|
From: <net...@us...> - 2011-10-08 10:42:34
|
Revision: 431
http://openautomation.svn.sourceforge.net/openautomation/?rev=431&view=rev
Author: netzkind
Date: 2011-10-08 10:42:25 +0000 (Sat, 08 Oct 2011)
Log Message:
-----------
editor goes OO, php-files go failsave, editor force-reloads always
Modified Paths:
--------------
CometVisu/trunk/visu/designs/discreet/basic.css
CometVisu/trunk/visu/edit/get_addresses.php
CometVisu/trunk/visu/edit/get_widget_diagram.php
CometVisu/trunk/visu/edit/style_edit.css
CometVisu/trunk/visu/edit/visuconfig_edit.js
CometVisu/trunk/visu/edit_config.html
CometVisu/trunk/visu/lib/templateengine.js
CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js
Added Paths:
-----------
CometVisu/trunk/visu/edit/cometeditor.js
Modified: CometVisu/trunk/visu/designs/discreet/basic.css
===================================================================
--- CometVisu/trunk/visu/designs/discreet/basic.css 2011-10-01 09:00:10 UTC (rev 430)
+++ CometVisu/trunk/visu/designs/discreet/basic.css 2011-10-08 10:42:25 UTC (rev 431)
@@ -1,385 +1,386 @@
-@font-face { font-family: Liberation; src:url(fonts/liberationsans-regular.ttf); }
-@font-face { font-family: Liberation; font-weight: bold; src:url(fonts/liberationsans-bold.ttf); }
-
-body
-{
- color: white;
- font-family: Liberation;
- font-size: 5.5mm;
- overflow: hidden;
- margin:0;
- background: #1d1d1d; /* url(images/body_bg.png) repeat-x; */
-}
-
-h1
-{
- font-size: 2em;
- padding-left: 15px;
-}
-
-h2
-{
- font-size: 1.25em;
- margin-left: 15px;
- margin-top: 5px;
- margin-bottom: 5px;
-}
-
-body hr
-{
- clear:both;
- color: #81664b;
- background-color: #81664b;
- height: 1px;
- border:none;
- padding:0px;
- margin:0.1em;
-}
-
-#pages hr {
- border: 0; height: 30px; margin: 0 .1em;
- background: transparent url(images/hr_bg.png) 50% repeat-x;
- clear: both;
-}
-
-
-body br
-{
- clear:both;
-}
-
-div#top {
- padding-top: 8px;
- border-top: 3px solid #1d1d1d;
- border-bottom: 1px solid #0a0a0a;
- background-color: #121212;
- padding-bottom: 2px;
-}
-
-.page h1 {
- margin-top: 0;
- padding-top: 1em;
- background: #121212 url(images/head_bg.png) scroll repeat-x bottom;
-}
-
-.nav_path
-{
- color: #81664b;
- margin-left: 15px;
-}
-.nav_path a
-{
- color: white;
- text-decoration:none;
-}
-
-.footer,
-.footer *
-{
- color: #000000;
- font-size: 0.9em;
- vertical-align: middle;
-}
-
-.widget
-{
- float:left;
- width:48%;
- margin: .2em;
- padding: 0.3em;
- /* border:yellow 1px solid; */
- border-color: #020202;
- border-style: solid;
- border-width: 2px 0px 0px 2px;
- -moz-border-radius: 8px;
- -webkit-border-radius: 8px;
- border-radius: 8px;
- min-height: 2em;
- background-color: #101010;
-}
-
-.widget .widget
-{
- width:98%;
-}
-
-.text > div,
-.link > a {
- float:left;
- text-align:left;
- padding-left: 1em;
-}
-
-.widget .label,
-.widget.info .actor,
-.text > div,
-.link > a {
- line-height: 2em;
-}
-
-.widget .label
-{
- float:left;
- width:49%;
-/* color:red; */
-/* padding-right:0.25em; */
- text-align:left;
- padding-left: 1em;
-/* border:blue 1px solid; */
-}
-.widget .actor
-{
- float:left;
- margin-left:1em;
- text-align:left;
-}
-.widget .actor div
-{
- float:left;
- white-space: pre-wrap;
-}
-
-
-.green.switchPressed div, .green.switchUnpressed div{
- background: transparent url(images/dot_green.png) no-repeat center center;
- color: white !important;
-}
-.red.switchPressed div, .red.switchUnpressed div{
- background: transparent url(images/dot_red.png) no-repeat center center;
- color: white !important;
-}
-
-
-.red
-{
- color:#f44;
- font-weight:bold;
-}
-
-.green
-{
- color:#4f4;
-}
-
-.blue
-{
- color:#44f;
-}
-
-.purple
-{
- color:#f4f;
-}
-
-.link a
-{
- color: #81664b;
- width: 49%;
-}
-
-.page
-{
- float:left;
- width: 900px;
- overflow: auto;
- position: relative;
-}
-
-.switchPressed, .switchUnpressed {
- border-style: solid;
- -moz-border-radius: 12px;
- -webkit-border-radius: 12px;
- border-radius: 12px;
- padding: 1px;
- background: url(images/button_bg.png) #171717 repeat-x;
-}
-
-.switchUnpressed
-{
- border-width: 1px 2px 2px 1px;
- border-color: #282828 #010101 #010101 #282828;
- margin-top: 0px;
- background-color: #3A3A3A;
- background-position: center +2px;
-}
-.switchUnpressed div, .switchPressed div
-{
- padding: 5px;
- width: 5em;
- float: left;
- background: transparent;
- text-align: center;
- cursor: pointer;
-}
-
-.switchPressed
-{
- border-width: 2px 1px 1px 2px;
- border-color: #010101 #282828 #282828 #010101;
- margin-top: 1px;
- background-position: center -2px;
-}
-
-.switchUnpressed div {
- margin-left: -1px;
-}
-
-.switchPressed div {
- margin-top: -1px;
-}
-
-.ui-slider { position: relative; text-align: left; }
-.ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: 1.6em; height: 1.6em; cursor: default; }
-.ui-slider .ui-slider-range { position: absolute; z-index: 1; font-size: .7em; display: block; border: 0; background-position: 0 0; }
-
-.ui-slider-horizontal { height: .8em; }
-.ui-slider-horizontal .ui-slider-handle { top: -.5em; margin-left: -.8em; }
-.ui-slider-horizontal .ui-slider-range { top: 0; height: 100%; }
-.ui-slider-horizontal .ui-slider-range-min { left: 0; }
-.ui-slider-horizontal .ui-slider-range-max { right: 0; }
-
-.ui-slider-vertical { width: .8em; height: 100px; }
-.ui-slider-vertical .ui-slider-handle { left: -.3em; margin-left: 0; margin-bottom: -.6em; }
-.ui-slider-vertical .ui-slider-range { left: 0; width: 100%; }
-.ui-slider-vertical .ui-slider-range-min { bottom: 0; }
-.ui-slider-vertical .ui-slider-range-max { top: 0; }
-.ui-widget-content { border: 1px solid #dddddd; background: #000 ; color: #000; }
-.ui-widget-content a { color: #333333; }
-.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #cccccc; background: #000 ; font-weight: bold; color: #1c94c4; }
-.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #1c94c4; text-decoration: none; }
-.ui-corner-all { -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; }
-
-.dim .actor
-{
- width: 3em;
-}
-.widget .ui-slider
-{
- width: 30%;
- float: left;
- margin-left: 10px;
- margin-left: 1em;
- margin-top: 0.5em;
- border-color: #010101 #282828 #282828 #010101;
- background: url(images/gradient.png) #a7a7a7 repeat-y;
-}
-
-.widget .ui-slider-handle
-{
- border-style: solid;
- -moz-border-radius: 12px;
- -webkit-border-radius: 12px;
- border-radius: 12px;
- padding: 1px;
- background: url(images/button_bg.png) #171717 repeat-x;
- border-width: 1px 2px 2px 1px;
- border-color: #282828 #010101 #010101 #282828;
-}
-/* Clearfix */
-.clearfix:after {
- content: ".";
- display: block;
- clear: both;
- visibility: hidden;
- line-height: 0;
- height: 0;
-}
-
-.clearfix {
- display: inline-block;
-}
-
-html[xmlns] .clearfix {
- display: block;
-}
-
-*:first-child+html .clearfix {
- min-height: 0;
-}
-
-* html .clearfix {
- height: 1%;
-}
-
-* html>body .clearfix {
- display: inline-block;
- width: 100%;
-}
-
-* html .clearfix {
- /* Hides from IE-mac \*/
- height: 1%;
- /* End hide from IE-mac */
-}
-
-.loading {
- display: block !important;
-}
-
-div#loading {
- display: none !important;
-}
-
-
-.popup,
-.popup_background {
- position: absolute;
- width: 90%;
- height: 90%;
- top: 5%;
- left: 5%;
-}
-
-.popup {
- z-index: 101;
- background: transparent;
-}
-
-
-.popup_background {
- z-index: 100;
- border-color: #020202;
- border-style: solid;
- border-width: 2px 0px 0px 2px;
- -moz-border-radius: 8px;
- -webkit-border-radius: 8px;
- border-radius: 8px;
- background: #101010;
- opacity: .98;
-}
-
-.popup div {
- margin: 4px;
-}
-
-.popup div.head {
- border-bottom: 1px solid;
-}
-
-.popup_background.error {
- background: #800000;
- border: #f00;
-}
-
-.clickable {
- cursor: pointer;
-}
-
-.diagram_inline {
- width: 320px;
- height: 180px;
-}
-
-.diagram_preview {
- width: 240px;
- height: 2em;
-}
-
-#diagramTooltip {
- z-index: 1000;
- color: black;
- border: 1px solid #fdd;
- padding: 2px;
- background-color: #fee;
- opacity: 0.80;
+@font-face { font-family: Liberation; src:url(fonts/liberationsans-regular.ttf); }
+@font-face { font-family: Liberation; font-weight: bold; src:url(fonts/liberationsans-bold.ttf); }
+
+body
+{
+ color: white;
+ font-family: Liberation;
+ font-size: 5.5mm;
+ overflow: hidden;
+ margin:0;
+ background: #1d1d1d; /* url(images/body_bg.png) repeat-x; */
+}
+
+h1
+{
+ font-size: 2em;
+ padding-left: 15px;
+}
+
+h2
+{
+ font-size: 1.25em;
+ margin-left: 15px;
+ margin-top: 5px;
+ margin-bottom: 5px;
+}
+
+body hr
+{
+ clear:both;
+ color: #81664b;
+ background-color: #81664b;
+ height: 1px;
+ border:none;
+ padding:0px;
+ margin:0.1em;
+}
+
+#pages hr {
+ border: 0; height: 30px; margin: 0 .1em;
+ background: transparent url(images/hr_bg.png) 50% repeat-x;
+ clear: both;
+}
+
+
+body br
+{
+ clear:both;
+}
+
+div#top {
+ padding-top: 8px;
+ border-top: 3px solid #1d1d1d;
+ border-bottom: 1px solid #0a0a0a;
+ background-color: #121212;
+ padding-bottom: 2px;
+}
+
+.page h1 {
+ margin-top: 0;
+ padding-top: 1em;
+ background: #121212 url(images/head_bg.png) scroll repeat-x bottom;
+}
+
+.nav_path
+{
+ color: #81664b;
+ margin-left: 15px;
+}
+.nav_path a
+{
+ color: white;
+ text-decoration:none;
+}
+
+.footer,
+.footer *
+{
+ color: #000000;
+ font-size: 0.9em;
+ vertical-align: middle;
+}
+
+.widget
+{
+ float:left;
+ width:48%;
+ margin: .2em;
+ padding: 0.3em;
+ /* border:yellow 1px solid; */
+ border-color: #020202;
+ border-style: solid;
+ border-width: 2px 0px 0px 2px;
+ -moz-border-radius: 8px;
+ -webkit-border-radius: 8px;
+ border-radius: 8px;
+ min-height: 2em;
+ background-color: #101010;
+}
+
+.widget .widget
+{
+ width:98%;
+}
+
+.text > div,
+.link > a {
+ float:left;
+ text-align:left;
+ padding-left: 1em;
+}
+
+.widget .label,
+.widget.info .actor,
+.text > div,
+.link > a {
+ line-height: 2em;
+}
+
+.widget .label
+{
+ float:left;
+ width:49%;
+/* color:red; */
+/* padding-right:0.25em; */
+ text-align:left;
+ padding-left: 1em;
+/* border:blue 1px solid; */
+}
+.widget .actor
+{
+ float:left;
+ margin-left:1em;
+ text-align:left;
+}
+.widget .actor div
+{
+ float:left;
+ white-space: pre-wrap;
+}
+
+
+.green.switchPressed div, .green.switchUnpressed div{
+ background: transparent url(images/dot_green.png) no-repeat center center;
+ color: white !important;
+}
+.red.switchPressed div, .red.switchUnpressed div{
+ background: transparent url(images/dot_red.png) no-repeat center center;
+ color: white !important;
+}
+
+
+.red
+{
+ color:#f44;
+ font-weight:bold;
+}
+
+.green
+{
+ color:#4f4;
+}
+
+.blue
+{
+ color:#44f;
+}
+
+.purple
+{
+ color:#f4f;
+}
+
+.link a
+{
+ color: #81664b;
+ width: 49%;
+}
+
+.page
+{
+ float:left;
+ width: 900px;
+ overflow: auto;
+ position: relative;
+}
+
+.switchPressed, .switchUnpressed {
+ border-style: solid;
+ -moz-border-radius: 12px;
+ -webkit-border-radius: 12px;
+ border-radius: 12px;
+ padding: 1px;
+ background: url(images/button_bg.png) #171717 repeat-x;
+}
+
+.switchUnpressed
+{
+ border-width: 1px 2px 2px 1px;
+ border-color: #282828 #010101 #010101 #282828;
+ margin-top: 0px;
+ background-color: #3A3A3A;
+ background-position: center +2px;
+}
+.switchUnpressed div, .switchPressed div
+{
+ padding: 5px;
+ width: 5em;
+ float: left;
+ background: transparent;
+ text-align: center;
+ cursor: pointer;
+}
+
+.switchPressed
+{
+ border-width: 2px 1px 1px 2px;
+ border-color: #010101 #282828 #282828 #010101;
+ margin-top: 1px;
+ background-position: center -2px;
+}
+
+.switchUnpressed div {
+ margin-left: -1px;
+}
+
+.switchPressed div {
+ margin-top: -1px;
+}
+
+.ui-slider { position: relative; text-align: left; }
+.ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: 1.6em; height: 1.6em; cursor: default; }
+.ui-slider .ui-slider-range { position: absolute; z-index: 1; font-size: .7em; display: block; border: 0; background-position: 0 0; }
+
+.ui-slider-horizontal { height: .8em; }
+.ui-slider-horizontal .ui-slider-handle { top: -.5em; margin-left: -.8em; }
+.ui-slider-horizontal .ui-slider-range { top: 0; height: 100%; }
+.ui-slider-horizontal .ui-slider-range-min { left: 0; }
+.ui-slider-horizontal .ui-slider-range-max { right: 0; }
+
+.ui-slider-vertical { width: .8em; height: 100px; }
+.ui-slider-vertical .ui-slider-handle { left: -.3em; margin-left: 0; margin-bottom: -.6em; }
+.ui-slider-vertical .ui-slider-range { left: 0; width: 100%; }
+.ui-slider-vertical .ui-slider-range-min { bottom: 0; }
+.ui-slider-vertical .ui-slider-range-max { top: 0; }
+.ui-widget-content { border: 1px solid #dddddd; background: #000 ; color: #000; }
+.ui-widget-content a { color: #333333; }
+.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #cccccc; background: #000 ; font-weight: bold; color: #1c94c4; }
+.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #1c94c4; text-decoration: none; }
+.ui-corner-all { -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; }
+
+.dim .actor
+{
+ width: 3em;
+}
+.widget .ui-slider
+{
+ width: 30%;
+ float: left;
+ margin-left: 10px;
+ margin-left: 1em;
+ margin-top: 0.5em;
+ border-color: #010101 #282828 #282828 #010101;
+ background: url(images/gradient.png) #a7a7a7 repeat-y;
+}
+
+.widget .ui-slider-handle
+{
+ border-style: solid;
+ -moz-border-radius: 12px;
+ -webkit-border-radius: 12px;
+ border-radius: 12px;
+ padding: 1px;
+ background: url(images/button_bg.png) #171717 repeat-x;
+ border-width: 1px 2px 2px 1px;
+ border-color: #282828 #010101 #010101 #282828;
+}
+/* Clearfix */
+.clearfix:after {
+ content: ".";
+ display: block;
+ clear: both;
+ visibility: hidden;
+ line-height: 0;
+ height: 0;
+}
+
+.clearfix {
+ display: inline-block;
+}
+
+html[xmlns] .clearfix {
+ display: block;
+}
+
+*:first-child+html .clearfix {
+ min-height: 0;
+}
+
+* html .clearfix {
+ height: 1%;
+}
+
+* html>body .clearfix {
+ display: inline-block;
+ width: 100%;
+}
+
+* html .clearfix {
+ /* Hides from IE-mac \*/
+ height: 1%;
+ /* End hide from IE-mac */
+}
+
+.loading {
+ display: block !important;
+}
+
+div#loading {
+ display: none !important;
+}
+
+
+.popup,
+.popup_background {
+ position: absolute;
+ width: 90%;
+ height: 90%;
+ top: 5%;
+ left: 5%;
+}
+
+.popup {
+ z-index: 101;
+ background: transparent;
+}
+
+
+.popup_background {
+ z-index: 100;
+ border-color: #020202;
+ border-style: solid;
+ border-width: 2px 0px 0px 2px;
+ -moz-border-radius: 8px;
+ -webkit-border-radius: 8px;
+ border-radius: 8px;
+ background: #101010;
+ opacity: .98;
+}
+
+.popup div {
+ margin: 4px;
+}
+
+.popup div.head {
+ border-bottom: 1px solid;
+}
+
+.popup_background.error {
+ background: #800000;
+ border: #f00;
+}
+
+.clickable {
+ cursor: pointer;
+}
+
+.diagram_inline {
+ margin-left: 1em;
+ width: 320px;
+ height: 180px;
+}
+
+.diagram_preview {
+ width: 240px;
+ height: 2em;
+}
+
+#diagramTooltip {
+ z-index: 1000;
+ color: black;
+ border: 1px solid #fdd;
+ padding: 2px;
+ background-color: #fee;
+ opacity: 0.80;
}
\ No newline at end of file
Added: CometVisu/trunk/visu/edit/cometeditor.js
===================================================================
--- CometVisu/trunk/visu/edit/cometeditor.js (rev 0)
+++ CometVisu/trunk/visu/edit/cometeditor.js 2011-10-08 10:42:25 UTC (rev 431)
@@ -0,0 +1,637 @@
+var CometEditor = function() {
+ var Editor = this;
+ Editor.cache = {};
+
+
+ Editor.cacheServerData = function(url, variable) {
+ // get all GAs from the server
+ $.ajax({
+ url: url,
+ type: "GET",
+ dataType: "json",
+ success: function(data) {
+ Editor.cache[variable] = data;
+ },
+ error: function(xhr, textStatus, e) {
+ Editor.cache[variable] = false;
+ $("#StatusBar").jnotifyAddMessage({
+ text: lingua("bad_get_" + variable, textStatus + " " + e),
+ permanent: false,
+ type: "error",
+ disappearTime: 30000
+ });
+ }
+ });
+ }
+
+ Editor.refreshEditor = function(val) {
+ // the type has been changed
+ // we need to change the input-field accordingly to match
+ // what attributes we need
+
+
+ // get all the info we need to edit this piece of work
+ var creator = design.getCreator(val);
+ var attributes = creator.attributes || {};
+ var elements = creator.elements || {};
+
+ // find old input-fields in the editor to remember those values ...
+ // this is need in case someone switches types while editing - and sure they want to keep their settings
+ var container = $("#addMaster div.inputs");
+ var values = $.extend({}, $("#addMaster").data("widgetdata"));
+
+ if (!$("#pages .inedit").is(".widget")) {
+ // this needs to be changed for the new settings-layout - it's completely broken right now!
+ // alte Werte zwischenspeichern
+ container.find(":input").each(function() {
+ if ($(this).val() != "") {
+ var name = $(this).data("name");
+ values[name] = $(this).val();
+ }
+ })
+ }
+ container.empty();
+
+ // we will need this variable later on to store our fieldset in.
+ var set;
+ if (typeof creator.content.type != "undefined" && creator.content.type == "string") {
+
+ var element = $("<div />").addClass("add_input").addClass("content")
+ .append($("<label />").attr("for", "add_textContent").html("text-content"))
+ .append($("<div class=\"input\" />")
+ .append($("<input type=\"text\" id=\"add_textContent\"/>"))
+ );
+ if (typeof values["textContent"] != "undefined") {
+ element.find("input").val(values["textContent"]);
+ }
+
+ element.find(":input").data("required", creator.content.required);
+
+ container.append(element);
+ delete element;
+ }
+
+ if (false === jQuery.isEmptyObject(elements)) {
+ // we've got elements we need to addit :)
+ container.append(set = jQuery("<fieldset />").addClass("elements"));
+ jQuery.each(elements, function(index, e) {
+ var $line = $("<div />").addClass("add_input")
+ .append($("<label />").attr("for", "add_" + index).html(index))
+ .append($("<div class=\"input\" />"));
+ var $input = $line.find("div.input");
+
+ switch (e.type) {
+ case "address":
+ // create a fake input-element to store our data later on
+ $input.append(jQuery("<input type=\"hidden\" id=\"add_" + index + "\" class=\"multi address\" />"));
+
+ // create the real inputs-thingy-thing
+ $input.append('<div><div class="add_element">+</div><div class="multi_element address" /></div>');
+ $input.find(".add_element").click(function() {
+ // insert a new, empty sub-element
+ var objData = {};
+ // don't try to hide it: this is hardcoded and works for addresses only
+ objData.type = "address";
+ objData.textContent = "";
+ objData._attributes = {};
+ objData._attributes.transform = "";
+ objData._attributes.type = "";
+ objData._attributes.readonly = false;
+
+ var elementDiv = HTMLLayer.createAddressEditorElement(objData);
+ $input.find("div.multi_element").append(elementDiv);
+ });
+
+ if (typeof values._elements != "undefined"
+ && typeof values._elements[index] != "undefined") {
+ $.each(values._elements[index], function(i, e) {
+ var elementDiv = HTMLLayer.createAddressEditorElement(e);
+ $input.find("div.multi_element").append(elementDiv);
+ });
+ }
+ break;
+ default:
+ // add an unknown element (e.g. the label)
+ if (e.multi == false) {
+ // this element can appear only once
+ $input.append(jQuery("<input type=\"text\" id=\"add_" + index + "\" />"));
+
+ if (typeof values._elements != "undefined"
+ && typeof values._elements[index] != "undefined") {
+ $.each(values._elements[index], function(i, e) {
+ $input.find("input").val(values._elements[index][0].textContent);
+ });
+ }
+ } else {
+ // handling for "if an element can appear more than once"
+ // TODO: needs to be coded once someone wants to use it :)
+ }
+ break;
+ }
+
+ // remember how to name and how to validate this input
+ $line.find(":input")
+ .data("name", index)
+ .data("required", e.required)
+ .data("type", e.type);
+
+ // add this "line" to the editor
+ set.append($line);
+ delete $line;
+ });
+ }
+
+ if (false === jQuery.isEmptyObject(attributes)) {
+ // we've got attributes to addit :)
+ container.append(set = jQuery("<fieldset />").addClass("attributes"));
+ $.each(attributes, function (index, e) {
+ var $line = $("<div />").addClass("add_input")
+ .append($("<label />").attr("for", "add_" + index).html(index))
+ .append($("<div class=\"input\" />"));
+ var $input = $line.find("div.input");
+
+ switch (e.type) {
+ case "mapping":
+ $input.append($("<select id=\"add_mapping\" />")
+ .append($("<option />").attr("value", "").html("-")));
+ jQuery.each(mappings, function(i, tmp) {
+ $input.find("select#add_mapping").append($("<option />").attr("value", i).html(i));
+ });
+
+ if (typeof values._attributes != "undefined"
+ && typeof values._attributes[index] != "undefined") {
+ $input.find("option[value=" + values._attributes[index] + "]").attr("selected", "selected");
+ }
+
+ break;
+
+ case "styling":
+ $input.append($("<select id=\"add_styling\" />")
+ .append($("<option />").attr("value", "").html("-")));
+ jQuery.each(stylings, function(i, tmp) {
+ $input.find("select#add_styling").append($("<option />").attr("value", i).html(i));
+ });
+
+ if (typeof values._attributes != "undefined"
+ && typeof values._attributes[index] != "undefined") {
+ $input.find("option[value=" + values._attributes[index] + "]").attr("selected", "selected");
+ }
+
+ break;
+ case "datatype":
+ break;
+ case "list":
+ $input.append($("<select id=\"add_" + index + "\" />")
+ .append($("<option />").attr("value", "").html("-")));
+ jQuery.each(e.list, function (i, val) {
+ $input.find("select#add_" + index).append($("<option />").attr("value", i).html(val));
+ });
+
+ if (typeof values._attributes != "undefined"
+ && typeof values._attributes[index] != "undefined") {
+ $input.find("option[value=" + values._attributes[index] + "]").attr("selected", "selected");
+ }
+
+ break;
+ default:
+ $input.append($("<input type=\"text\" id=\"add_" + index + "\" />"));
+
+ if (typeof values._attributes != "undefined"
+ && typeof values._attributes[index] != "undefined") {
+ $input.find("input").val(values._attributes[index]);
+ }
+
+ break;
+ }
+
+ if ($line.find("select")[0]) {
+ var select = $line.find("select");
+ select.change(function() {
+ // update the input-field
+ jQuery(this).parent().find("input").val(jQuery(this).val());
+ })
+ }
+
+ $line.find(":input")
+ .data("name", index)
+ .data("required", e.required)
+ .data("type", e.type);
+
+ set.append($line);
+ delete $line;
+ });
+ }
+ }
+
+
+ Editor.saveElement = function() {
+ // Daten aus den Eingabefeldner übernehmen
+ // einfach alle rein - wir haben ja nur die passenden Felder
+
+ var container = $("#addMaster div.inputs");
+
+ // dataObject needs to be a real dom-object, so we need to go all the
+ // way through parsing an xml-string ...
+ var name = jQuery("#addMaster #add_type").val();
+ var text = container.find("#add_textContent:input").val();
+ var xml = "<" + name + ">" + text + "</" + name + ">";
+ var dataObject;
+
+ if (window.DOMParser) {
+ var parser = new DOMParser();
+ dataObject = parser.parseFromString(xml, "text/xml");
+ } else {
+ // Internet Explorer
+ dataObject = new ActiveXObject("Microsoft.XMLDOM");
+ dataObject.async="false";
+ dataObject.loadXML(xml);
+ }
+
+ dataObject = jQuery(dataObject.documentElement);
+ if (typeof (dataObject.nodeName) == "undefined" || dataObject.nodeName == "") {
+ dataObject.nodeName = name;
+ }
+ if (typeof (text) != "undefined"
+ && (typeof (dataObject.textContent) == "undefined" || dataObject.textContent == "")) {
+ dataObject.textContent = text;
+ }
+
+ var error = false;
+
+ // get the settings for all sub-elements
+ container.find("fieldset.elements :input").each(function() {
+ var name = $(this).data("name");
+
+ if (!$(this).is(".multi")) {
+ if ($(this).val() != "") {
+ // validating
+ if (false === Editor.validateInput($(this).val(), $(this).data("type"))) {
+ $('#StatusBar').jnotifyAddMessage({
+ text: lingua("value_invalid", name),
+ permanent: false,
+ type: 'error'
+ });
+ // do not save
+ error = true;
+ }
+ dataObject.append($("<" + name + " />").append($(this).val()));
+ } else if ($(this).data("required") === true) {
+ // do not save
+ $('#StatusBar').jnotifyAddMessage({
+ text: lingua("value_required", name),
+ permanent: false,
+ type: 'error'
+ });
+ error = true;
+ }
+ } else {
+ // multi-element-input
+ if ($(this).is(".address")) {
+ $elements = jQuery(this).closest("div.input").find(".multi_element .element");
+ $elements.each(function (index, e) {
+ $address = $("<address />")
+ .attr("transform", $(e).data("transform"))
+ .attr("variant", $(e).data("variant"))
+ .attr("readonly", $(e).data("readonly") == true ? "true" : "false")
+ .append($(e).data("address"));
+ dataObject.append($address);
+ });
+ }
+ }
+ });
+
+ // get the settings for all attributes
+ container.find("fieldset.attributes :input").each(function() {
+ var name = $(this).data("name");
+
+ if ($(this).val() != "") {
+ // validating
+ if (false === Editor.validateInput($(this).val(), $(this).data("type"))) {
+ $('#StatusBar').jnotifyAddMessage({
+ text: lingua("value_invalid", name),
+ permanent: false,
+ type: 'error'
+ });
+ // do not save
+ error = true;
+ }
+ dataObject.attr(name, $(this).val());
+ } else if ($(this).data("required") === true) {
+ // do not save
+ $('#StatusBar').jnotifyAddMessage({
+ text: lingua("value_required", name),
+ permanent: false,
+ type: 'error'
+ });
+ error = true;
+ }
+ });
+
+ if (error !== false) {
+ return;
+ }
+
+ // als path verwenden wir einfach den aktuellen UNIX-Timestamp
+ // der wird nicht schon belegt sein
+ var path = $(".page:visible:last").attr("id");
+ path = path + "_" + new Date().getTime();
+ var newWidget = create_pages(dataObject, path);
+
+ // falls es eine page war dann muss die HINTER das aktuelle Element
+ $("#" + path + ".page").insertAfter($(".page:visible:last"));
+
+ if ($("#pages .inedit").is(".widget")) {
+ $("#pages .inedit").replaceWith(newWidget);
+ } else {
+ jQuery(".page:visible:last > div").append(newWidget);
+ }
+ jQuery("#pages").triggerHandler("done");
+
+ // und dann noch mich wieder verstecken
+ jQuery("#addMaster").trigger("hide").trigger("cleanup");
+
+ };
+
+ Editor.validateInput = function (val, type) {
+ /**
+ * check whether a user-given value matches the type-criterias and thus is valid
+ */
+
+ if (typeof type == "undefined" || type == null) {
+ // nicht mit Geistern rumschlagen
+ return true;
+ }
+ if (typeof type == "object") {
+ // wohl ein regulärer Ausdruck
+ try {
+ if (val.match(type)) {
+ return true;
+ } else {
+ return false;
+ }
+
+ } catch (e) {
+ $('#StatusBar').jnotifyAddMessage({
+ text: lingua("regexp_invalid", name),
+ permanent: false,
+ type: 'error'
+ });
+ return false;
+ }
+ }
+
+ switch (type) {
+ case "address":
+ return Boolean(val.match(/^[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{1,3}$/) != null);
+ break;
+ case "datatype":
+ case "numeric":
+ return Boolean(val.match(/^-?\d+([\.,]\d+)?$/g));
+ break;
+ case "string":
+ case "uri":
+ return Boolean(typeof val == "string");
+ break;
+ case "mapping":
+ return Boolean(typeof mappings[val] != "undefined");
+ break;
+ case "styling":
+ return Boolean(typeof stylings[val] != "undefined");
+ break;
+ }
+ }
+
+ Editor.saveConfig = function() {
+ var configData = Editor.createObjectFromPage("#0.page");
+ var configDataJSON = JSON.stringify(configData);
+ delete configData;
+
+ var configSuffix = "";
+ if ($.getUrlVar("config")) {
+ configSuffix = "_" + $.getUrlVar("config");
+ }
+
+ $.ajax({
+ type: "POST",
+ data: {data: configDataJSON, config: configSuffix},
+ url: "edit/save_config.php",
+ cache: false,
+ dataType: "json",
+ error: function(XMLHttpRequest, textStatus, errorThrown) {
+ $('#StatusBar').jnotifyAddMessage({
+ text: lingua("save_bad", errorThrown),
+ permanent: false,
+ type: 'error',
+ disappearTime: 30000
+ });
+ },
+ success: function(data, textStatus, XMLHttpRequest) {
+ if (data != 1) {
+ $('#StatusBar').jnotifyAddMessage({
+ text: lingua("save_bad", data),
+ permanent: false,
+ type: 'error',
+ disappearTime: 30000
+ });
+ return;
+ }
+ $('#StatusBar').jnotifyAddMessage({
+ text: lingua("save_good"),
+ permanent: false,
+ type: 'message'
+ });
+ }
+ });
+ }
+
+ Editor.getWidgetData = function(element, nodive) {
+ var myObj = {};
+
+ var e = $(element);
+
+ myObj._type = e.data("nodeName");
+ myObj.textContent = e.data("textContent");
+ myObj._attributes = e.data("configData").attributes;
+
+ if (e.data("configData").elements) {
+ // Sub-Elements must be processed differently.
+ var myElements = {};
+ $.each(e.data("configData").elements, function (index, elementGroup) {
+ $.each(elementGroup, function (index, element) {
+ var myElement = {};
+ element = jQuery(element).get(0);
+ switch (element.nodeName) {
+ case "address":
+ myElement._type = "address";
+ myElement.textContent = element.textContent;
+
+ myElement._attributes = {};
+
+ myElement._attributes.transform = jQuery(element).attr("transform");
+ myElement._attributes.readonly = jQuery(element).attr("readonly");
+ myElement._attributes.type = jQuery(element).attr("type") || "";
+ break;
+ default:
+ // mostly labels
+ myElement._type = element.nodeName;
+ myElement.textContent = element.textContent;
+ break;
+ }
+ if (typeof(myElements[element.nodeName]) == "undefined") {
+ myElements[element.nodeName] = [];
+ }
+ myElements[element.nodeName].push(myElement);
+ });
+ });
+ // add it to the object-to-be-saved
+ myObj._elements = myElements;
+ }
+
+ if (e.is(".pagelink")) {
+ // it's a page, we need to dive in
+ // eine Sub-Seite
+ // versuchen die Seiten-Id durch den Link zu bekommen
+ var s = e.find("a");
+ var href = s.attr("href");
+ var matches = href.match(/(\d+_)*\d+/);
+
+ var subElements = new Array();
+ if (matches && (typeof nodive == "undefined" || !nodive)) {
+ // wenn wir eine Id haben, dann suchen wir die Seite
+ // und serialisieren sie auch
+ var page = $("#pages").find("#" + matches[0] + ".page");
+ var subObject = Editor.createObjectFromPage(page);
+ if (subObject._elements.length > 0) {
+ myObj = subObject;
+ }
+ }
+ }
+
+ return myObj;
+ }
+
+ Editor.createObjectFromPage = function(pageObject) {
+ var obj = {};
+ var elements = new Array();
+ $(pageObject).find("h1, .widget").each(function(index, element) {
+ if ($(element).is("h1")) {
+ // Seitenname
+ obj.name = $(element).text();
+ obj._type = "page";
+ if ($(element).parents("div.page").data("configData")) {
+ var data = $(element).parents("div.page").data("configData");
+ obj = jQuery.extend(obj, data.attributes);
+ }
+ } else {
+ var myObj = {};
+ myObj = Editor.getWidgetData(element);
+ if (typeof myObj != "undefined" && typeof myObj._type != "undefined") {
+ elements.push(myObj);
+ }
+ }
+
+ });
+
+ obj._elements = elements;
+ return obj;
+ }
+
+ Editor.getAddressesObject = function() {
+
+ if (typeof Editor.cache.cachedAddressesObject == "object") {
+ return Editor.cache.cachedAddressesObject.clone();
+ }
+
+ element = $("<select />");
+
+ $.each(Editor.cache.addresses, function(hg, sub) {
+ $.each(sub, function(mg, addresses) {
+ element.append(
+ $("<optgroup />").attr("label", hg + " - " + mg)
+ );
+ $.each(addresses, function (i, address) {
+ element.find("optgroup:last")
+ .append($("<option />").attr("value", address.address)
+ .addClass("dpt_DPT:" + address.dpt)
+ .html(address.name)
+ )
+ });
+ });
+ });
+
+ Editor.cache.cachedAddressesObject = element.children();
+
+ return Editor.cache.cachedAddressesObject;
+ }
+
+ Editor.getDPTObject = function() {
+
+ if (typeof Editor.cache.cachedDPTObject == "object") {
+ return Editor.cache.cachedDPTObject.clone();
+ }
+
+ var element = $("<select />");
+
+ var lastMajor = "";
+
+ $.each(Editor.cache.dpts, function(i, dptDefinition) {
+ var myMajor = lastMajor;
+ var t = dptDefinition.dpt.match(/^([0-9]+)\./);
+ if (typeof (t[1]) != "undefined") {
+ myMajor = t[1];
+ }
+
+ if (lastMajor != myMajor) {
+ if (element.is("optgroup")) {
+ element = element.closest("select");
+ }
+ element.append($("<optgroup />").attr("label", "DPT " + myMajor));
+ lastMajor = myMajor;
+ }
+
+ element.find("optgroup:last").append($("<option />").attr("value", "DPT:" + dptDefinition.dpt)
+ .html("" + dptDefinition.dpt + ": " + dptDefinition.name)
+ );
+ });
+
+ Editor.cache.cachedDPTObject = element.children();
+
+ return Editor.cache.cachedDPTObject;
+ }
+
+};
+
+var CometEditorHTMLLayer = function() {
+
+ var Layer = this;
+
+ /**
+ * Create a sub-element for the multi-editor to edit an address-entry.
+ */
+ Layer.createAddressEditorElement = function(elementData) {
+ var elementDiv = jQuery("<div class=\"element clearfix\" />");
+ elementDiv.append("<div class=\"title\" />")
+ .append("<div class=\"value editable\" />")
+ .append("<div class=\"transform editable\" />")
+ .append("<div class=\"variant editable\" />")
+ .append("<div class=\"readonly editable\" />");
+ //myDiv.find(".title").append();
+ var t = Editor.getAddressesObject();
+ elementDiv.find(".title").append(t.find("option[value=" + elementData.textContent + "]").text());
+ elementDiv.find(".value").append(elementData.textContent);
+ elementDiv.find(".transform").append(elementData._attributes.transform);
+ if (elementData._attributes.type != "undefined" && elementData._attributes.type != "") {
+ elementDiv.find(".variant").append(elementData._attributes.type).show();
+ } else {
+ elementDiv.find(".variant").hide();
+ }
+ elementDiv.find(".readonly").append(elementData._attributes.readonly == "true" ? "readonly" : "")
+
+ elementDiv.data("transform", elementData._attributes.transform)
+ .data("variant", elementData._attributes.type)
+ .data("readonly", elementData._attributes.readonly == "true" ? true : false)
+ .data("address", elementData.textContent);
+
+ return elementDiv;
+ }
+}
\ No newline at end of file
Modified: CometVisu/trunk/visu/edit/get_addresses.php
===================================================================
--- CometVisu/trunk/visu/edit/get_addresses.php 2011-10-01 09:00:10 UTC (rev 430)
+++ CometVisu/trunk/visu/edit/get_addresses.php 2011-10-08 10:42:25 UTC (rev 431)
@@ -3,11 +3,21 @@
define('FILE_HG', "/etc/wiregate/eibga_hg.conf");
define('FILE_MG', "/etc/wiregate/eibga_mg.conf");
-$arrGA = parse_ini_file(FILE_GA, true);
-$arrHG = parse_ini_file(FILE_HG, true);
-$arrMG = parse_ini_file(FILE_MG, true);
+$arrGA = array();
+$arrHG = array();
+$arrMG = array();
+if (true === file_exists(FILE_GA)) {
+ $arrGA = parse_ini_file(FILE_GA, true);
+}
+if (true === file_exists(FILE_HG)) {
+ $arrHG = parse_ini_file(FILE_HG, true);
+}
+if (true === file_exists(FILE_MG)) {
+ $arrMG = parse_ini_file(FILE_MG, true);
+}
+
$arrAdresses = array();
foreach ($arrGA as $strGA => $arrData) {
$arrGAParts = explode("/", $strGA, 3);
Modified: CometVisu/trunk/visu/edit/get_widget_diagram.php
===================================================================
--- CometVisu/trunk/visu/edit/get_widget_diagram.php 2011-10-01 09:00:10 UTC (rev 430)
+++ CometVisu/trunk/visu/edit/get_widget_diagram.php 2011-10-08 10:42:25 UTC (rev 431)
@@ -3,9 +3,17 @@
define('FILE_OW', "/etc/wiregate/owsensors.conf");
define('DIR_RRD', "/var/www/rrd/*.rrd");
-$arrOW = parse_ini_file(FILE_OW, true);
-$arrGA = parse_ini_file(FILE_GA, true);
+$arrOW = array();
+if (true === file_exists(FILE_OW)) {
+ $arrOW = parse_ini_file(FILE_OW, true);
+}
+
+$arrGA = array();
+if (true === file_exists(FILE_GA)) {
+ $arrGA = parse_ini_file(FILE_GA, true);
+}
+
$arrAdresses = array();
foreach (glob(DIR_RRD) as $filename) {
Modified: CometVisu/trunk/visu/edit/style_edit.css
===================================================================
--- CometVisu/trunk/visu/edit/style_edit.css 2011-10-01 09:00:10 UTC (rev 430)
+++ CometVisu/trunk/visu/edit/style_edit.css 2011-10-08 10:42:25 UTC (rev 431)
@@ -124,7 +124,7 @@
height: 1em;
}
-.element .value, .element .transform, .element .readonly, .element .addresstype {
+.element .value, .element .transform, .element .readonly, .element .variant {
font-weight: normal;
height: 1em;
font-size: small;
@@ -143,17 +143,17 @@
font-style: italic;
}
-.element .addresstype {
+.element .variant {
float: left;
margin-left: .4em;
font-weight: bold;
}
-.element .addresstype:before {
+.element .variant:before {
content: "(";
}
-.element .addresstype:after {
+.element .variant:after {
content: ")";
}
Modified: CometVisu/trunk/visu/edit/visuconfig_edit.js
===================================================================
--- CometVisu/trunk/visu/edit/visuconfig_edit.js 2011-10-01 09:00:10 UTC (rev 430)
+++ CometVisu/trunk/visu/edit/visuconfig_edit.js 2011-10-08 10:42:25 UTC (rev 431)
@@ -1,16 +1,16 @@
var lingua = function(element, param) {
var texts = {
- confirm_delete: "Delete '%s' from this page?",
- confirm_save: "Save config?",
- prompt_rename: "Rename page '%s' to ...",
- save_good: "Config has been successfully saved.",
- save_bad: "Config not saved. Error: '%s'",
- value_required: "Field '%s' is required but empty. Please correct your input.",
- value_invalid: "The value for field '%s' is invalid. Please correct your input.",
- regexp_invalid: "There's something wrong with the cable.",
- getaddr_bad: "Failed to get address-config. Error: '%s'.",
- getdpt_bad: "Failed to get DPT-config. Error: '%s'.",
- getrrd_bad: "Failed to get available RRDs. Error: '%s'."
+ confirm_delete: "Delete '%s' from this page?",
+ confirm_save: "Save config?",
+ prompt_rename: "Rename page '%s' to ...",
+ save_good: "Config has been successfully saved.",
+ save_bad: "Config not saved. Error: '%s'",
+ value_required: "Field '%s' is required but empty. Please correct your input.",
+ value_invalid: "The value for field '%s' is invalid. Please correct your input.",
+ regexp_invalid: "There's something wrong with the cable.",
+ bad_get_addresses: "Failed to get address-config. Error: '%s'.",
+ bad_get_dpts: "Failed to get DPT-config. Error: '%s'.",
+ bad_get_rrds: "Failed to get available RRDs. Error: '%s'."
}
if (typeof texts[element] == "undefined") {
@@ -26,13 +26,40 @@
return myText;
}
-var addressesCache;
-var dptCache;
-var rrdCache
+/**
+ * Rename a page
+ * uses simple javascript-prompt to request a new name from the user
+ */
+function renamePage(widget) {
+ var data = Editor.getWidgetData(widget, true);
+ var newText = prompt(lingua("prompt_rename", data._attributes.name), data._attributes.name);
+ if (!newText) {
+ return;
+ }
+
+ var path = widget.data("path");
+
+ widget.find("a").html(newText);
+ widget.data("name", newText);
+ $("#pages").find("#" + path + ".page").find("h1").html(newText);
+ // update configData or next "edit" will show old name
+ widget.data("configData").attributes.name = newText;
+}
+
+
+var Editor = new CometEditor();
+var HTMLLayer = new CometEditorHTMLLayer();
+
jQuery(document).ready(function() {
+ $('#StatusBar').jnotifyInizialize({oneAtTime: false})
- $('#StatusBar').jnotifyInizialize({ oneAtTime: false })
+ // get all rrds from the server
+ Editor.cacheServerData("edit/get_widget_diagram.php", "rrdCache");
+ // get all GAs from the server
+ Editor.cacheServerData("edit/get_addresses.php", "addresses");
+ // get all known dpt from the server
+ Editor.cacheServerData("edit/dpt_list.json", "dpts");
jQuery("div#addwidgetcontrol").bind("click", function() {
$("#addMaster").triggerHandler("cleanup");
@@ -40,66 +67,9 @@
});
$("#saveconfigcontrol").bind("click", function () {
- saveConfig();
+ Editor.saveConfig();
});
- // get all GAs from the server
- $.ajax({
- url: "edit/get_addresses.php",
- type: "GET",
- dataType: "json",
- success: function(data) {
- addressesCache = data;
- },
- error: function(xhr, textStatus, e) {
- addressesCache = false;
- $('#StatusBar').jnotifyAddMessage({
- text: lingua("getaddr_bad", textStatus + " " +e),
- permanent: false,
- type: 'error',
- disappearTime: 30000
- });
- }
- });
-
- // get all known dpt from the server
- $.ajax({
- url: "edit/dpt_list.json",
- type: "GET",
- dataType: "json",
- success: function(data) {
- dptCache = data;
- },
- error: function(xhr, textStatus, e) {
- dptCache = false;
- $('#StatusBar').jnotifyAddMessage({
- text: lingua("getdpt_bad", textStatus + " " +e),
- permanent: false,
- type: 'error',
- disappearTime: 30000
- });
- }
- });
-
- // get all rrds from the server
- $.ajax({
- url: "edit/get_widget_diagram.php",
- type: "GET",
- dataType: "json",
- success: function(data) {
- rrdCache = data;
- },
- error: function(xhr, textStatus, e) {
- rrdCache = false;
- $('#StatusBar').jnotifyAddMessage({
- text: lingua("getrrd_bad", textStatus + " " +e),
- permanent: false,
- type: 'error',
- disappearTime: 30000
- });
- }
- });
-
jQuery("#pages").bind("done", function() {
$("#pages hr, #pages br").each(function() {
if ($(this).closest(".widget").length == 0) {
@@ -138,11 +108,12 @@
// "unknown" is not a good choice for a new widget :)
return;
}
- if( design.creators[index].maturity > use_maturity )
- {
+
+ if (design.creators[index].maturity > use_maturity) {
// widget is not mature enough to show in the edior
return;
}
+
$("#addMaster").find("select#add_type").append(
$("<option />").attr("value", index).html(index)
);
@@ -151,7 +122,7 @@
jQuery(".removecontrol").live("click", function() {
var widget = $(this).parents("div.widget");
- var data = getWidgetData(widget, true);
+ var data = Editor.getWidgetData(widget, true);
var t;
if (data._type == "page") {
@@ -174,7 +145,7 @@
return renamePage(widget);
}
- var data = getWidgetData(widget, true);
+ var data = Editor.getWidgetData(widget, true);
// kennzeichnen welches Element grade bearbeitet wird
widget.addClass("inedit");
@@ -215,7 +186,7 @@
myElement.find(":input").val($e.text());
}
- if (typeof addressesCache != undefined && addressesCache != false) {
+ if (typeof Editor.cache.addresses != undefined && Editor.cache.addresses != false) {
var input = myElement.find("input");
input.attr("disabled", "disabled");
myElement.append($("<input type=\"checkbox\" name=\"enable_address\" checked=\"checked\" />")
@@ -233,7 +204,7 @@
myElement.append($("<select class=\"add_address\" />")
.append($("<option />").attr("value", "").html("-")));
- myElement.find("select:first").append(getAddressesObject());
+ myElement.find("select:first").append(Editor.getAddressesObject());
myElement.find("select").bind("change", function() {
// on changing the address, the coresponding datatype-field is
@@ -255,7 +226,7 @@
}
if ($e.hasClass("transform")) {
element.find("label").html("transform");
- if (typeof dptCache == undefined || dptCache == false) {
+ if (typeof Editor.cache.dpts == undefined || Editor.cache.dpts == false) {
// appearantly we were unable to load the list of datatypes from the server
// we will provide an input-field instead
myElement.append($("<input class=\"add_transform\" />"));
@@ -267,7 +238,7 @@
myElement.append($("<select class=\"add_transform\" />")
.append($("<option />").attr("value", "").html("-")));
- myElement.find("select:first").append(getDPTObject());
+ myElement.find("select:first").append(Editor.getDPTObject());
if (typeof $e.text() != "undefined") {
myElement.find("option[value=" + $e.text() + "]").attr("selected", "selected");
@@ -283,9 +254,9 @@
}
}
- if ($e.hasClass("addresstype")) {
- element.find("label").html("addresstype");
- myElement.append($("<input class=\"add_addresstype\" />"));
+ if ($e.hasClass("variant")) {
+ element.find("label").html("variant");
+ myElement.append($("<input class=\"add_variant\" />"));
if (typeof $e.text() != "undefined") {
// pre-set the value
myElement.find(":input").val($e.text());
@@ -321,11 +292,11 @@
objData.textContent = $e.find("input.add_address").val();
objData._attributes = {};
objData._attributes.transform = $e.find(".add_transform").val();
- objData._attributes.type = $e.find(".add_addresstype").val();
+ objData._attributes.type = $e.find(".add_variant").val();
objData._attributes.readonly = $e.find(".add_readonly:checked").val();
// remove this item and insert a new one instead
- var elementDiv = createAddressEditorElement(objData);
+ var elementDiv = HTMLLayer.createAddressEditorElement(objData);
$this.closest(".element").replaceWith(elementDiv);
}))
@@ -342,11 +313,7 @@
}))
);
});
-});
-
-jQuery(function() {
- // dem addMaster Leben einhauchen
jQuery("#addMaster")
.bind("show", function() {
if ($("#pages .inedit").is(".widget")) {
@@ -384,633 +351,15 @@
// the type has been changed
// we need to change the input-field accordingly to match
// what attributes we need
- var val = jQuery(this).val();
-
- // get all the info we need to edit this piece of work
- var creator = design.getCreator(val);
- var attributes = creator.attributes || {};
- var elements = creator.elements || {};
-
- // find old input-fields in the editor to remember those values ...
- // this is need in case someone switches types while editing - and sure they want to keep their settings
- var container = $("#addMaster div.inputs");
- var values = $.extend({}, $("#addMaster").data("widgetdata"));
-
- if (!$("#pages .inedit").is(".widget")) {
- // this needs to be changed for the new settings-layout - it's completely broken right now!
- // alte Werte zwischenspeichern
- container.find(":input").each(function() {
- if ($(this).val() != "") {
- var name = $(this).data("name");
- values[name] = $(this).val();
- }
- })
- }
- container.empty();
-
- // we will need this variable later on to store our fieldset in.
- var set;
- if (typeof creator.content.type != "undefined" && creator.content.type == "string") {
-
- var element = $("<div />").addClass("add_input").addClass("content")
- .append($("<label />").attr("for", "add_textContent").html("text-content"))
- .append($("<div class=\"input\" />")
- .append($("<input type=\"text\" id=\"add_textContent\"/>"))
- );
- if (typeof values["textContent"] != "undefined") {
- element.find("input").val(values["textContent"]);
- }
-
- element.find(":input").data("required", creator.content.required);
-
- container.append(element);
- delete element;
- }
-
- if (false === jQuery.isEmptyObject(elements)) {
- // we've got elements we need to addit :)
- container.append(set = jQuery("<fieldset />").addClass("elements"));
- jQuery.each(elements, function(index, e) {
- var $line = $("<div />").addClass("add_input")
- .append($("<label />").attr("for", "add_" + index).html(index))
- .append($("<div class=\"input\" />"));
- var $input = $line.find("div.input");
-
- switch (e.type) {
- case "address":
- // create a fake input-element to store our data later on
- $input.append(jQuery("<input type=\"hidden\" id=\"add_" + index + "\" class=\"multi address\" />"));
-
- // create the real inputs-thingy-thing
- $input.append('<div><div class="add_element">+</div><div class="multi_element address" /></div>');
- $input.find(".add_element").click(function() {
- // insert a new, empty sub-element
- var objData = {};
- // don't try to hide it: this is hardcoded and works for addresses only
- objData.type = "address";
- objData.textContent = "";
- objData._attributes = {};
- objData._attributes.transform = "";
- objData._attributes.type = "";
- objData._attributes.readonly = false;
-
- var elementDiv = createAddressEditorElement(objData);
- $input.find("div.multi_element").append(elementDiv);
- });
-
- if (typeof values._elements != "undefined"
- && typeof values._elements[index] != "undefined") {
- $.each(values._elements[index], function(i, e) {
- var elementDiv = createAddressEditorElement(e);
- $input.find("div.multi_element").append(elementDiv);
- });
- }
- break;
- default:
- // add an unknown element (e.g. the label)
- if (e.multi == false) {
- // this element can appear only once
- $input.append(jQuery("<input type=\"text\" id=\"add_" + index + "\" />"));
-
- if (typeof values._elements != "undefined"
- && typeof values._elements[index] != "undefined") {
- ...
[truncated message content] |