WIP first partially working version without mongodb, using sqlite/sequelize
This commit is contained in:
@@ -36,13 +36,11 @@ SpacedeckAccount = {
|
||||
|
||||
save_user_language: function(lang) {
|
||||
localStorage.lang = lang;
|
||||
if (this.user.preferences) {
|
||||
this.user.preferences.language = lang;
|
||||
this.save_user(function() {
|
||||
window._spacedeck_location_change = true;
|
||||
location.href="/spaces";
|
||||
}.bind(this));
|
||||
}
|
||||
this.user.prefs_language = lang;
|
||||
this.save_user(function() {
|
||||
window._spacedeck_location_change = true;
|
||||
location.href="/spaces";
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
save_user: function(on_success) {
|
||||
|
||||
@@ -61,16 +61,16 @@ var SpacedeckBoardArtifacts = {
|
||||
},
|
||||
|
||||
artifact_link: function(a) {
|
||||
if (a.meta && a.meta.link_uri) {
|
||||
return a.meta.link_uri;
|
||||
if (a.link_uri) {
|
||||
return a.link_uri;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
},
|
||||
|
||||
artifact_link_caption: function(a) {
|
||||
if (a.meta && a.meta.link_uri) {
|
||||
var parts = a.meta.link_uri.split("/");
|
||||
if (a.link_uri) {
|
||||
var parts = a.link_uri.split("/");
|
||||
// scheme://domain.foo/...
|
||||
// 0 1 2
|
||||
if (parts.length>2) {
|
||||
@@ -102,11 +102,9 @@ var SpacedeckBoardArtifacts = {
|
||||
if (this.artifact_is_selected(a) && this.editing_artifact_id!=a._id) clzs.push("selected");
|
||||
if (!a._id) clzs.push("creating");
|
||||
|
||||
if (a.style) {
|
||||
clzs.push("align-"+a.style.align);
|
||||
clzs.push("align-"+a.style.valign);
|
||||
}
|
||||
|
||||
if (a.align) clzs.push("align-"+a.align);
|
||||
if (a.valign) clzs.push("align-"+a.valign);
|
||||
|
||||
clzs.push("state-"+a.state);
|
||||
|
||||
if (this.artifact_is_text_blank(a)) {
|
||||
@@ -123,56 +121,56 @@ var SpacedeckBoardArtifacts = {
|
||||
artifact_inner_style: function(a) {
|
||||
var styles = [];
|
||||
|
||||
if (a.style) {
|
||||
//if (a.style) {
|
||||
|
||||
var svg_style = ((a.mime.match("vector") || a.mime.match("shape")) && a.style.shape!="square");
|
||||
var svg_style = ((a.mime.match("vector") || a.mime.match("shape")) && a.shape!="square");
|
||||
|
||||
if (!svg_style) {
|
||||
if (a.style.stroke) {
|
||||
styles.push("border-width:"+a.style.stroke+"px");
|
||||
styles.push("border-style:"+(a.style.stroke_style||"solid"));
|
||||
if (a.stroke) {
|
||||
styles.push("border-width:"+a.stroke+"px");
|
||||
styles.push("border-style:"+(a.stroke_style||"solid"));
|
||||
}
|
||||
if (a.style.stroke_color) {
|
||||
styles.push("border-color:"+a.style.stroke_color);
|
||||
if (a.stroke_color) {
|
||||
styles.push("border-color:"+a.stroke_color);
|
||||
}
|
||||
if (a.style.border_radius) {
|
||||
styles.push("border-radius:"+a.style.border_radius+"px");
|
||||
if (a.border_radius) {
|
||||
styles.push("border-radius:"+a.border_radius+"px");
|
||||
}
|
||||
}
|
||||
|
||||
if (a.style.fill_color && !svg_style) {
|
||||
styles.push("background-color:"+a.style.fill_color);
|
||||
if (a.fill_color && !svg_style) {
|
||||
styles.push("background-color:"+a.fill_color);
|
||||
}
|
||||
if (a.style.text_color) {
|
||||
styles.push("color:"+a.style.text_color);
|
||||
if (a.text_color) {
|
||||
styles.push("color:"+a.text_color);
|
||||
}
|
||||
|
||||
var filters = [];
|
||||
|
||||
if (!isNaN(a.style.brightness) && a.style.brightness != 100) {
|
||||
filters.push("brightness("+a.style.brightness+"%)");
|
||||
if (!isNaN(a.brightness) && a.brightness != 100) {
|
||||
filters.push("brightness("+a.brightness+"%)");
|
||||
}
|
||||
if (!isNaN(a.style.contrast) && a.style.contrast != 100) {
|
||||
filters.push("contrast("+a.style.contrast+"%)");
|
||||
if (!isNaN(a.contrast) && a.contrast != 100) {
|
||||
filters.push("contrast("+a.contrast+"%)");
|
||||
}
|
||||
if (!isNaN(a.style.opacity) && a.style.opacity != 100) {
|
||||
filters.push("opacity("+a.style.opacity+"%)");
|
||||
if (!isNaN(a.opacity) && a.opacity != 100) {
|
||||
filters.push("opacity("+a.opacity+"%)");
|
||||
}
|
||||
if (!isNaN(a.style.hue) && a.style.hue) {
|
||||
filters.push("hue-rotate("+a.style.hue+"deg)");
|
||||
if (!isNaN(a.hue) && a.hue) {
|
||||
filters.push("hue-rotate("+a.hue+"deg)");
|
||||
}
|
||||
if (!isNaN(a.style.saturation) && a.style.saturation != 100) {
|
||||
filters.push("saturate("+a.style.saturation+"%)");
|
||||
if (!isNaN(a.saturation) && a.saturation != 100) {
|
||||
filters.push("saturate("+a.saturation+"%)");
|
||||
}
|
||||
if (!isNaN(a.style.blur) && a.style.blur) {
|
||||
filters.push("blur("+a.style.blur+"px)");
|
||||
if (!isNaN(a.blur) && a.blur) {
|
||||
filters.push("blur("+a.blur+"px)");
|
||||
}
|
||||
|
||||
if (filters.length) {
|
||||
styles.push("-webkit-filter:"+filters.join(" "));
|
||||
styles.push("filter:"+filters.join(" "));
|
||||
}
|
||||
}
|
||||
//}
|
||||
|
||||
return styles.join(";");
|
||||
},
|
||||
@@ -180,12 +178,10 @@ var SpacedeckBoardArtifacts = {
|
||||
artifact_text_cell_style: function(a, for_text_editor) {
|
||||
var styles = [];
|
||||
|
||||
if (a.style) {
|
||||
if (a.style.padding_left) styles.push("padding-left:"+a.style.padding_left+"px");
|
||||
if (a.style.padding_right) styles.push("padding-right:"+a.style.padding_right+"px");
|
||||
if (a.style.padding_top) styles.push("padding-top:"+a.style.padding_top+"px");
|
||||
if (a.style.padding_bottom) styles.push("padding-bottom:"+a.style.padding_bottom+"px");
|
||||
}
|
||||
if (a.padding_left) styles.push("padding-left:"+a.padding_left+"px");
|
||||
if (a.padding_right) styles.push("padding-right:"+a.padding_right+"px");
|
||||
if (a.padding_top) styles.push("padding-top:"+a.padding_top+"px");
|
||||
if (a.padding_bottom) styles.push("padding-bottom:"+a.padding_bottom+"px");
|
||||
|
||||
return styles.join(";");
|
||||
},
|
||||
@@ -194,26 +190,22 @@ var SpacedeckBoardArtifacts = {
|
||||
var styles = [];
|
||||
var z = 0;
|
||||
|
||||
if (a.board) {
|
||||
z = a.board.z;
|
||||
if (z<0) z=0; // fix negative z-index
|
||||
|
||||
styles = [
|
||||
"left:" +a.board.x+"px",
|
||||
"top:" +a.board.y+"px",
|
||||
"width:" +a.board.w+"px",
|
||||
"height:"+a.board.h+"px",
|
||||
"z-index:"+z
|
||||
];
|
||||
}
|
||||
|
||||
if (a.style) {
|
||||
if (a.style.margin_left) styles.push("margin-left:"+a.style.margin_left+"px");
|
||||
if (a.style.margin_right) styles.push("margin-right:"+a.style.margin_right+"px");
|
||||
if (a.style.margin_top) styles.push("margin-top:"+a.style.margin_top+"px");
|
||||
if (a.style.margin_bottom) styles.push("margin-bottom:"+a.style.margin_bottom+"px");
|
||||
}
|
||||
z = a.z;
|
||||
if (z<0) z=0; // fix negative z-index
|
||||
|
||||
styles = [
|
||||
"left:" +a.x+"px",
|
||||
"top:" +a.y+"px",
|
||||
"width:" +a.w+"px",
|
||||
"height:"+a.h+"px",
|
||||
"z-index:"+z
|
||||
];
|
||||
|
||||
if (a.margin_left) styles.push("margin-left:"+a.margin_left+"px");
|
||||
if (a.margin_right) styles.push("margin-right:"+a.margin_right+"px");
|
||||
if (a.margin_top) styles.push("margin-top:"+a.margin_top+"px");
|
||||
if (a.margin_bottom) styles.push("margin-bottom:"+a.margin_bottom+"px");
|
||||
|
||||
// FIXME: via class logic?
|
||||
if (a.mime.match("vector")) {
|
||||
styles.push("overflow:visible");
|
||||
@@ -241,7 +233,7 @@ var SpacedeckBoardArtifacts = {
|
||||
|
||||
artifact_thumbnail_uri: function(a) {
|
||||
if (a.payload_thumbnail_big_uri && a.board) {
|
||||
if (a.board.w>800) {
|
||||
if (a.w>800) {
|
||||
return a.payload_thumbnail_big_uri;
|
||||
}
|
||||
}
|
||||
@@ -255,35 +247,35 @@ var SpacedeckBoardArtifacts = {
|
||||
var type = parts[0];
|
||||
var provider = parts[1];
|
||||
|
||||
if (!a.meta || !a.meta.link_uri) {
|
||||
if (!a.link_uri) {
|
||||
console.log("missing meta / link_uri: ",a);
|
||||
console.log("type/provider: ",type,provider);
|
||||
return ("missing metadata: "+a._id);
|
||||
}
|
||||
|
||||
if (provider=="youtube") {
|
||||
var vid = a.meta.link_uri.match(/(v=|\/)([a-zA-Z0-9\-_]{11})/);
|
||||
var vid = a.link_uri.match(/(v=|\/)([a-zA-Z0-9\-_]{11})/);
|
||||
if (vid && vid.length>2) {
|
||||
var uri = "https://youtube.com/embed/"+vid[2];
|
||||
return "<iframe frameborder=0 allowfullscreen src=\""+uri+"?showinfo=0&rel=0&controls=0\"></iframe>";
|
||||
} else return "Can't resolve: "+a.payload_uri;
|
||||
|
||||
} else if (provider=="dailymotion") {
|
||||
var match = a.meta.link_uri.match(/dailymotion.com\/video\/([^<]*)/);
|
||||
var match = a.link_uri.match(/dailymotion.com\/video\/([^<]*)/);
|
||||
if (match && match.length>1) {
|
||||
var uri = "https://www.dailymotion.com/embed/video/"+match[1];
|
||||
return "<iframe frameborder=0 allowfullscreen src=\""+uri+"\"></iframe>";
|
||||
} else return "Can't resolve: "+a.payload_uri;
|
||||
|
||||
} else if (provider=="vimeo") {
|
||||
var match = a.meta.link_uri.match(/https?:\/\/(www\.)?vimeo.com\/(\d+)($|\/)/);
|
||||
var match = a.link_uri.match(/https?:\/\/(www\.)?vimeo.com\/(\d+)($|\/)/);
|
||||
if (match) {
|
||||
var uri = "https://player.vimeo.com/video/"+match[2];
|
||||
return "<iframe frameborder=0 allowfullscreen src=\""+uri+"\"></iframe>";
|
||||
} else return "Can't resolve: "+a.payload_uri;
|
||||
|
||||
} else if (provider=="soundcloud") {
|
||||
return '<iframe width="100%" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url='+a.meta.link_uri.replace(":", "%3A")+'"></iframe>';
|
||||
return '<iframe width="100%" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url='+a.link_uri.replace(":", "%3A")+'"></iframe>';
|
||||
|
||||
} else if (provider=="spacedeck") {
|
||||
|
||||
@@ -299,8 +291,8 @@ var SpacedeckBoardArtifacts = {
|
||||
|
||||
if (mtype != "vector" && mtype != "shape") return "";
|
||||
|
||||
var shape = a.style.shape || "";
|
||||
var padding = 32 + a.style.stroke*2;
|
||||
var shape = a.shape || "";
|
||||
var padding = 32 + a.stroke*2;
|
||||
var path_svg;
|
||||
var fill = "";
|
||||
|
||||
@@ -310,13 +302,13 @@ var SpacedeckBoardArtifacts = {
|
||||
fill = "fill:none";
|
||||
} else {
|
||||
path_svg = render_vector_shape(a, padding);
|
||||
fill = "fill:"+a.style.fill_color+";";
|
||||
fill = "fill:"+a.fill_color+";";
|
||||
padding = 0;
|
||||
}
|
||||
var margin = padding;
|
||||
|
||||
var svg = "<svg xmlns='http://www.w3.org/2000/svg' width='"+(a.board.w+2*padding)+"' height='"+(a.board.h+2*padding)+"' ";
|
||||
svg += "style='margin-left:"+(-margin)+"px;margin-top:"+(-margin)+"px;stroke-width:"+a.style.stroke+";stroke:"+a.style.stroke_color+";"+fill+"'>";
|
||||
var svg = "<svg xmlns='http://www.w3.org/2000/svg' width='"+(a.w+2*padding)+"' height='"+(a.h+2*padding)+"' ";
|
||||
svg += "style='margin-left:"+(-margin)+"px;margin-top:"+(-margin)+"px;stroke-width:"+a.stroke+";stroke:"+a.stroke_color+";"+fill+"'>";
|
||||
svg += path_svg;
|
||||
svg += "</svg>";
|
||||
|
||||
@@ -329,10 +321,10 @@ var SpacedeckBoardArtifacts = {
|
||||
if (arts.length==0) return null;
|
||||
|
||||
r = {
|
||||
x1: parseInt(_.min(arts.map(function(a){return a.board.x}))),
|
||||
y1: parseInt(_.min(arts.map(function(a){return a.board.y}))),
|
||||
x2: parseInt(_.max(arts.map(function(a){return a.board.x+a.board.w}))),
|
||||
y2: parseInt(_.max(arts.map(function(a){return a.board.y+a.board.h})))
|
||||
x1: parseInt(_.min(arts.map(function(a){return a.x}))),
|
||||
y1: parseInt(_.min(arts.map(function(a){return a.y}))),
|
||||
x2: parseInt(_.max(arts.map(function(a){return a.x+a.w}))),
|
||||
y2: parseInt(_.max(arts.map(function(a){return a.y+a.h})))
|
||||
};
|
||||
r.x=r.x1;
|
||||
r.y=r.y1;
|
||||
@@ -356,7 +348,7 @@ var SpacedeckBoardArtifacts = {
|
||||
|
||||
artifacts_in_rect: function(rect) {
|
||||
return _.filter(this.active_space_artifacts, function(a) {
|
||||
return this.rects_intersecting(a.board, rect);
|
||||
return this.rects_intersecting(a, rect);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
@@ -366,15 +358,15 @@ var SpacedeckBoardArtifacts = {
|
||||
var rect = this.artifact_selection_rect();
|
||||
var overlapping = _.filter(this.artifacts_in_rect(rect), function(a){return !this.is_selected(a)}.bind(this));
|
||||
|
||||
var max_z = _.max(overlapping,function(a){ return a.board.z; });
|
||||
var max_z = _.max(overlapping,function(a){ return a.z; });
|
||||
if (max_z.board) {
|
||||
max_z = max_z.board.z + 1;
|
||||
max_z = max_z.z + 1;
|
||||
} else {
|
||||
max_z = 1;
|
||||
}
|
||||
|
||||
this.update_selected_artifacts(function(a) {
|
||||
return { board: _.extend(a.board, { z: max_z }) };
|
||||
return { z: max_z };
|
||||
});
|
||||
},
|
||||
|
||||
@@ -384,15 +376,15 @@ var SpacedeckBoardArtifacts = {
|
||||
var rect = this.artifact_selection_rect();
|
||||
var overlapping = _.filter(this.artifacts_in_rect(rect), function(a){return !this.is_selected(a);}.bind(this));
|
||||
|
||||
var min_z = _.min(overlapping,function(a){ return (a.board?a.board.z:0); });
|
||||
var min_z = _.min(overlapping,function(a){ return a.z; });
|
||||
if (min_z.board) {
|
||||
min_z = min_z.board.z - 1;
|
||||
min_z = min_z.z - 1;
|
||||
} else {
|
||||
min_z = 0;
|
||||
}
|
||||
var my_z = _.max(this.selected_artifacts(),function(a){ (a.board?a.board.z:0); });
|
||||
var my_z = _.max(this.selected_artifacts(),function(a){ return a.z; });
|
||||
if (my_z.board) {
|
||||
my_z = my_z.board.z - 1;
|
||||
my_z = my_z.z - 1;
|
||||
} else {
|
||||
my_z = 0;
|
||||
}
|
||||
@@ -400,14 +392,14 @@ var SpacedeckBoardArtifacts = {
|
||||
// TODO: move all other items up in this case?
|
||||
if (min_z < 0) {
|
||||
this.update_artifacts(overlapping, function(a) {
|
||||
return { board: _.extend(a.board, { z: (my_z + (a.board?a.board.z:0) + 1) }) };
|
||||
return { z: (my_z + a.z + 1) };
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.update_selected_artifacts(function(a) {
|
||||
return { board: _.extend(a.board, { z: min_z }) };
|
||||
return { z: min_z };
|
||||
});
|
||||
},
|
||||
|
||||
@@ -416,7 +408,7 @@ var SpacedeckBoardArtifacts = {
|
||||
|
||||
var rect = this.artifact_selection_rect();
|
||||
this.update_selected_artifacts(function(a) {
|
||||
return { board: _.extend(a.board, { x: rect.x1 }) };
|
||||
return { x: rect.x1 };
|
||||
});
|
||||
},
|
||||
|
||||
@@ -425,7 +417,7 @@ var SpacedeckBoardArtifacts = {
|
||||
|
||||
var rect = this.artifact_selection_rect();
|
||||
this.update_selected_artifacts(function(a) {
|
||||
return { board: _.extend(a.board, { y: rect.y1 }) };
|
||||
return { y: rect.y1 };
|
||||
});
|
||||
},
|
||||
|
||||
@@ -434,7 +426,7 @@ var SpacedeckBoardArtifacts = {
|
||||
|
||||
var rect = this.artifact_selection_rect();
|
||||
this.update_selected_artifacts(function(a) {
|
||||
return { board: _.extend(a.board, { x: rect.x2 - a.board.w }) };
|
||||
return { x: rect.x2 - a.w };
|
||||
});
|
||||
},
|
||||
|
||||
@@ -443,7 +435,7 @@ var SpacedeckBoardArtifacts = {
|
||||
|
||||
var rect = this.artifact_selection_rect();
|
||||
this.update_selected_artifacts(function(a) {
|
||||
return { board: _.extend(a.board, { y: rect.y2 - a.board.h }) };
|
||||
return { y: rect.y2 - a.h };
|
||||
});
|
||||
},
|
||||
|
||||
@@ -453,7 +445,7 @@ var SpacedeckBoardArtifacts = {
|
||||
var rect = this.artifact_selection_rect();
|
||||
var cx = rect.x1 + (rect.x2-rect.x1)/2;
|
||||
this.update_selected_artifacts(function(a) {
|
||||
return { board: _.extend(a.board, { x: cx - a.board.w/2 }) };
|
||||
return { x: cx - a.w/2 };
|
||||
});
|
||||
},
|
||||
|
||||
@@ -463,7 +455,7 @@ var SpacedeckBoardArtifacts = {
|
||||
var rect = this.artifact_selection_rect();
|
||||
var cy = rect.y1 + (rect.y2-rect.y1)/2;
|
||||
this.update_selected_artifacts(function(a) {
|
||||
return { board: _.extend(a.board, { y: cy - a.board.h/2 }) };
|
||||
return { y: cy - a.h/2 };
|
||||
});
|
||||
},
|
||||
|
||||
@@ -473,11 +465,11 @@ var SpacedeckBoardArtifacts = {
|
||||
var arts = this.selected_artifacts();
|
||||
if (arts.length<2) return;
|
||||
|
||||
var totalw = _.reduce(arts, function(sum, a) { return sum + a.board.w }, 0);
|
||||
var totalw = _.reduce(arts, function(sum, a) { return sum + a.w }, 0);
|
||||
var avgw = totalw / arts.length;
|
||||
|
||||
this.update_selected_artifacts(function(a) {
|
||||
return { board: _.extend(a.board, { w: avgw }) };
|
||||
return { w: avgw };
|
||||
});
|
||||
},
|
||||
|
||||
@@ -487,11 +479,11 @@ var SpacedeckBoardArtifacts = {
|
||||
var arts = this.selected_artifacts();
|
||||
if (arts.length<2) return;
|
||||
|
||||
var totalh = _.reduce(arts, function(sum, a) { return sum + a.board.h }, 0);
|
||||
var totalh = _.reduce(arts, function(sum, a) { return sum + a.h }, 0);
|
||||
var avgh = totalh / arts.length;
|
||||
|
||||
this.update_selected_artifacts(function(a) {
|
||||
return { board: _.extend(a.board, { h: avgh }) };
|
||||
return { h: avgh };
|
||||
});
|
||||
},
|
||||
|
||||
@@ -506,16 +498,16 @@ var SpacedeckBoardArtifacts = {
|
||||
var selected = this.selected_artifacts();
|
||||
if (selected.length<3) return;
|
||||
|
||||
var sorted = _.sortBy(selected, function(a) { return a.board.x });
|
||||
var startx = sorted[0].board.x + sorted[0].board.w/2;
|
||||
var stopx = _.last(sorted).board.x + _.last(sorted).board.w/2;
|
||||
var sorted = _.sortBy(selected, function(a) { return a.x });
|
||||
var startx = sorted[0].x + sorted[0].w/2;
|
||||
var stopx = _.last(sorted).x + _.last(sorted).w/2;
|
||||
var step = (stopx-startx)/(sorted.length-1);
|
||||
|
||||
for (var i=1; i<sorted.length-1; i++) {
|
||||
var a = sorted[i];
|
||||
var x = startx + step*i - a.board.w/2;
|
||||
var x = startx + step*i - a.w/2;
|
||||
this.update_artifacts([a],function(a) {
|
||||
return { board: _.extend(a.board, {x: x}) }
|
||||
return { x: x }
|
||||
});
|
||||
}
|
||||
},
|
||||
@@ -526,16 +518,16 @@ var SpacedeckBoardArtifacts = {
|
||||
var selected = this.selected_artifacts();
|
||||
if (selected.length<3) return;
|
||||
|
||||
var sorted = _.sortBy(selected, function(a) { return a.board.y });
|
||||
var starty = sorted[0].board.y + sorted[0].board.h/2;
|
||||
var stopy = _.last(sorted).board.y + _.last(sorted).board.h/2;
|
||||
var sorted = _.sortBy(selected, function(a) { return a.y });
|
||||
var starty = sorted[0].y + sorted[0].h/2;
|
||||
var stopy = _.last(sorted).y + _.last(sorted).h/2;
|
||||
var step = (stopy-starty)/(sorted.length-1);
|
||||
|
||||
for (var i=1; i<sorted.length-1; i++) {
|
||||
var a = sorted[i];
|
||||
var y = starty + step*i - a.board.h/2;
|
||||
var y = starty + step*i - a.h/2;
|
||||
this.update_artifacts([a],function(a) {
|
||||
return { board: _.extend(a.board, {y: y}) }
|
||||
return { y: y }
|
||||
});
|
||||
}
|
||||
},
|
||||
@@ -546,21 +538,21 @@ var SpacedeckBoardArtifacts = {
|
||||
var selected = this.selected_artifacts();
|
||||
if (selected.length<3) return;
|
||||
|
||||
var sorted = _.sortBy(selected, function(a) { return a.board.x });
|
||||
var startx = sorted[0].board.x;
|
||||
var stopx = _.last(sorted).board.x + _.last(sorted).board.w;
|
||||
var sorted = _.sortBy(selected, function(a) { return a.x });
|
||||
var startx = sorted[0].x;
|
||||
var stopx = _.last(sorted).x + _.last(sorted).w;
|
||||
var range = stopx - startx;
|
||||
var totalw = _.reduce(sorted, function(sum, a) { return sum + a.board.w }, 0);
|
||||
var totalw = _.reduce(sorted, function(sum, a) { return sum + a.w }, 0);
|
||||
var avgs = (range - totalw) / (sorted.length-1);
|
||||
var prevend = startx + sorted[0].board.w;
|
||||
var prevend = startx + sorted[0].w;
|
||||
|
||||
for (var i=1; i<sorted.length-1; i++) {
|
||||
var a = sorted[i];
|
||||
var x = prevend + avgs;
|
||||
this.update_artifacts([a],function(a) {
|
||||
return { board: _.extend(a.board, {x: x}) }
|
||||
return { x: x }
|
||||
});
|
||||
prevend = x+a.board.w;
|
||||
prevend = x+a.w;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -570,21 +562,21 @@ var SpacedeckBoardArtifacts = {
|
||||
var selected = this.selected_artifacts();
|
||||
if (selected.length<3) return;
|
||||
|
||||
var sorted = _.sortBy(selected, function(a) { return a.board.y });
|
||||
var starty = sorted[0].board.y;
|
||||
var stopy = _.last(sorted).board.y + _.last(sorted).board.h;
|
||||
var sorted = _.sortBy(selected, function(a) { return a.y });
|
||||
var starty = sorted[0].y;
|
||||
var stopy = _.last(sorted).y + _.last(sorted).h;
|
||||
var range = stopy - starty;
|
||||
var totalh = _.reduce(sorted, function(sum, a) { return sum + a.board.h }, 0);
|
||||
var totalh = _.reduce(sorted, function(sum, a) { return sum + a.h }, 0);
|
||||
var avgs = (range - totalh) / (sorted.length-1);
|
||||
var prevend = starty + sorted[0].board.h;
|
||||
var prevend = starty + sorted[0].h;
|
||||
|
||||
for (var i=1; i<sorted.length-1; i++) {
|
||||
var a = sorted[i];
|
||||
var y = prevend + avgs;
|
||||
this.update_artifacts([a],function(a) {
|
||||
return { board: _.extend(a.board, {y: y}) }
|
||||
return { y: y }
|
||||
});
|
||||
prevend = y+a.board.h;
|
||||
prevend = y+a.h;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -594,20 +586,20 @@ var SpacedeckBoardArtifacts = {
|
||||
var selected = this.selected_artifacts();
|
||||
if (selected.length<2) return;
|
||||
|
||||
var sorted = _.sortBy(selected, function(a) { return a.board.x+a.board.y*this.active_space.advanced.width }.bind(this));
|
||||
var sorted = _.sortBy(selected, function(a) { return a.x+a.y*this.active_space.advanced.width }.bind(this));
|
||||
|
||||
var minx = sorted[0].board.x;
|
||||
var miny = sorted[0].board.y;
|
||||
var minx = sorted[0].x;
|
||||
var miny = sorted[0].y;
|
||||
|
||||
var sorted = _.sortBy(selected, function(a) { return -Math.max(a.board.w,a.board.h) }.bind(this));
|
||||
var sorted = _.sortBy(selected, function(a) { return -Math.max(a.w,a.h) }.bind(this));
|
||||
|
||||
var blocks = [];
|
||||
|
||||
for (var i=0; i<sorted.length; i++) {
|
||||
var a = sorted[i];
|
||||
blocks.push({
|
||||
w: a.board.w,
|
||||
h: a.board.h,
|
||||
w: a.w,
|
||||
h: a.h,
|
||||
a: a
|
||||
});
|
||||
}
|
||||
@@ -620,10 +612,10 @@ var SpacedeckBoardArtifacts = {
|
||||
if (block.fit) {
|
||||
var a = block.a;
|
||||
this.update_artifacts([a],function(a) {
|
||||
return { board: _.extend(a.board, {
|
||||
return {
|
||||
x: minx+block.fit.x,
|
||||
y: miny+block.fit.y
|
||||
}) }
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,8 +369,8 @@ var SpacedeckSections = {
|
||||
// canvas
|
||||
this.$watch('active_style.background_color', function (value, mutation) {
|
||||
|
||||
if (this.active_style.background_color != this.active_space.advanced.background_color) {
|
||||
this.$set("active_space.advanced.background_color",this.active_style.background_color);
|
||||
if (this.active_style.background_color != this.active_space.background_color) {
|
||||
this.$set("active_space.background_color",this.active_style.background_color);
|
||||
this.throttled_save_active_space();
|
||||
}
|
||||
|
||||
@@ -448,7 +448,7 @@ var SpacedeckSections = {
|
||||
|
||||
for (var i=0; i<props.length; i++) {
|
||||
var prop = props[i];
|
||||
this.active_style[prop]=a.style[prop];
|
||||
this.active_style[prop]=a[prop];
|
||||
}
|
||||
|
||||
// defaults
|
||||
@@ -457,10 +457,10 @@ var SpacedeckSections = {
|
||||
this.active_style.line_height = this.default_style.line_height;
|
||||
this.active_style.letter_spacing = this.default_style.letter_spacing;
|
||||
|
||||
this.active_style.padding_top = a.style.padding_top || 0;
|
||||
this.active_style.padding_bottom = a.style.padding_bottom || 0;
|
||||
this.active_style.padding_left = a.style.padding_left || 0;
|
||||
this.active_style.padding_right = a.style.padding_right || 0;
|
||||
this.active_style.padding_top = a.padding_top || 0;
|
||||
this.active_style.padding_bottom = a.padding_bottom || 0;
|
||||
this.active_style.padding_left = a.padding_left || 0;
|
||||
this.active_style.padding_right = a.padding_right || 0;
|
||||
|
||||
if (this.active_style.padding_top == this.active_style.padding_bottom) {
|
||||
this.active_style.padding_vert = this.active_style.padding_top;
|
||||
@@ -476,10 +476,10 @@ var SpacedeckSections = {
|
||||
this.active_style.padding = this.active_style.padding_top;
|
||||
}
|
||||
|
||||
this.active_style.margin_top = a.style.margin_top || 0;
|
||||
this.active_style.margin_bottom = a.style.margin_bottom || 0;
|
||||
this.active_style.margin_left = a.style.margin_left || 0;
|
||||
this.active_style.margin_right = a.style.margin_right || 0;
|
||||
this.active_style.margin_top = a.margin_top || 0;
|
||||
this.active_style.margin_bottom = a.margin_bottom || 0;
|
||||
this.active_style.margin_left = a.margin_left || 0;
|
||||
this.active_style.margin_right = a.margin_right || 0;
|
||||
|
||||
if (this.active_style.margin_top == this.active_style.margin_bottom) {
|
||||
this.active_style.margin_vert = this.active_style.margin_top;
|
||||
@@ -758,8 +758,8 @@ var SpacedeckSections = {
|
||||
},
|
||||
|
||||
resize_minimap: function() {
|
||||
if (!this.active_space || !this.active_space.advanced) return;
|
||||
this.minimap_scale = this.active_space.advanced.width/100.0;
|
||||
if (!this.active_space) return;
|
||||
this.minimap_scale = this.active_space.width/100.0;
|
||||
},
|
||||
|
||||
handle_minimap_mouseup: function(evt) {
|
||||
@@ -921,7 +921,7 @@ var SpacedeckSections = {
|
||||
|
||||
discover_zones: function() {
|
||||
this.zones = _.sortBy(_.filter(this.active_space_artifacts, function(a) { return (a.mime=="x-spacedeck/zone") }),
|
||||
function(z){return z.style.order});
|
||||
function(z){return z.order});
|
||||
},
|
||||
|
||||
artifact_plaintext: function(a) {
|
||||
@@ -1015,10 +1015,10 @@ var SpacedeckSections = {
|
||||
arts = _.filter(arts); // remove any nulls
|
||||
|
||||
return {
|
||||
x1: parseInt(_.min(arts.map(function(a){return ((!a.board || !a.board.x)?0:a.board.x)}))),
|
||||
y1: parseInt(_.min(arts.map(function(a){return ((!a.board || !a.board.y)?0:a.board.y)}))),
|
||||
x2: parseInt(_.max(arts.map(function(a){return (!a.board?0:a.board.x+a.board.w)}))),
|
||||
y2: parseInt(_.max(arts.map(function(a){return (!a.board?0:a.board.y+a.board.h)})))
|
||||
x1: parseInt(_.min(arts.map(function(a){return ((!a || !a.x)?0:a.x)}))),
|
||||
y1: parseInt(_.min(arts.map(function(a){return ((!a || !a.y)?0:a.y)}))),
|
||||
x2: parseInt(_.max(arts.map(function(a){return (!a?0:a.x+a.w)}))),
|
||||
y2: parseInt(_.max(arts.map(function(a){return (!a?0:a.y+a.h)})))
|
||||
};
|
||||
},
|
||||
|
||||
@@ -1076,7 +1076,7 @@ var SpacedeckSections = {
|
||||
this.selection_metrics.count=arts.length;
|
||||
this.selection_metrics.scribble_selection = false;
|
||||
if (arts.length == 1 && arts[0].mime == "x-spacedeck/vector") {
|
||||
if (arts[0].style.shape == "scribble") {
|
||||
if (arts[0].shape == "scribble") {
|
||||
this.selection_metrics.scribble_selection = true;
|
||||
}
|
||||
this.selection_metrics.vector_points = arts[0].control_points;
|
||||
@@ -1112,8 +1112,8 @@ var SpacedeckSections = {
|
||||
fixup_space_size: function() {
|
||||
if (!this.active_space) return;
|
||||
|
||||
this.active_space.advanced.width =Math.max(this.active_space.advanced.width, window.innerWidth);
|
||||
this.active_space.advanced.height=Math.max(this.active_space.advanced.height, window.innerHeight);
|
||||
this.active_space.width =Math.max(this.active_space.width, window.innerWidth);
|
||||
this.active_space.height=Math.max(this.active_space.height, window.innerHeight);
|
||||
},
|
||||
|
||||
end_transaction: function() {
|
||||
@@ -1125,13 +1125,13 @@ var SpacedeckSections = {
|
||||
var er = this.enclosing_rect(this.active_space_artifacts);
|
||||
if (!er) return;
|
||||
|
||||
this.active_space.advanced.width =Math.max(er.x2+100, window.innerWidth);
|
||||
this.active_space.advanced.height=Math.max(er.y2+100, window.innerHeight);
|
||||
this.active_space.width =Math.max(er.x2+100, window.innerWidth);
|
||||
this.active_space.height=Math.max(er.y2+100, window.innerHeight);
|
||||
|
||||
if (this._last_bounds_width != this.active_space.advanced.width ||
|
||||
this._last_bounds_height != this.active_space.advanced.height) {
|
||||
this._last_bounds_width = this.active_space.advanced.width;
|
||||
this._last_bounds_height = this.active_space.advanced.height;
|
||||
if (this._last_bounds_width != this.active_space.width ||
|
||||
this._last_bounds_height != this.active_space.height) {
|
||||
this._last_bounds_width = this.active_space.width;
|
||||
this._last_bounds_height = this.active_space.height;
|
||||
|
||||
save_space(this.active_space);
|
||||
}
|
||||
@@ -1214,7 +1214,7 @@ var SpacedeckSections = {
|
||||
|
||||
// this is a bit hacky, but might be the smartest place to do it
|
||||
if (a.view && a.view.vector_svg) {
|
||||
a.style.shape_svg = a.view.vector_svg;
|
||||
a.shape_svg = a.view.vector_svg;
|
||||
}
|
||||
|
||||
window.artifact_save_queue[a._id] = a;
|
||||
@@ -1329,7 +1329,7 @@ var SpacedeckSections = {
|
||||
this.update_selected_artifacts(function(a) {
|
||||
var c = {};
|
||||
|
||||
if (c[prop] != val) {
|
||||
if (a[prop] != val) {
|
||||
//console.log("set_artifact_prop: ",c,val);
|
||||
c[prop]=val;
|
||||
return c;
|
||||
@@ -1343,11 +1343,11 @@ var SpacedeckSections = {
|
||||
this.begin_transaction();
|
||||
|
||||
this.update_selected_artifacts(function(a) {
|
||||
var c = {style: a.style||{}};
|
||||
|
||||
if (c.style[prop] != val) {
|
||||
var c = {};
|
||||
|
||||
if (a[prop] != val) {
|
||||
//console.log("set_artifact_style_prop: ",c,val);
|
||||
c.style[prop]=val;
|
||||
c[prop]=val;
|
||||
return c;
|
||||
}
|
||||
|
||||
@@ -1419,7 +1419,7 @@ var SpacedeckSections = {
|
||||
if (this.selected_artifacts().length!=1 && this.opened_dialog!="background") return;
|
||||
|
||||
if (this.opened_dialog=="background") {
|
||||
this.active_style[this.color_picker_target] = this.active_space.advanced.background_color;
|
||||
this.active_style[this.color_picker_target] = this.active_space.background_color;
|
||||
} else {
|
||||
if (!this.active_style[this.color_picker_target]) {
|
||||
this.active_style[this.color_picker_target] = this.default_style[this.color_picker_target];
|
||||
@@ -1478,10 +1478,8 @@ var SpacedeckSections = {
|
||||
|
||||
this.update_selected_artifacts(function(a) {
|
||||
return {
|
||||
board: _.extend(a.board, {
|
||||
x: a.board.x+dx,
|
||||
y: a.board.y+dy
|
||||
})
|
||||
x: a.x+dx,
|
||||
y: a.y+dy
|
||||
};
|
||||
});
|
||||
},
|
||||
@@ -1489,7 +1487,7 @@ var SpacedeckSections = {
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
highest_z: function() {
|
||||
var z = _.max(this.active_space_artifacts.map(function(a){return a.board.z||0}));
|
||||
var z = _.max(this.active_space_artifacts.map(function(a){return a.z||0}));
|
||||
if (z<0) z=0;
|
||||
if (z>999) z=999;
|
||||
return z;
|
||||
@@ -1574,20 +1572,18 @@ var SpacedeckSections = {
|
||||
payload_thumbnail_web_uri: url || null,
|
||||
space_id: space._id,
|
||||
|
||||
style: {
|
||||
order: this.active_space_artifacts.length+1,
|
||||
valign: "middle",
|
||||
align: "center"
|
||||
//fill_color: "#f8f8f8"
|
||||
}
|
||||
order: this.active_space_artifacts.length+1,
|
||||
valign: "middle",
|
||||
align: "center"
|
||||
//fill_color: "#f8f8f8"
|
||||
};
|
||||
|
||||
if (mimes[item_type] == "text/html") {
|
||||
new_item.style.padding_left = 10;
|
||||
new_item.style.padding_top = 10;
|
||||
new_item.style.padding_right = 10;
|
||||
new_item.style.padding_bottom = 10;
|
||||
new_item.style.fill_color = "rgba(255,255,255,1)";
|
||||
new_item.padding_left = 10;
|
||||
new_item.padding_top = 10;
|
||||
new_item.padding_right = 10;
|
||||
new_item.padding_bottom = 10;
|
||||
new_item.fill_color = "rgba(255,255,255,1)";
|
||||
new_item.description = "<p>Text</p>";
|
||||
}
|
||||
|
||||
@@ -1600,13 +1596,11 @@ var SpacedeckSections = {
|
||||
z = point.z;
|
||||
}
|
||||
|
||||
new_item.board = {
|
||||
x: parseInt(point.x),
|
||||
y: parseInt(point.y),
|
||||
w: w,
|
||||
h: h,
|
||||
z: z
|
||||
};
|
||||
new_item.x = parseInt(point.x);
|
||||
new_item.y = parseInt(point.y);
|
||||
new_item.z = z;
|
||||
new_item.w = w;
|
||||
new_item.h = h;
|
||||
|
||||
if (this.guest_nickname) {
|
||||
new_item.editor_name = this.guest_nickname;
|
||||
@@ -1665,7 +1659,7 @@ var SpacedeckSections = {
|
||||
for (var i=0; i<new_zones.length; i++) {
|
||||
if (new_zones[i]) {
|
||||
if (!new_zones[i].style) new_zones[i].style = {};
|
||||
new_zones[i].style.order = i;
|
||||
new_zones[i].order = i;
|
||||
save_artifact(new_zones[i]);
|
||||
}
|
||||
}
|
||||
@@ -1679,7 +1673,7 @@ var SpacedeckSections = {
|
||||
for (var i=0; i<new_zones.length; i++) {
|
||||
if (new_zones[i]) {
|
||||
if (!new_zones[i].style) new_zones[i].style = {};
|
||||
new_zones[i].style.order = i;
|
||||
new_zones[i].order = i;
|
||||
save_artifact(new_zones[i]);
|
||||
}
|
||||
}
|
||||
@@ -1695,17 +1689,13 @@ var SpacedeckSections = {
|
||||
space_id: this.active_space._id,
|
||||
mime: "x-spacedeck/zone",
|
||||
description: "Zone "+(this.zones.length+1),
|
||||
board: {
|
||||
x: point.x,
|
||||
y: point.y,
|
||||
w: w,
|
||||
h: h,
|
||||
z: 0
|
||||
},
|
||||
style: {
|
||||
valign: "middle",
|
||||
align: "center"
|
||||
}
|
||||
x: point.x,
|
||||
y: point.y,
|
||||
w: w,
|
||||
h: h,
|
||||
z: 0,
|
||||
valign: "middle",
|
||||
align: "center"
|
||||
};
|
||||
|
||||
if (this.guest_nickname) {
|
||||
@@ -1735,22 +1725,18 @@ var SpacedeckSections = {
|
||||
space_id: this.active_space._id,
|
||||
mime: "x-spacedeck/shape",
|
||||
description: "Text",
|
||||
board: {
|
||||
x: point.x,
|
||||
y: point.y,
|
||||
z: point.z,
|
||||
w: w,
|
||||
h: h
|
||||
},
|
||||
style: {
|
||||
stroke_color: "#ffffff",
|
||||
text_color: "#ffffff",
|
||||
stroke: 0,
|
||||
fill_color: "#000000",
|
||||
shape: shape_type,
|
||||
valign: "middle",
|
||||
align: "center"
|
||||
}
|
||||
x: point.x,
|
||||
y: point.y,
|
||||
z: point.z,
|
||||
w: w,
|
||||
h: h,
|
||||
stroke_color: "#ffffff",
|
||||
text_color: "#ffffff",
|
||||
stroke: 0,
|
||||
fill_color: "#000000",
|
||||
shape: shape_type,
|
||||
valign: "middle",
|
||||
align: "center"
|
||||
};
|
||||
|
||||
if (this.guest_nickname) {
|
||||
@@ -1829,17 +1815,13 @@ var SpacedeckSections = {
|
||||
state: "uploading",
|
||||
payload_thumbnail_medium_uri: null,
|
||||
payload_thumbnail_web_uri: null,
|
||||
board: {
|
||||
x: point.x,
|
||||
y: point.y,
|
||||
w: w,
|
||||
h: h,
|
||||
z: point.z
|
||||
},
|
||||
style: {
|
||||
order: this.active_space_artifacts.length+1,
|
||||
fill_color: fill
|
||||
}
|
||||
x: point.x,
|
||||
y: point.y,
|
||||
w: w,
|
||||
h: h,
|
||||
z: point.z,
|
||||
order: this.active_space_artifacts.length+1,
|
||||
fill_color: fill
|
||||
}
|
||||
|
||||
this.update_board_artifact_viewmodel(a);
|
||||
@@ -1864,7 +1846,11 @@ var SpacedeckSections = {
|
||||
a.payload_thumbnail_big_uri = updated_a.payload_thumbnail_big_uri;
|
||||
a.payload_alternatives = updated_a.payload_alternatives;
|
||||
a.mime = updated_a.mime;
|
||||
a.board = updated_a.board;
|
||||
a.x = updated_a.x;
|
||||
a.y = updated_a.y;
|
||||
a.w = updated_a.w;
|
||||
a.h = updated_a.h;
|
||||
a.z = updated_a.z;
|
||||
a.state = updated_a.state;
|
||||
this.update_board_artifact_viewmodel(a);
|
||||
|
||||
@@ -2002,26 +1988,26 @@ var SpacedeckSections = {
|
||||
clear_formatting_walk: function(el,cmd,arg1,arg2) {
|
||||
if (el && el.style) {
|
||||
if (cmd == "preciseFontSize") {
|
||||
el.style.fontSize = null;
|
||||
el.fontSize = null;
|
||||
} else if (cmd == "letterSpacing") {
|
||||
el.style.letterSpacing = null;
|
||||
el.letterSpacing = null;
|
||||
} else if (cmd == "lineHeight") {
|
||||
el.style.lineHeight = null;
|
||||
el.lineHeight = null;
|
||||
} else if (cmd == "fontName") {
|
||||
el.style.fontFamily = null;
|
||||
el.fontFamily = null;
|
||||
} else if (cmd == "fontWeight") {
|
||||
el.style.fontWeight = null;
|
||||
el.style.fontStyle = null;
|
||||
el.fontWeight = null;
|
||||
el.fontStyle = null;
|
||||
} else if (cmd == "bold") {
|
||||
el.style.fontWeight = null;
|
||||
el.fontWeight = null;
|
||||
} else if (cmd == "italic") {
|
||||
el.style.fontStyle = null;
|
||||
el.fontStyle = null;
|
||||
} else if (cmd == "underline") {
|
||||
el.style.textDecoration = null;
|
||||
el.textDecoration = null;
|
||||
} else if (cmd == "strikeThrough") {
|
||||
el.style.textDecoration = null;
|
||||
el.textDecoration = null;
|
||||
} else if (cmd == "forecolor") {
|
||||
el.style.color = null;
|
||||
el.color = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2108,6 +2094,9 @@ var SpacedeckSections = {
|
||||
|
||||
if (a.description!=dom.innerHTML) {
|
||||
a.description = dom.innerHTML;
|
||||
|
||||
console.log("new DOM:",dom.innerHTML);
|
||||
|
||||
this.update_board_artifact_viewmodel(a);
|
||||
this.queue_artifact_for_save(a);
|
||||
|
||||
@@ -2141,10 +2130,7 @@ var SpacedeckSections = {
|
||||
|
||||
remove_link_from_selected_artifacts: function() {
|
||||
this.update_selected_artifacts(function(a) {
|
||||
var meta = a.meta || {};
|
||||
delete meta.link_uri;
|
||||
|
||||
return {meta: meta};
|
||||
return {link_uri: ""};
|
||||
});
|
||||
},
|
||||
|
||||
@@ -2160,9 +2146,7 @@ var SpacedeckSections = {
|
||||
var insert_link_url = prompt("URL:",def);
|
||||
|
||||
this.update_selected_artifacts(function(a) {
|
||||
var meta = a.meta || {};
|
||||
meta.link_uri = insert_link_url;
|
||||
var update = {meta: meta};
|
||||
var update = {link_uri: insert_link_url};
|
||||
|
||||
if (a.payload_uri && a.payload_uri.match("webgrabber")) {
|
||||
var enc_uri = encodeURIComponent(btoa(insert_link_url));
|
||||
@@ -2185,11 +2169,10 @@ var SpacedeckSections = {
|
||||
delete copy["$index"];
|
||||
delete copy["_id"];
|
||||
|
||||
if (dx) copy.board.x += dx;
|
||||
if (dy) copy.board.y += dy;
|
||||
if (dx) copy.x += dx;
|
||||
if (dy) copy.y += dy;
|
||||
|
||||
if (!copy.style) copy.style = {};
|
||||
copy.style.order = this.active_space_artifacts.length+1;
|
||||
copy.order = this.active_space_artifacts.length+1;
|
||||
|
||||
if (this.guest_nickname) {
|
||||
copy.editor_name = this.guest_nickname;
|
||||
@@ -2334,16 +2317,16 @@ var SpacedeckSections = {
|
||||
if (parsed[i].mime) {
|
||||
var z = this.highest_z()+1;
|
||||
if (parsed.length==1) {
|
||||
var w = parsed[i].board.w;
|
||||
var h = parsed[i].board.h;
|
||||
var w = parsed[i].w;
|
||||
var h = parsed[i].h;
|
||||
var point = this.find_place_for_item(w,h);
|
||||
parsed[i].board.x = point.x;
|
||||
parsed[i].board.y = point.y;
|
||||
parsed[i].board.z = point.z;
|
||||
parsed[i].x = point.x;
|
||||
parsed[i].y = point.y;
|
||||
parsed[i].z = point.z;
|
||||
} else {
|
||||
parsed[i].board.x = parsed[i].board.x+50;
|
||||
parsed[i].board.y = parsed[i].board.y+50;
|
||||
parsed[i].board.y = parsed[i].board.z+z;
|
||||
parsed[i].x = parsed[i].x+50;
|
||||
parsed[i].y = parsed[i].y+50;
|
||||
parsed[i].y = parsed[i].z+z;
|
||||
}
|
||||
this.clone_artifact(parsed[i], 0,0, function(a) {
|
||||
this.multi_select([a]);
|
||||
@@ -2373,13 +2356,11 @@ var SpacedeckSections = {
|
||||
var h = 300;
|
||||
var point = this.find_place_for_item(w,h);
|
||||
|
||||
new_item.board = {
|
||||
x: point.x,
|
||||
y: point.y,
|
||||
w: w,
|
||||
h: h,
|
||||
z: point.z
|
||||
};
|
||||
new_item.x = point.x;
|
||||
new_item.y = point.y;
|
||||
new_item.w = w;
|
||||
new_item.h = h;
|
||||
new_item.z = point.z;
|
||||
|
||||
if (this.guest_nickname) {
|
||||
new_item.editor_name = this.guest_nickname;
|
||||
@@ -2402,16 +2383,12 @@ var SpacedeckSections = {
|
||||
mime: "image/png",
|
||||
description: url,
|
||||
state: "uploading",
|
||||
board: {
|
||||
x: point.x,
|
||||
y: point.y,
|
||||
w: 200,
|
||||
h: 200,
|
||||
z: z
|
||||
},
|
||||
style: {
|
||||
order: this.active_space_artifacts.length
|
||||
}
|
||||
x: point.x,
|
||||
y: point.y,
|
||||
w: 200,
|
||||
h: 200,
|
||||
z: z,
|
||||
order: this.active_space_artifacts.length
|
||||
}
|
||||
|
||||
var metadata = parse_link(url)
|
||||
@@ -2473,16 +2450,12 @@ var SpacedeckSections = {
|
||||
payload_thumbnail_medium_uri: metadata.thumbnail_url,
|
||||
payload_thumbnail_web_uri: metadata.thumbnail_url,
|
||||
state: "idle",
|
||||
meta: {
|
||||
title: metadata.title,
|
||||
link_uri: metadata.url || url
|
||||
},
|
||||
board: {
|
||||
x: point.x - w/2,
|
||||
y: point.y - h/2,
|
||||
w: w,
|
||||
h: h
|
||||
}
|
||||
title: metadata.title,
|
||||
link_uri: metadata.url || url,
|
||||
x: point.x - w/2,
|
||||
y: point.y - h/2,
|
||||
w: w,
|
||||
h: h
|
||||
});
|
||||
|
||||
if (this.guest_nickname) {
|
||||
@@ -2591,7 +2564,7 @@ var SpacedeckSections = {
|
||||
},
|
||||
|
||||
remove_section_background: function() {
|
||||
this.active_space.advanced.background_uri = null;
|
||||
this.active_space.background_uri = null;
|
||||
save_space(this.active_space);
|
||||
},
|
||||
|
||||
@@ -2652,8 +2625,8 @@ var SpacedeckSections = {
|
||||
|
||||
this.bounds_zoom = this.viewport_zoom;
|
||||
|
||||
var eff_w = this.active_space.advanced.width*this.viewport_zoom;
|
||||
var eff_h = this.active_space.advanced.height*this.viewport_zoom;
|
||||
var eff_w = this.active_space.width*this.viewport_zoom;
|
||||
var eff_h = this.active_space.height*this.viewport_zoom;
|
||||
|
||||
if (window.innerWidth>eff_w) {
|
||||
// horizontal centering
|
||||
@@ -2846,8 +2819,8 @@ var SpacedeckSections = {
|
||||
|
||||
var el = $("#space")[0];
|
||||
|
||||
var eff_w = this.active_space.advanced.width*this.viewport_zoom;
|
||||
var eff_h = this.active_space.advanced.height*this.viewport_zoom;
|
||||
var eff_w = this.active_space.width*this.viewport_zoom;
|
||||
var eff_h = this.active_space.height*this.viewport_zoom;
|
||||
|
||||
var sx = el.scrollLeft;
|
||||
var sy = el.scrollTop;
|
||||
@@ -2980,9 +2953,9 @@ var SpacedeckSections = {
|
||||
|
||||
var w = 300;
|
||||
var h = 200;
|
||||
if (parsed.board && parsed.board.w && parsed.board.h) {
|
||||
w = parsed.board.w;
|
||||
h = parsed.board.h;
|
||||
if (parsed.board && parsed.w && parsed.h) {
|
||||
w = parsed.w;
|
||||
h = parsed.h;
|
||||
}
|
||||
|
||||
var point = this.cursor_point_to_space(evt);
|
||||
|
||||
@@ -283,9 +283,9 @@ var SpacedeckSpaces = {
|
||||
|
||||
this.discover_zones();
|
||||
|
||||
window.setTimeout(function() {
|
||||
this.zoom_to_fit();
|
||||
}.bind(this),10);
|
||||
//window.setTimeout(function() {
|
||||
// this.zoom_to_fit();
|
||||
//}.bind(this),10);
|
||||
|
||||
if (on_success) {
|
||||
on_success();
|
||||
|
||||
@@ -331,7 +331,7 @@ function setup_whiteboard_directives() {
|
||||
var $scope = this.vm.$root;
|
||||
|
||||
return _.filter($scope.active_space_artifacts, function(a) {
|
||||
return this.rects_intersecting(a.board, rect);
|
||||
return this.rects_intersecting(a, rect);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
@@ -439,15 +439,15 @@ function setup_whiteboard_directives() {
|
||||
|
||||
dists = $scope.unselected_artifacts().map(function(a){
|
||||
|
||||
var r = this.rect_to_points(a.board);
|
||||
var r = this.rect_to_points(a);
|
||||
|
||||
var xd1 = Math.abs(r[0].x-x);
|
||||
var xd2 = Math.abs(r[1].x-x);
|
||||
var xd3 = Math.abs(r[0].x+a.board.w/2 - x);
|
||||
var xd3 = Math.abs(r[0].x+a.w/2 - x);
|
||||
|
||||
var yd1 = Math.abs(r[0].y-y);
|
||||
var yd2 = Math.abs(r[2].y-y);
|
||||
var yd3 = Math.abs(r[0].y+a.board.h/2 - y);
|
||||
var yd3 = Math.abs(r[0].y+a.h/2 - y);
|
||||
|
||||
if (!snap_middle) {
|
||||
if (xd2<xd1) {
|
||||
@@ -469,10 +469,10 @@ function setup_whiteboard_directives() {
|
||||
|
||||
if (snap_middle) {
|
||||
var xd = xd3;
|
||||
var sx = r[0].x+a.board.w/2;
|
||||
var sx = r[0].x+a.w/2;
|
||||
|
||||
var yd = yd3;
|
||||
var sy = r[0].y+a.board.h/2;
|
||||
var sy = r[0].y+a.h/2;
|
||||
}
|
||||
|
||||
return [[xd,sx],[yd,sy]];
|
||||
@@ -531,18 +531,14 @@ function setup_whiteboard_directives() {
|
||||
mime: "x-spacedeck/vector",
|
||||
description: "",
|
||||
control_points: [{dx:0,dy:0}],
|
||||
board: {
|
||||
x: point.x,
|
||||
y: point.y,
|
||||
z: z,
|
||||
w: 64,
|
||||
h: 64
|
||||
},
|
||||
style: {
|
||||
stroke_color: "#000000",
|
||||
stroke: 2,
|
||||
shape: "scribble"
|
||||
}
|
||||
x: point.x,
|
||||
y: point.y,
|
||||
z: z,
|
||||
w: 64,
|
||||
h: 64,
|
||||
stroke_color: "#000000",
|
||||
stroke: 2,
|
||||
shape: "scribble"
|
||||
};
|
||||
|
||||
$scope.save_artifact(a, function(saved_a) {
|
||||
@@ -572,18 +568,14 @@ function setup_whiteboard_directives() {
|
||||
mime: "x-spacedeck/vector",
|
||||
description: "",
|
||||
control_points: [{dx:0,dy:0},{dx:0,dy:0},{dx:0,dy:0}],
|
||||
board: {
|
||||
x: point.x,
|
||||
y: point.y,
|
||||
z: z,
|
||||
w: 64,
|
||||
h: 64
|
||||
},
|
||||
style: {
|
||||
stroke_color: "#000000",
|
||||
stroke: 2,
|
||||
shape: "arrow"
|
||||
}
|
||||
x: point.x,
|
||||
y: point.y,
|
||||
z: z,
|
||||
w: 64,
|
||||
h: 64,
|
||||
stroke_color: "#000000",
|
||||
stroke: 2,
|
||||
shape: "arrow"
|
||||
};
|
||||
|
||||
$scope.save_artifact(a, function(saved_a) {
|
||||
@@ -612,18 +604,14 @@ function setup_whiteboard_directives() {
|
||||
mime: "x-spacedeck/vector",
|
||||
description: "",
|
||||
control_points: [{dx:0,dy:0},{dx:0,dy:0}],
|
||||
board: {
|
||||
x: point.x,
|
||||
y: point.y,
|
||||
z: z,
|
||||
w: 64,
|
||||
h: 64
|
||||
},
|
||||
style: {
|
||||
stroke_color: "#000000",
|
||||
stroke: 2,
|
||||
shape: "line"
|
||||
}
|
||||
x: point.x,
|
||||
y: point.y,
|
||||
z: z,
|
||||
w: 64,
|
||||
h: 64,
|
||||
stroke_color: "#000000",
|
||||
stroke: 2,
|
||||
shape: "line"
|
||||
};
|
||||
|
||||
$scope.save_artifact(a, function(saved_a) {
|
||||
@@ -675,11 +663,11 @@ function setup_whiteboard_directives() {
|
||||
|
||||
if (_.include(["text","placeholder"],$scope.artifact_major_type(ars[i]))) {
|
||||
// some types of artifact need a minimum size
|
||||
if (ars[i].board.w<10) {
|
||||
ars[i].board.w = 10;
|
||||
if (ars[i].w<10) {
|
||||
ars[i].w = 10;
|
||||
}
|
||||
if (ars[i].board.h<10) {
|
||||
ars[i].board.h = 10;
|
||||
if (ars[i].h<10) {
|
||||
ars[i].h = 10;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -827,10 +815,8 @@ function setup_whiteboard_directives() {
|
||||
|
||||
if (old_a) {
|
||||
return {
|
||||
board: _.extend(a.board, {
|
||||
x: old_a.board.x + dx - snap_dx,
|
||||
y: old_a.board.y + dy - snap_dy
|
||||
})
|
||||
x: old_a.x + dx - snap_dx,
|
||||
y: old_a.y + dy - snap_dy
|
||||
};
|
||||
} else {
|
||||
// deleted?
|
||||
@@ -865,26 +851,24 @@ function setup_whiteboard_directives() {
|
||||
|
||||
var scale_x = lead_x ? (moved_x)/lead_x : 1;
|
||||
var scale_y = lead_y ? (moved_y)/lead_y : 1;
|
||||
if ($scope.transform_lock) scale_y = scale_x;
|
||||
if (!$scope.transform_lock) scale_y = scale_x;
|
||||
|
||||
$scope.update_selected_artifacts(function(a) {
|
||||
var old_a = $scope.find_artifact_before_transaction(a);
|
||||
|
||||
var x1 = origin_x + ((old_a.board.x - origin_x) * scale_x);
|
||||
var y1 = origin_y + ((old_a.board.y - origin_y) * scale_y);
|
||||
var x2 = origin_x + (((old_a.board.x + old_a.board.w) - origin_x) * scale_x);
|
||||
var y2 = origin_y + (((old_a.board.y + old_a.board.h) - origin_y) * scale_y);
|
||||
var x1 = origin_x + ((old_a.x - origin_x) * scale_x);
|
||||
var y1 = origin_y + ((old_a.y - origin_y) * scale_y);
|
||||
var x2 = origin_x + (((old_a.x + old_a.w) - origin_x) * scale_x);
|
||||
var y2 = origin_y + (((old_a.y + old_a.h) - origin_y) * scale_y);
|
||||
|
||||
if (x1>x2) { var t = x1; x1 = x2; x2 = t; }
|
||||
if (y1>y2) { var t = y1; y1 = y2; y2 = t; }
|
||||
|
||||
return {
|
||||
board: _.extend(a.board, {
|
||||
x: x1,
|
||||
y: y1,
|
||||
w: x2 - x1,
|
||||
h: y2 - y1
|
||||
})
|
||||
x: x1,
|
||||
y: y1,
|
||||
w: x2 - x1,
|
||||
h: y2 - y1
|
||||
};
|
||||
}.bind(this));
|
||||
|
||||
@@ -902,18 +886,17 @@ function setup_whiteboard_directives() {
|
||||
var old_a = $scope.find_artifact_before_transaction(a);
|
||||
|
||||
var control_points = _.cloneDeep(old_a.control_points);
|
||||
var board = _.clone(old_a.board);
|
||||
var cp = control_points[$scope.selected_control_point_idx];
|
||||
|
||||
var snapped = _this.snap_point(board.x+cp.dx+dx, board.y+cp.dy+dy);
|
||||
dx = snapped.snapx[1]-(board.x+cp.dx);
|
||||
dy = snapped.snapy[1]-(board.y+cp.dy);
|
||||
var snapped = _this.snap_point(old_a.x+cp.dx+dx, old_a.y+cp.dy+dy);
|
||||
dx = snapped.snapx[1]-(old_a.x+cp.dx);
|
||||
dy = snapped.snapy[1]-(old_a.y+cp.dy);
|
||||
|
||||
cp.dx += dx;
|
||||
cp.dy += dy;
|
||||
|
||||
// special case for arrow's 3rd point
|
||||
if (a.style.shape == "arrow" && $scope.selected_control_point_idx!=2) {
|
||||
if (a.shape == "arrow" && $scope.selected_control_point_idx!=2) {
|
||||
/*control_points[2].dx += dx/2;
|
||||
control_points[2].dy += dy/2; */
|
||||
|
||||
@@ -921,7 +904,7 @@ function setup_whiteboard_directives() {
|
||||
control_points[2].dy = (control_points[0].dy+control_points[1].dy)/2;
|
||||
}
|
||||
|
||||
return _this.normalize_control_points(control_points, board);
|
||||
return _this.normalize_control_points(control_points, old_a);
|
||||
});
|
||||
|
||||
} else if (this.mouse_state == "scribble") {
|
||||
@@ -930,16 +913,14 @@ function setup_whiteboard_directives() {
|
||||
var old_a = a;
|
||||
|
||||
var control_points = _.cloneDeep(old_a.control_points);
|
||||
var board = _.clone(old_a.board);
|
||||
|
||||
var offset = this.offset_point_in_wrapper({x:cursor.x,y:cursor.y});
|
||||
|
||||
control_points.push({
|
||||
dx: offset.x-board.x,
|
||||
dy: offset.y-board.y
|
||||
dx: offset.x-old_a.x,
|
||||
dy: offset.y-old_a.y
|
||||
});
|
||||
|
||||
return this.normalize_control_points(simplify_scribble_points(control_points), board);
|
||||
return this.normalize_control_points(simplify_scribble_points(control_points), old_a);
|
||||
}.bind(this));
|
||||
|
||||
var arts = $scope.selected_artifacts();
|
||||
@@ -959,7 +940,7 @@ function setup_whiteboard_directives() {
|
||||
}
|
||||
},
|
||||
|
||||
normalize_control_points: function(control_points, board) {
|
||||
normalize_control_points: function(control_points, artifact) {
|
||||
var x1 = _.min(control_points,"dx").dx;
|
||||
var y1 = _.min(control_points,"dy").dy;
|
||||
var x2 = _.max(control_points,"dx").dx;
|
||||
@@ -981,19 +962,15 @@ function setup_whiteboard_directives() {
|
||||
var bshiftx = 0;
|
||||
var bshifty = 0;
|
||||
|
||||
if (board.w < 0) bshiftx = -board.w;
|
||||
if (board.h < 0) bshifty = -board.h;
|
||||
|
||||
var shifted_board = {
|
||||
x: board.x + bshiftx - shiftx,
|
||||
y: board.y + bshifty - shifty,
|
||||
w: w,
|
||||
h: h,
|
||||
z: board.z
|
||||
};
|
||||
if (artifact.w < 0) bshiftx = -artifact.w;
|
||||
if (artifact.h < 0) bshifty = -artifact.h;
|
||||
|
||||
return {
|
||||
board: shifted_board,
|
||||
x: artifact.x + bshiftx - shiftx,
|
||||
y: artifact.y + bshifty - shifty,
|
||||
w: w,
|
||||
h: h,
|
||||
z: artifact.z,
|
||||
control_points: shifted_cps
|
||||
};
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ function vec2_angle(v) {
|
||||
}
|
||||
|
||||
function render_vector_drawing(a, padding) {
|
||||
var shape = a.style.shape || "";
|
||||
var shape = a.shape || "";
|
||||
var path = [];
|
||||
var p = a.control_points[0];
|
||||
|
||||
@@ -48,8 +48,8 @@ function render_vector_drawing(a, padding) {
|
||||
|
||||
var d = "M" + (cps.dx + padding) + "," + (cps.dy + padding) + " Q" + (scaledMiddlePoint.dx + padding) + "," + (scaledMiddlePoint.dy + padding) + " " + (cpe.dx + padding) + "," + (cpe.dy + padding);
|
||||
var tip = "<defs><marker id='ae" + markerId + "' refX=\"0.1\" refY=\"3\" markerWidth=\"3\" markerHeight=\"6\" orient=\"auto\">";
|
||||
tip += "<path d=\"M-3,0 V6 L3,3 Z\" fill=\""+a.style.stroke_color+"\" stroke-width=\"0\"/></marker></defs>";
|
||||
var svg = tip + "<path d='" + d + "' style='stroke-width:" + a.style.stroke + ";' marker-end='url(#ae" + markerId + ")'/>";
|
||||
tip += "<path d=\"M-3,0 V6 L3,3 Z\" fill=\""+a.stroke_color+"\" stroke-width=\"0\"/></marker></defs>";
|
||||
var svg = tip + "<path d='" + d + "' style='stroke-width:" + a.stroke + ";' marker-end='url(#ae" + markerId + ")'/>";
|
||||
|
||||
return svg;
|
||||
}
|
||||
@@ -237,11 +237,11 @@ function render_vector_rect(xradius,yradius,offset) {
|
||||
}
|
||||
|
||||
function render_vector_shape(a) {
|
||||
var stroke = parseInt(a.style.stroke) + 4;
|
||||
var stroke = parseInt(a.stroke) + 4;
|
||||
var offset = stroke / 2;
|
||||
|
||||
var xr = (a.board.w-stroke) / 2;
|
||||
var yr = (a.board.h-stroke) / 2;
|
||||
var xr = (a.w-stroke) / 2;
|
||||
var yr = (a.h-stroke) / 2;
|
||||
|
||||
var shape_renderers = {
|
||||
ellipse: function() { return render_vector_ellipse(xr, yr, offset); },
|
||||
@@ -258,7 +258,7 @@ function render_vector_shape(a) {
|
||||
cloud: function() { return render_vector_cloud(xr, yr, offset); },
|
||||
}
|
||||
|
||||
var render_func = shape_renderers[a.style.shape];
|
||||
var render_func = shape_renderers[a.shape];
|
||||
|
||||
if (!render_func) return "";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user