emanuele45 / StylePicker

This is not an addon, but a library to be used in ElkArte addons and written to provide a common interface to easily define CSS styles.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Style Picker library

A library for ElkArte addons that provides some basic tools to let people pick CSS styles (borders, colors, sizes, etc.) from the web interface.

Used for example in the addon Colored Names

Usage

$picker = new StylePicker();
loadTemplate('StylePicker');

$picker->addStyle(array(
	'padding' => array(
		'value' => '',
		'type' => 'text',
		'validate' => function($val) {
			if (preg_match('~^((\d+)|(\d+\.\d+))([a-z]{1,3}|%)$~', $val, $matches))
				return $val;
			else
				return '';
		},
	),
));

Rendering:

global $context;

$context['style_picker_elements'] = $picker->getAttributes();

template_profile_style_picker();

Validation:

require_once(SUBSDIR . '/DataValidator.class.php');

$validator = new Data_Validator();
$result = $picker->validate($_POST, $validator);

// Returns an array of valid styles or empty if no valid styles have been found

Build Status

About

This is not an addon, but a library to be used in ElkArte addons and written to provide a common interface to easily define CSS styles.


Languages

Language:PHP 100.0%