mirror of
https://github.com/wassname/HackFlowy.git
synced 2026-07-01 16:40:05 +08:00
Rev Control- polishing , visual BugFixes
This commit is contained in:
+2
-2
@@ -49,8 +49,8 @@ module.exports = {
|
||||
socket.emit("commitReceived");
|
||||
});
|
||||
|
||||
socket.on("revHistoryRequest", function(){
|
||||
getAndSendRevHistory(null, socket);
|
||||
socket.on("revHistoryRequest", function(subRootId){
|
||||
getAndSendRevHistory(subRootId, socket);
|
||||
});
|
||||
|
||||
//socket.emit('news', {hello: "world"});
|
||||
|
||||
+3
-3
@@ -3,16 +3,16 @@ var MySnap = require('../models/Snap.js').MySnap
|
||||
module.exports.getAndSendRevHistory = getAndSendRevHistory;
|
||||
|
||||
|
||||
function getAndSendRevHistory(rootId, sock){
|
||||
function getAndSendRevHistory(subRootId, sock){
|
||||
globalList = [];
|
||||
snapHash = {};
|
||||
timeHash = {};
|
||||
depth = 0;
|
||||
socket = sock;
|
||||
|
||||
var rootId = "53ea3f506dc8d39342bf4f9f";
|
||||
// subRootId = "53f10817cb52c1e31cf45d94";
|
||||
// FetchSelfAndChildrenBack(rootId, asyncLoopGetChildren);
|
||||
asyncLoopGetChildren([rootId]);
|
||||
asyncLoopGetChildren([subRootId]);
|
||||
}
|
||||
|
||||
//This is all the backSnaps for ONE rootId.
|
||||
|
||||
+8
-2
@@ -1,13 +1,16 @@
|
||||
$(function(){
|
||||
//alert("jquery works");
|
||||
var myRouter;
|
||||
|
||||
|
||||
$("#COMMIT").click(function(){
|
||||
socket.emit("COMMIT");
|
||||
});
|
||||
|
||||
$(".getRevHistory").click(function(){
|
||||
socket.emit("revHistoryRequest");
|
||||
$(".getRevHistory").click(function(e){
|
||||
var rootId = $(".root").attr("data-id")
|
||||
socket.emit("revHistoryRequest", rootId);
|
||||
$(e.target).attr("data-id", rootId);
|
||||
});
|
||||
|
||||
$(".toggleSidebar").click(function(){
|
||||
@@ -291,6 +294,9 @@ if((vo.hitTab && !event.shiftKey) || (event.keyCode == 39 && event.shiftKey)){ /
|
||||
if(hasAboveSibling){
|
||||
var newIndex = vo.siblingModel.get("children").length; // no need for a + 1, because 0 index + insert (duh)
|
||||
moveNode(vo.thisModel, vo.thisIndex, vo.parentModel, vo.siblingModel, newIndex, true);
|
||||
setTimeout(function(){
|
||||
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
if((vo.hitTab && event.shiftKey) || (event.keyCode == 37 && event.shiftKey)){// OUTDENT!!
|
||||
|
||||
@@ -11,7 +11,8 @@ renderRevControl = function(rootNode, timeStamp){
|
||||
}
|
||||
console.log("FINALCOLLECTION");
|
||||
console.log(finalCollection);
|
||||
nodesCollection = new NodesCollection(finalCollection);
|
||||
var snapCollection = new NodesCollection(finalCollection);
|
||||
return snapCollection;
|
||||
|
||||
}
|
||||
|
||||
|
||||
+26
-23
@@ -62,17 +62,19 @@
|
||||
$("#revTimestamps").html(list);
|
||||
})
|
||||
|
||||
|
||||
$("#revTimestamps").on("click", "a.timestamp", function(event){
|
||||
// debugger;
|
||||
var a = event.target;
|
||||
var timestamp = parseInt($(a).html());
|
||||
renderRevControl("53ea3f506dc8d39342bf4f9f", timestamp);
|
||||
setTimeout(function(){
|
||||
// debugger;
|
||||
console.log("nodesCollection")
|
||||
console.log(nodesCollection);
|
||||
that.viewRoot("53ea3f506dc8d39342bf4f9f")
|
||||
}, 1000);
|
||||
var subRootId = $(".getRevHistory").attr("data-id");
|
||||
|
||||
var snapCollection = renderRevControl(subRootId, timestamp);
|
||||
|
||||
console.log("snapCollection")
|
||||
console.log(snapCollection);
|
||||
|
||||
that.viewRoot(subRootId, snapCollection);
|
||||
});
|
||||
|
||||
socket.on('edit', function(data){
|
||||
@@ -189,27 +191,28 @@
|
||||
|
||||
},
|
||||
|
||||
viewRoot: function(id){
|
||||
var rootNode = nodesCollection.findWhere({_id: id});
|
||||
if(!rootNode){
|
||||
rootNode = nodesCollection.findWhere({cur_id: id});
|
||||
viewRoot: function(id, snapCollection){
|
||||
|
||||
var rootModel;
|
||||
var metaCollection;
|
||||
var snapView = 0;
|
||||
if(snapCollection){
|
||||
rootModel = snapCollection.findWhere({cur_id: id});
|
||||
metaCollection = snapCollection
|
||||
snapView = 1;
|
||||
}
|
||||
// alert("viewNode");
|
||||
console.log("ViewRoot + rootNode");
|
||||
console.log(rootNode);
|
||||
else{
|
||||
rootModel = nodesCollection.findWhere({_id: id});
|
||||
metaCollection = nodesCollection;
|
||||
}
|
||||
|
||||
var rootView = new listView({
|
||||
viewWindow: ".main1",
|
||||
model: rootNode,
|
||||
nodesCollection: nodesCollection //nodesCollection might be global (and this would be redundant)
|
||||
model: rootModel,
|
||||
metaCollection: metaCollection,
|
||||
snapView: snapView
|
||||
})
|
||||
this.changeView(rootView);
|
||||
|
||||
// var rootView = new listView({
|
||||
// viewWindow: ".main2",
|
||||
// model: rootNode,
|
||||
// nodesCollection: nodesCollection //nodesCollection might be global (and this would be redundant)
|
||||
// })
|
||||
// this.changeView(rootView);
|
||||
},
|
||||
|
||||
changeView: function(view) {
|
||||
|
||||
@@ -2,6 +2,8 @@ var listView = Backbone.View.extend({
|
||||
|
||||
initialize: function(options){
|
||||
var that = this;
|
||||
that.metaCollection = options["metaCollection"];
|
||||
that.snapView = options["snapView"];
|
||||
|
||||
this.viewWindow = $(options["viewWindow"]);
|
||||
that.model = options["model"];
|
||||
@@ -24,6 +26,15 @@ var listView = Backbone.View.extend({
|
||||
return that;
|
||||
},
|
||||
|
||||
findModel: function(id){
|
||||
if(this.snapView){
|
||||
return this.metaCollection.findWhere({cur_id: id});
|
||||
}
|
||||
else{
|
||||
return this.metaCollection.findWhere({_id: id});
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
renderPath: function(){
|
||||
var that = this;
|
||||
@@ -33,12 +44,12 @@ var listView = Backbone.View.extend({
|
||||
var parents = that.model.get("parents");
|
||||
while(parents.length != 0){
|
||||
ancestry.push(parents);
|
||||
parents = nodesCollection.findWhere({_id: parents[0] }).get("parents");
|
||||
parents = that.findModel(parents[0]).get("parents");
|
||||
//making the assumption/simplification that it's a tree. Not a graph.
|
||||
}
|
||||
|
||||
_.each(ancestry.reverse(), function(parent){
|
||||
var parentModel = nodesCollection.findWhere({_id: parent[0] });
|
||||
var parentModel = that.findModel(parent[0]);
|
||||
pathDiv += "<a class='pathLink' href='#"+ parentModel.get("_id") + "'>" + parentModel.get("text") + "</a>";
|
||||
pathDiv += " -- ";
|
||||
});
|
||||
@@ -54,15 +65,15 @@ var listView = Backbone.View.extend({
|
||||
|
||||
var childrenIds = that.model.get("children");
|
||||
_.each(childrenIds, function(childId, index){
|
||||
var childModel = nodesCollection.findWhere({_id: childId});
|
||||
if(!childModel){childModel= nodesCollection.findWhere({cur_id: childId});}
|
||||
console.log("childModelId = " + childId);
|
||||
console.log(childModel);
|
||||
var childModel = that.findModel(childId);
|
||||
|
||||
var tempView = new showView({
|
||||
depth: 0,
|
||||
model: childModel //,
|
||||
//nodesCollection: that.nodesCollection
|
||||
model: childModel,
|
||||
metaCollection: that.metaCollection,
|
||||
snapView: that.snapView
|
||||
});
|
||||
|
||||
var tempLI = tempView.render().$el;
|
||||
tempLI.children("textarea").textareaAutoExpand();
|
||||
that.$el.append(tempLI);
|
||||
@@ -76,7 +87,9 @@ var listView = Backbone.View.extend({
|
||||
var that = this;
|
||||
var newView = new showView({
|
||||
model: newNode,
|
||||
depth: 0
|
||||
depth: 0,
|
||||
metaCollection: that.metaCollection,
|
||||
snapView: that.snapView
|
||||
});
|
||||
var newLI = newView.render().$el;
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
var showView = Backbone.View.extend({
|
||||
initialize: function(options){
|
||||
var that = this;
|
||||
that.metaCollection = options["metaCollection"];
|
||||
that.snapView = options["snapView"];
|
||||
|
||||
this.model = options["model"];
|
||||
this.depth = options["depth"];
|
||||
@@ -15,6 +17,16 @@ var showView = Backbone.View.extend({
|
||||
events: {"click .markdown" : "showMarkDownEditor"},
|
||||
|
||||
|
||||
findModel: function(id){
|
||||
if(this.snapView){
|
||||
return this.metaCollection.findWhere({cur_id: id});
|
||||
}
|
||||
else{
|
||||
return this.metaCollection.findWhere({_id: id});
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
//todo = refactor this function.
|
||||
render: function(){
|
||||
var that = this;
|
||||
@@ -29,6 +41,10 @@ var showView = Backbone.View.extend({
|
||||
that.$el.attr("data-id", id);
|
||||
|
||||
that.$el.html(html);
|
||||
if(that.snapView){
|
||||
that.$el.children().children("textarea").prop("disabled", true);
|
||||
that.$el.addClass("snapLI");
|
||||
}
|
||||
console.log("about to render textarea")
|
||||
|
||||
that.renderChildren();
|
||||
@@ -40,10 +56,12 @@ var showView = Backbone.View.extend({
|
||||
var childrenIds = that.model.get("children");
|
||||
|
||||
_.each(childrenIds, function(childId, index){
|
||||
var childModel = nodesCollection.findWhere({_id: childId});
|
||||
var childModel = that.findModel(childId);
|
||||
var tempView = new showView({
|
||||
depth: 0,
|
||||
model: childModel
|
||||
depth: that.depth + 1,
|
||||
model: childModel,
|
||||
metaCollection: that.metaCollection,
|
||||
snapView: that.snapView
|
||||
});
|
||||
that.childViews.push(tempView)
|
||||
that.$el.children("ul").append(tempView.render().$el);
|
||||
@@ -115,7 +133,10 @@ var showView = Backbone.View.extend({
|
||||
console.log("addNodeText" + newNode.get("text"))
|
||||
var newView = new showView({
|
||||
model: newNode,
|
||||
depth: that.depth +1
|
||||
depth: that.depth +1,
|
||||
metaCollection: that.metaCollection,
|
||||
snapView: that.snapView
|
||||
|
||||
});
|
||||
|
||||
var newLI = newView.render().$el;
|
||||
@@ -130,7 +151,7 @@ var showView = Backbone.View.extend({
|
||||
|
||||
that.childViews.insert(index , newView);
|
||||
if(cur){
|
||||
newLI.children().children("textarea").focus();
|
||||
newLI.children().children("textarea").focus().textareaAutoExpand();
|
||||
}
|
||||
else{
|
||||
newView.lock();
|
||||
@@ -146,7 +167,7 @@ var showView = Backbone.View.extend({
|
||||
var that = this;
|
||||
this.$el.children().children("textarea").val(that.model.get("text"));
|
||||
},
|
||||
lock: function(){
|
||||
lock: function(){ //for concurrent editing...
|
||||
this.$el.children().children("textarea").attr("readonly", "readonly");
|
||||
this.$el.children().children("textarea").val("editing....")
|
||||
},
|
||||
|
||||
@@ -148,6 +148,12 @@ ul.navbar-right {
|
||||
/**************** Panel ****************/
|
||||
|
||||
/**************** List *****************/
|
||||
|
||||
.snapLI > span > textarea:hover{
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
|
||||
#marked-mathjax-input{
|
||||
border: 2px dotted black;
|
||||
margin-left: 0px;
|
||||
|
||||
Reference in New Issue
Block a user