Commit 05a8798f authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

store node_style in preference.

parent 7ceb2dad
...@@ -238,10 +238,12 @@ ...@@ -238,10 +238,12 @@
_id: "dream_demo" _id: "dream_demo"
}, function (err, response) { }, function (err, response) {
if (response !== undefined && response.data !== undefined) { if (response !== undefined && response.data !== undefined) {
// Add all elements
$.each(response.data.nodes, function (key, value) {
var preference = response.data.preference !== undefined ? var preference = response.data.preference !== undefined ?
response.data.preference : {}; response.data.preference : {};
dream_instance.setPreferences(preference);
// Add all elements
$.each(response.data.nodes, function (key, value) {
var coordinates = preference['coordinates'] || {}; var coordinates = preference['coordinates'] || {};
var coordinate = coordinates[key] || {}; var coordinate = coordinates[key] || {};
value['coordinate'] = {}; value['coordinate'] = {};
......
...@@ -128,6 +128,21 @@ ...@@ -128,6 +128,21 @@
return coordinate; return coordinate;
}; };
priv.updateNodeStyle = function (element_id) {
var node_style = priv.preference_container['node_style'] || {};
var element = $("#" + element_id);
element.css(node_style);
};
priv.saveNodeStyle = function (style_dict) {
var node_style = priv.preference_container['node_style'] || {};
$.each(style_dict, function (k, v) {
node_style[k] = v;
});
priv.preference_container['node_style'] = node_style;
priv.onDataChange();
};
priv.draggable = function () { priv.draggable = function () {
// make all the window divs draggable // make all the window divs draggable
var stop = function (el) { var stop = function (el) {
...@@ -171,7 +186,7 @@ ...@@ -171,7 +186,7 @@
var left = Math.floor(pos.left * (canvas_size_x - size_x)) + "px"; var left = Math.floor(pos.left * (canvas_size_x - size_x)) + "px";
priv.updateElementCoordinate(node, { priv.updateElementCoordinate(node, {
top: top, top: top,
left: left, left: left
}); });
$('#'+node).css('top', top); $('#'+node).css('top', top);
$('#'+node).css('left', left); $('#'+node).css('left', left);
...@@ -184,21 +199,27 @@ ...@@ -184,21 +199,27 @@
that.zoom_in = function () { that.zoom_in = function () {
var attr_list = ['width', 'height', 'font-size', 'padding-top', var attr_list = ['width', 'height', 'font-size', 'padding-top',
'line-height'] 'line-height'];
var style_dict = {};
$.each(attr_list, function (i, j) { $.each(attr_list, function (i, j) {
$('.window').css(j, var new_value = $('.window').css(j).replace('px', '') * 1.1111 + 'px';
$('.window').css(j).replace('px', '') * 1.1111 + 'px'); $('.window').css(j, new_value);
style_dict[j] = new_value;
}); });
priv.saveNodeStyle(style_dict);
jsPlumb.repaintEverything(); jsPlumb.repaintEverything();
}; };
that.zoom_out = function () { that.zoom_out = function () {
var attr_list = ['width', 'height', 'font-size', 'padding-top', var attr_list = ['width', 'height', 'font-size', 'padding-top',
'line-height'] 'line-height'];
var style_dict = {};
$.each(attr_list, function (i, j) { $.each(attr_list, function (i, j) {
$('.window').css(j, var new_value = $('.window').css(j).replace('px', '') * 0.9 + 'px';
$('.window').css(j).replace('px', '') * 0.9 + 'px'); $('.window').css(j, new_value);
style_dict[j] = new_value;
}); });
priv.saveNodeStyle(style_dict);
jsPlumb.repaintEverything(); jsPlumb.repaintEverything();
}; };
...@@ -257,6 +278,10 @@ ...@@ -257,6 +278,10 @@
}); });
}; };
that.setPreferences = function (preferences) {
priv.preference_container = preferences;
};
that.setGeneralProperties = function (properties) { that.setGeneralProperties = function (properties) {
priv.general_container = properties; priv.general_container = properties;
priv.onDataChange(); priv.onDataChange();
...@@ -275,6 +300,7 @@ ...@@ -275,6 +300,7 @@
box = $("#" + element.id); box = $("#" + element.id);
box.css("top", coordinate.top); box.css("top", coordinate.top);
box.css("left", coordinate.left); box.css("left", coordinate.left);
priv.updateNodeStyle(element.id);
// Initial DEMO code : make all the window divs draggable // Initial DEMO code : make all the window divs draggable
priv.draggable(); priv.draggable();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment