📄 color_selector.class.inc
字号:
<?php/** * @copyright Intermesh 2003 * @author Merijn Schering <mschering@intermesh.nl> * @version $Revision: 1.8 $ $Date: 2005/07/20 10:06:20 $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. * @package Framework * @subpackage Controls *//** * Prints a color selector with custom colors * * @package Framework * @subpackage Controls * * @access public */class color_selector extends table{ /** * The array of colors to be selectable * * @var String * @access private */ var $colors = array(); var $form_name = 'forms[0]'; /** * Adds a color to the control * * @param String $color_code The Hexadecimal color code * @access public * @retrun void */ function add_color($color_code) { $this->colors[] = $color_code; } /** * Prints the color selector * * @param String $name The name of the control * @param String $selected_color The selected color code * @param String $form_name The form name where the color selector is in * @access public * @retrun void */ function color_selector($id, $name, $value, $form_name ='forms[0]') { global $GO_THEME; $this->value= $value; $this->name= $name; $this->form_name= $form_name; $this->set_attribute('id', $id); } function get_html() { if (!in_array($this->value, $this->colors)) { $this->value = $this->colors[0]; } $this->add_outerhtml_element(new input('hidden', $this->name, $this->value, false)); $row = new table_row(); $img = new image('blank'); $img->set_attribute('style', 'height:16px;width:16px;border:0px;'); while ($color_code = array_shift($this->colors)) { $cell = new table_cell(); $cell->add_html_element(new hyperlink('javascript:select_background_'.$this->attributes['id'] .'(\''.$color_code.'\')', $img->get_html())); $cell->set_attribute('id', $this->attributes['id'].'_'.$color_code); $cell->set_attribute('style', 'background-color: #'.$color_code.'; border: 1px solid #aaa;'); $row->add_cell($cell); } $this->add_row($row); return parent::get_html()." <script type=\"text/javascript\" language=\"javascript\"> function select_background_".$this->attributes['id'] ."(color) { active_table_cell = get_object('".$this->attributes['id']."_'+document.".$this->form_name.".elements['".$this->name."'].value); table_cell = get_object('".$this->attributes['id']."_'+color); active_table_cell.style.border = '1px solid #aaa'; table_cell.style.border = '2px solid black'; document.".$this->form_name.".elements['".$this->name."'].value = color; } select_background_".$this->attributes['id']."('".$this->value."'); </script>"; }}?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -