|
From: <net...@us...> - 2011-12-18 12:50:00
|
Revision: 584
http://openautomation.svn.sourceforge.net/openautomation/?rev=584&view=rev
Author: netzkind
Date: 2011-12-18 12:49:54 +0000 (Sun, 18 Dec 2011)
Log Message:
-----------
made Editor work with UI-fixes from #583
Modified Paths:
--------------
CometVisu/trunk/visu/edit/cometeditor.js
CometVisu/trunk/visu/edit/style_edit.css
CometVisu/trunk/visu/edit/visuconfig_edit.js
Modified: CometVisu/trunk/visu/edit/cometeditor.js
===================================================================
--- CometVisu/trunk/visu/edit/cometeditor.js 2011-12-18 11:21:22 UTC (rev 583)
+++ CometVisu/trunk/visu/edit/cometeditor.js 2011-12-18 12:49:54 UTC (rev 584)
@@ -175,7 +175,7 @@
if (typeof values._attributes != "undefined"
&& typeof values._attributes[index] != "undefined") {
- $input.find("option[value=" + values._attributes[index] + "]").attr("selected", "selected");
+ $input.find("option[value='" + values._attributes[index] + "']").attr("selected", "selected");
}
break;
@@ -189,7 +189,7 @@
if (typeof values._attributes != "undefined"
&& typeof values._attributes[index] != "undefined") {
- $input.find("option[value=" + values._attributes[index] + "]").attr("selected", "selected");
+ $input.find("option[value='" + values._attributes[index] + "']").attr("selected", "selected");
}
break;
@@ -204,7 +204,7 @@
if (typeof values._attributes != "undefined"
&& typeof values._attributes[index] != "undefined") {
- $input.find("option[value=" + values._attributes[index] + "]").attr("selected", "selected");
+ $input.find("option[value='" + values._attributes[index] + "']").attr("selected", "selected");
}
break;
@@ -356,7 +356,7 @@
$("#" + path + ".page").insertAfter($(".page:visible:last"));
if ($("#pages .inedit").is(".widget")) {
- $("#pages .inedit").replaceWith(newWidget);
+ $("#pages .inedit").closest(".widget_container").replaceWith(newWidget);
} else {
jQuery(".page:visible:last > div").append(newWidget);
}
@@ -463,6 +463,11 @@
var myObj = {};
var e = $(element);
+
+ // if this is a widget-container, get its widget
+ if (e.is(".widget_container")) {
+ e = e.children(".widget");
+ }
myObj._type = e.data("nodeName");
myObj.textContent = e.data("textContent");
@@ -632,7 +637,7 @@
.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(".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.variant != "undefined" && elementData._attributes.variant != "") {
Modified: CometVisu/trunk/visu/edit/style_edit.css
===================================================================
--- CometVisu/trunk/visu/edit/style_edit.css 2011-12-18 11:21:22 UTC (rev 583)
+++ CometVisu/trunk/visu/edit/style_edit.css 2011-12-18 12:49:54 UTC (rev 584)
@@ -1,5 +1,5 @@
/* Editor-Stuff */
-.widget {position: relative;}
+.widget_container, .widget {position: relative;}
.editcontrol, .movecontrol, .removecontrol {
position: absolute;
@@ -181,8 +181,8 @@
padding-left: 120px;
}
-div.line {
- width: 97%;
+.widget_container.line {
+ width: 100%;
}
div.line hr {
Modified: CometVisu/trunk/visu/edit/visuconfig_edit.js
===================================================================
--- CometVisu/trunk/visu/edit/visuconfig_edit.js 2011-12-18 11:21:22 UTC (rev 583)
+++ CometVisu/trunk/visu/edit/visuconfig_edit.js 2011-12-18 12:49:54 UTC (rev 584)
@@ -71,36 +71,46 @@
});
jQuery("#pages").bind("done", function() {
+ // wrap hr and br into "widgets", so they can be moved + removed
$("#pages hr, #pages br").each(function() {
if ($(this).closest(".widget").length == 0) {
- $(this).wrap("<div class=\"widget clearfix line\" />");
+ $(this).wrap("<div class=\"widget clearfix\" />");
+ $(this).closest(".widget").wrap("<div class=\"widget_container line\" />");
var d = $.extend({}, $(this).data());
$(this).closest("div.widget").data(d);
}
});
+ // init "sortable"
jQuery(".page div").sortable({
handle: ".movecontrol",
- items: '.widget',
+ items: '.widget_container',
stop: function(event, ui) {
//console.log(jQuery(this).sortable("toArray"));
// hier haben wir eine neue Config
}
});
- jQuery(".widget").unbind("mouseenter.edit").bind("mouseenter.edit", function() {
+ // create buttons for edit, move, remove
+ jQuery(".widget_container").unbind("mouseenter.edit").bind("mouseenter.edit", function() {
jQuery(this).data("background-color-old", jQuery(this).css("background-color"));
- $(this).prepend(jQuery("<div />").attr("class", "movecontrol"));
- $(this).prepend(jQuery("<div />").attr("class", "editcontrol").html("edit"));
- $(this).prepend(jQuery("<div />").attr("class", "removecontrol").html("x"));
+ if ($(this).find("div.movecontrol").is("div")) {
+ jQuery(this).find("div.editcontrol, div.movecontrol, div.removecontrol").show();
+ } else {
+ $(this).prepend(jQuery("<div />").attr("class", "movecontrol"));
+ $(this).prepend(jQuery("<div />").attr("class", "editcontrol").html("edit"));
+ $(this).prepend(jQuery("<div />").attr("class", "removecontrol").html("x"));
+ }
});
- jQuery(".widget").unbind("mouseleave.edit").bind("mouseleave.edit", function() {
+ // remove buttons when cursor leaves
+ jQuery(".widget_container").unbind("mouseleave.edit").bind("mouseleave.edit", function() {
jQuery(this).css("background-color", jQuery(this).data("background-color-old"));
- jQuery(this).find("div.editcontrol, div.movecontrol, div.removecontrol").remove();
+ jQuery(this).find("div.editcontrol, div.movecontrol, div.removecontrol").hide();
});
+ // create list of widgets to be insertable/editable
var options = {};
$("#addMaster").find("select#add_type").empty();
jQuery.each(design.creators, function (index, e) {
@@ -120,8 +130,9 @@
});
});
+ // act on "remove"-Clicks
jQuery(".removecontrol").live("click", function() {
- var widget = $(this).parents("div.widget");
+ var widget = $(this).siblings("div.widget");
var data = Editor.getWidgetData(widget, true);
var t;
@@ -132,15 +143,16 @@
}
var b = confirm(lingua("confirm_delete", t));
if (b) {
- widget.remove();
+ widget.closest(".widget_container").remove();
}
});
+ // act on "edit"-clicks
jQuery(".editcontrol").live("click", function() {
$("#addMaster").triggerHandler("cleanup");
- var widget = $(this).parents("div.widget");
+ var widget = $(this).siblings("div.widget");
if (widget.is(".pagelink")) {
return renamePage(widget);
}
@@ -152,11 +164,12 @@
$("#addMaster").data("widgetdata", data);
- $("#addMaster #add_type").find("option[value=" + data._type + "]").attr("selected", "selected");
+ $("#addMaster #add_type").find("option[value='" + data._type + "']").attr("selected", "selected");
$("#addMaster").triggerHandler("show");
});
+ // multi-element edits, like "address"
jQuery(".multi_element .element").live("click", function() {
$this = jQuery(this);
if ($this.is(".inedit")) {
@@ -214,12 +227,12 @@
if ($dptField.is("input")) {
$dptField.val(dpt);
} else if ($dptField.is("select")) {
- $dptField.find("option[value=" + dpt + "]").attr("selected", "selected");
+ $dptField.find("option[value='" + dpt + "']").attr("selected", "selected");
}
});
if (typeof $e.text() != "undefined") {
- myElement.find("option[value=" + $e.text() + "]").attr("selected", "selected");
+ myElement.find("option[value='" + $e.text() + "']").attr("selected", "selected");
}
}
@@ -241,7 +254,7 @@
myElement.find("select:first").append(Editor.getDPTObject());
if (typeof $e.text() != "undefined") {
- myElement.find("option[value=" + $e.text() + "]").attr("selected", "selected");
+ myElement.find("option[value='" + $e.text() + "']").attr("selected", "selected");
}
}
@@ -314,7 +327,9 @@
);
});
+ // edit-"window"
jQuery("#addMaster")
+ // act on "show"
.bind("show", function() {
if ($("#pages .inedit").is(".widget")) {
$(this).find(".create").hide().end().find(".edit").show();
@@ -325,7 +340,7 @@
// if we have widget-specific data, we must be in edit-mode
var widgetdata = $(this).data("widgetdata");
if (typeof widgetdata != "undefined") {
- $(this).find("#add_type").find("option[value=" + widgetdata._type + "]").attr("selected", "selected").trigger("change");
+ $(this).find("#add_type").find("option[value='" + widgetdata._type + "']").attr("selected", "selected").trigger("change");
}
$(this).show()
@@ -333,20 +348,24 @@
jQuery(".page div").sortable("destroy");
jQuery(".widget").unbind("mouseenter.edit").trigger("mouseleave.edit").unbind("mouseleave.edit");
})
+ // act on "hide"
.bind("hide", function() {
$(this).hide();
$("#pages").triggerHandler("done");
})
+ // cleanup
.bind("cleanup", function() {
$(this).removeData("widgetdata");
jQuery(this).find("input[type=text]").val("");
$("#addMaster div.inputs").empty();
$("#pages").find(".inedit").removeClass("inedit");
})
+ // cancel: hide and cleanup
.find("#add_cancel").click(function() {
jQuery("#addMaster").trigger("hide").trigger("cleanup")
})
.end()
+ // act on changes of widget-type (the select-list)
.find("#add_type").change(function() {
// the type has been changed
// we need to change the input-field accordingly to match
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|