Update Button class.
This commit is contained in:
parent
22ec9cd469
commit
32f9a483a5
|
|
@ -28,6 +28,8 @@
|
||||||
if (!class_exists('button')) {
|
if (!class_exists('button')) {
|
||||||
class button {
|
class button {
|
||||||
|
|
||||||
|
public static $collapse = 'hide-md-dn';
|
||||||
|
|
||||||
static function create($array) {
|
static function create($array) {
|
||||||
$button_icons = $_SESSION['theme']['button_icons']['text'] != '' ? $_SESSION['theme']['button_icons']['text'] : 'auto';
|
$button_icons = $_SESSION['theme']['button_icons']['text'] != '' ? $_SESSION['theme']['button_icons']['text'] : 'auto';
|
||||||
//button: open
|
//button: open
|
||||||
|
|
@ -60,9 +62,16 @@ if (!class_exists('button')) {
|
||||||
!$array['icon'] ||
|
!$array['icon'] ||
|
||||||
$array['class'] == 'link'
|
$array['class'] == 'link'
|
||||||
)) {
|
)) {
|
||||||
$hide_class = $array['icon'] && $button_icons != 'always' && $button_icons != 'never' ? 'hide-sm' : null;
|
if ($array['icon'] && $button_icons != 'always' && $button_icons != 'never' && $array['collapse'] !== false) {
|
||||||
|
if ($array['collapse'] != '') {
|
||||||
|
$collapse_class = $array['collapse'];
|
||||||
|
}
|
||||||
|
else if (self::$collapse !== false) {
|
||||||
|
$collapse_class = self::$collapse;
|
||||||
|
}
|
||||||
|
}
|
||||||
$pad_class = $array['icon'] ? 'pad' : null;
|
$pad_class = $array['icon'] ? 'pad' : null;
|
||||||
$button .= "<span class='button-label ".$hide_class." ".$pad_class."'>".$array['label']."</span>";
|
$button .= "<span class='button-label ".$collapse_class." ".$pad_class."'>".$array['label']."</span>";
|
||||||
}
|
}
|
||||||
//button: close
|
//button: close
|
||||||
$button .= "</button>";
|
$button .= "</button>";
|
||||||
|
|
@ -80,7 +89,7 @@ if (!class_exists('button')) {
|
||||||
/*
|
/*
|
||||||
//usage
|
//usage
|
||||||
|
|
||||||
echo button::create(['type'=>'button','label'=>$text['button-label'],'icon'=>'icon','name'=>'btn','id'=>'btn','value'=>'value','link'=>'url','target'=>'_blank','onclick'=>'javascript','class'=>'name','style'=>'css','title'=>$text['button-label']]);
|
echo button::create(['type'=>'button','label'=>$text['button-label'],'icon'=>'icon','name'=>'btn','id'=>'btn','value'=>'value','link'=>'url','target'=>'_blank','onclick'=>'javascript','class'=>'name','style'=>'css','title'=>$text['button-label'],'collapse'=>'class']);
|
||||||
|
|
||||||
echo button::create([
|
echo button::create([
|
||||||
'type'=>'button',
|
'type'=>'button',
|
||||||
|
|
@ -94,13 +103,12 @@ if (!class_exists('button')) {
|
||||||
'onclick'=>'javascript',
|
'onclick'=>'javascript',
|
||||||
'class'=>'name',
|
'class'=>'name',
|
||||||
'style'=>'css',
|
'style'=>'css',
|
||||||
'title'=>$text['button-label']
|
'title'=>$text['button-label'],
|
||||||
|
'collapse'=>'class'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
//options
|
//options
|
||||||
|
|
||||||
note: all are parameters are optional, but at least set a value for label or icon
|
|
||||||
|
|
||||||
type 'button' (default) | 'submit' | 'link'
|
type 'button' (default) | 'submit' | 'link'
|
||||||
label button text
|
label button text
|
||||||
icon name without vendor prefix (e.g. 'user' instead of 'fa-user')
|
icon name without vendor prefix (e.g. 'user' instead of 'fa-user')
|
||||||
|
|
@ -110,6 +118,16 @@ if (!class_exists('button')) {
|
||||||
class css class[es]
|
class css class[es]
|
||||||
style css style[s]
|
style css style[s]
|
||||||
title tooltip text (if not set, defaults to value of label)
|
title tooltip text (if not set, defaults to value of label)
|
||||||
|
collapse overide the default hide class ('hide-md-dn')
|
||||||
|
|
||||||
|
//notes
|
||||||
|
|
||||||
|
1) all parameters are optional, but at least set a value for label or icon
|
||||||
|
2) overide the default hide class ('hide-md-dn') for all buttons that follow by using...
|
||||||
|
|
||||||
|
button::$collapse = '...';
|
||||||
|
|
||||||
|
3) setting either collapse (instance or default) to false (boolean) will cause the button label to always be visible
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue