Added widget for html-XET tag and added forgotten et2_styles.js

This commit is contained in:
Andreas Stöckel 2011-08-16 13:12:39 +00:00
parent 40a11bdb4f
commit 786ec9220c
6 changed files with 118 additions and 2 deletions

View File

@ -7,7 +7,7 @@
* @link http://www.egroupware.org
* @author Andreas Stöckel
* @copyright Stylite 2011
* @version $Id: et2_widget.js 36021 2011-08-07 13:43:46Z igel457 $
* @version $Id$
*/
"use strict";

50
etemplate/js/et2_html.js Normal file
View File

@ -0,0 +1,50 @@
/**
* eGroupWare eTemplate2 - JS widget class containing raw HTML
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate
* @subpackage api
* @link http://www.egroupware.org
* @author Andreas Stöckel
* @copyright Stylite 2011
* @version $Id$
*/
"use strict";
/*egw:uses
jsapi.jsapi; // Needed for egw_seperateJavaScript
jquery.jquery;
et2_baseWidget;
*/
var et2_html = et2_baseWidget.extend({
init: function() {
this._super.apply(this, arguments);
// Allow no child widgets
this.supportedWidgetClasses = [];
this.htmlNode = $j(document.createElement("span"));
this.setDOMNode(this.htmlNode[0]);
},
loadContent: function(_data) {
// Create an object containg the given value and an empty js string
var html = {html: value, js: ''};
// Seperate the javascript from the given html. The js code will be
// written to the previously created empty js string
egw_seperateJavaScript(html);
// Append the html to the parent element
this.htmlNode.append(html.html);
this.htmlNode.append(html.js);
}
});
et2_register_widget(et2_html, ["html"]);

View File

@ -7,7 +7,7 @@
* @link http://www.egroupware.org
* @author Andreas Stöckel
* @copyright Stylite 2011
* @version $Id: et2_widget.js 36021 2011-08-07 13:43:46Z igel457 $
* @version $Id$
*/
"use strict";

View File

@ -0,0 +1,62 @@
/**
* eGroupWare eTemplate2 - JS widget class containing styles
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate
* @subpackage api
* @link http://www.egroupware.org
* @author Andreas Stöckel
* @copyright Stylite 2011
* @version $Id$
*/
"use strict";
/*egw:uses
et2_widget;
*/
/**
* Function which appends the encapsulated style data to the head tag of the
* page.
*
* TODO: The style data could be parsed for rules and appended using the JS
* stylesheet interface, allowing the style only to modifiy nodes of the current
* template.
*/
var et2_styles = et2_widget.extend({
init: function() {
this._super.apply(this, arguments);
// Allow no child widgets
this.supportedWidgetClasses = [];
// Create the textnode which will contain the style data
this.textNode = document.createTextNode();
// Create the style node and append it to the head node
this.styleNode = document.createElement("style");
this.styleNode.setAttribute("type", "text/css");
this.styleNode.appendChild(this.textNode);
(document.getElementsByTagName("head")[0]).appendChild(this.styleNode);
},
destroy: function() {
this._super.apply(this, arguments);
// Remove the style node again and delete any reference to it
(document.getElementsByTagName("head")[0]).removeChild(this.styleNode);
this.styleNode = null;
},
loadContent: function(_content) {
// Set the style data
this.textNode.data = _content;
}
});
et2_register_widget(et2_styles, ["styles"]);

View File

@ -19,6 +19,7 @@
et2_description;
et2_textbox;
et2_styles;
et2_html;
// Requirements for the etemplate2 object
et2_xml;

View File

@ -19,11 +19,14 @@
<script src="../et2_box.js"></script>
<script src="../et2_textbox.js"></script>
<script src="../et2_styles.js"></script>
<script src="../et2_html.js"></script>
<script src="../etemplate2.js"></script>
<!--<script src="../et2_tabs.js"></script>-->
<script src="../lib/tooltip.js"></script>
<script src="../../../phpgwapi/js/jsapi/jsapi.js"></script>
<script src="et2_test_timesheet_edit.json"></script>
<script src="et2_test_expressions.json"></script>