mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 00:29:18 +01:00
- Add image widget
- Add missing dependency on et2_core_common
This commit is contained in:
parent
4fc8cadcb2
commit
8a632c723a
47
etemplate/inc/class.etemplate_widget_image.inc.php
Normal file
47
etemplate/inc/class.etemplate_widget_image.inc.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* EGroupware - eTemplate serverside image widget
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
* @copyright 2011 Nathan Gray
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* eTemplate image widget
|
||||
* Displays image from URL, vfs, or finds by name
|
||||
*/
|
||||
class etemplate_widget_image extends etemplate_widget
|
||||
{
|
||||
/**
|
||||
* Fill type options in self::$request->sel_options to be used on the client
|
||||
*
|
||||
* @param string $cname
|
||||
*/
|
||||
public function beforeSendToClient($cname)
|
||||
{
|
||||
$attrs = $this->attrs;
|
||||
$form_name = self::form_name($cname, $this->id);
|
||||
$value =& self::get_array(self::$request->content, $form_name);
|
||||
|
||||
$image = $value != '' ? $value : $this->attrs['src'];
|
||||
|
||||
if (is_string($image)) list($app,$img) = explode('/',$image,2);
|
||||
if (!$app || !$img || !is_dir(EGW_SERVER_ROOT.'/'.$app) || strpos($img,'/')!==false)
|
||||
{
|
||||
$img = $image;
|
||||
list($app) = explode('.',$form_name);
|
||||
}
|
||||
$src = common::find_image($app, $img);
|
||||
if(!$this->id)
|
||||
{
|
||||
// self::setElementAttribute($this->attrs['src'], 'id', $this->attrs['src']);
|
||||
}
|
||||
self::setElementAttribute($this->attrs['src'], 'src', $src);
|
||||
}
|
||||
}
|
||||
etemplate_widget::registerWidget('etemplate_widget_image', array('image'));
|
72
etemplate/js/et2_widget_image.js
Normal file
72
etemplate/js/et2_widget_image.js
Normal file
@ -0,0 +1,72 @@
|
||||
/**
|
||||
* eGroupWare eTemplate2 - JS Description object
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
* @copyright Nathan Gray 2011
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
/*egw:uses
|
||||
jquery.jquery;
|
||||
et2_core_baseWidget;
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class which implements the "image" XET-Tag
|
||||
*/
|
||||
var et2_image = et2_baseWidget.extend({
|
||||
|
||||
attributes: {
|
||||
"src": {
|
||||
"name": "Image",
|
||||
"type": "string",
|
||||
"description": "Displayed image",
|
||||
"translate": "!no_lang"
|
||||
},
|
||||
"link": {
|
||||
},
|
||||
"link_target":{
|
||||
},
|
||||
"imagemap":{
|
||||
},
|
||||
"link_size":{
|
||||
}
|
||||
},
|
||||
|
||||
legacyOptions: ["link", "link_target", "imagemap", "link_size"],
|
||||
|
||||
init: function() {
|
||||
this._super.apply(this, arguments);
|
||||
|
||||
// Create the image or a/image tag
|
||||
this.image = this.node = $j(document.createElement("img"));
|
||||
if(this.options.link)
|
||||
{
|
||||
this.node = $j(document.createElement("a"));
|
||||
this.image.appendTo(this.node);
|
||||
}
|
||||
this.setDOMNode(this.node[0]);
|
||||
},
|
||||
|
||||
set_label: function(_value) {
|
||||
if(_value == this.options.label) return;
|
||||
this.options.label = _value;
|
||||
this.image.attr("alt", _value);
|
||||
},
|
||||
|
||||
set_src: function(_value) {
|
||||
console.log("IMAGE ", _value);
|
||||
this.options.src = _value;
|
||||
this.image.attr("src", _value);
|
||||
}
|
||||
});
|
||||
|
||||
et2_register_widget(et2_image, ["image"]);
|
||||
|
||||
|
@ -29,10 +29,12 @@
|
||||
et2_widget_html;
|
||||
et2_widget_tabs;
|
||||
et2_widget_hrule;
|
||||
et2_widget_image;
|
||||
|
||||
et2_extension_nextmatch;
|
||||
|
||||
// Requirements for the etemplate2 object
|
||||
et2_core_common;
|
||||
et2_core_xml;
|
||||
et2_core_arrayMgr;
|
||||
et2_core_interfaces;
|
||||
@ -205,7 +207,7 @@ etemplate2.prototype.submit = function()
|
||||
if (canSubmit)
|
||||
{
|
||||
// Create the request object
|
||||
if (typeof egw_json_request != "undefined")
|
||||
if (typeof egw_json_request != "undefined" && this.menuaction)
|
||||
{
|
||||
var request = new egw_json_request(this.menuaction, [this.etemplate_exec_id,values], this);
|
||||
request.sendRequest(true);
|
||||
|
@ -12,7 +12,7 @@
|
||||
<radio label="Radio" id="radio_value"/>
|
||||
<buttononly label="Button" id="button_value"/>
|
||||
<hrule label="HR"/>
|
||||
<image label="Image" src="image_value"/>
|
||||
<image label="Image" src="phpgwapi/templates/default/images/edit.png"/>
|
||||
<menulist>
|
||||
<menupopup label="Selectbox" id="selectbox_value" options="No value">
|
||||
<option value="1">Test 1</option>
|
||||
|
@ -29,6 +29,7 @@
|
||||
<script src="../et2_widget_styles.js"></script>
|
||||
<script src="../et2_widget_html.js"></script>
|
||||
<script src="../et2_widget_hrule.js"></script>
|
||||
<script src="../et2_widget_image.js"></script>
|
||||
<script src="../et2_widget_date.js"></script>
|
||||
<script src="../et2_widget_tabs.js"></script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user