SEARCH WORKS

This commit is contained in:
Curtis SerVaas
2014-10-16 15:36:16 -04:00
parent 3dabfe79fd
commit 61284b39df
15 changed files with 356 additions and 323 deletions
+1 -1
View File
@@ -63,7 +63,7 @@ function setUpDB(){
MySnap.remove({}, function(err) { console.log('collection removed') });
var curtisId = "53e4079cd7dbc73d16c87c53";
addNode("0root", [], ["123456"], curtisId , "a42a" , function(err, rootNode){
addNode("0root", [], [], curtisId , "a42a" , function(err, rootNode){
console.log("rootNode", rootNode);
addNode("Welcolme!", [], [rootNode._id], curtisId , "b42b", function(err, firstBullet){
rootNode.children = [firstBullet._id]
+13 -63
View File
@@ -10,11 +10,21 @@ $(function(){
setTimeout(function(){
$(".toggleSidebar").click();
}, 2);
vo = {};
});
(function($) {
$.fn.isFirstViz = function(){
return $(this).is($(this).parent().children(":visible:first"));
}
$.fn.isLastViz = function(){
return $(this).is($(this).parent().children(":visible:last"));
}
}(jQuery));
@@ -69,67 +79,7 @@ Array.prototype.removeOne = function(parId){
this.remove(parIndex);
}
voInitializer = function(that, event){
//var that = this;
vo = {};
vo.hitEnter = (event.which == 13);
vo.hitTab = (event.which ==9);
vo.atEnd = ( $(that).getSelection().end == $(that).val().length);
vo.atBeg = ( $(that).getSelection().start == 0);
//cursor = $(this).getSelection().start;
vo.hitBack = (event.which ==8);
vo.empty = ($(that).val().length ==0);
vo.highLighted = !vo.empty && ( $(that).getSelection().end != $(that).getSelection().start )
vo.rootLevel = $(that).closest("ul").is(".root")
vo.lastBullet = ( $(that).closest("li").is(":first-child") && vo.rootLevel);
vo.thisLI = $(event.target).closest("li");
vo.thisId = vo.thisLI.attr("data-id"); //data-id.
vo.thisIndex = vo.thisLI.index(); //returns -1 if there's no match.
vo.thisModel = nodesCollection.findWhere({_id: vo.thisId});
vo.thisView = vo.thisModel.get("views").slice(-1)[0]; //we're assuming a tree.
//(also, I'm not garbage collecting extra views when you zoom in/out, so we have to grab last element).
//alert(thisIndex)
//thisModel = nodesCollection.get(thisId);
vo.siblingLI = vo.thisLI.prev();
vo.siblingIndex = vo.siblingLI.index();
vo.siblingId = vo.siblingLI.attr("data-id");
vo.siblingModel = nodesCollection.findWhere({_id: vo.siblingId});
// console.log(nodesCollection);
// console.log(vo.thisModel);
// if(!editing){
// // alert("editing!");
// socket.emit("editing", [vo.thisId, CurrentUser.google.name]);
// editing=true;
// }
if(vo.rootLevel){
vo.parentLI = undefined;
vo.parentId = (vo.thisLI.closest("ul").attr("data-id"))
vo.grandParentId = undefined; // won't matter since outTab prevents it. //unless programattic.
}
else{ //not root level.
//debugger;
vo.parentLI = vo.thisLI.parent().closest("li");
vo.parentId = (vo.parentLI.attr("data-id"));
if(vo.parentLI.attr("data-depth") == 0){ //could test this another way.
vo.grandParentId = vo.parentLI.closest("ul").attr("data-id");
//console.log("grandParentId" + grandParentId)
}
else{
vo.grandParentId = (vo.parentLI.parent().closest("li").attr('data-id'));
//console.log("grandParentId" + grandParentId)
}
}
vo.grandParentModel = nodesCollection.findWhere({_id: vo.grandParentId});
vo.parentModel = nodesCollection.findWhere({_id: vo.parentId});
vo.cursorHack = false;
} //(vo-initializer)
+14
View File
@@ -1,3 +1,17 @@
var NodeModel = Backbone.Model.extend({
getAncestry: function(){
var that = this;
var ancestry = [];
var parents = that.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.
}
return ancestry;
}
});
+43 -19
View File
@@ -38,32 +38,21 @@ var AppRouter = Backbone.Router.extend({
data.google.id = null;
data.google.token = null;
data.google.email = null;
CurrentUser = data;
// console.log("CURRENT USER");
// console.log(CurrentUser);
CurrentUser = data;
}
},
error: function(data){
console.log("ERROR- AjaxLoginDATA");
}
});//ajax
},
// index: function(otherID){
// var that = this;
// otherID = otherID ||
// },
viewRoot: function(id, snapCollection){
var rootModel;
var metaCollection;
var snapView = 0;
var snapView = 0;
if(snapCollection){
rootModel = snapCollection.findWhere({cur_id: id});
metaCollection = snapCollection
@@ -73,27 +62,62 @@ var AppRouter = Backbone.Router.extend({
rootModel = nodesCollection.findWhere({_id: id});
metaCollection = nodesCollection;
}
var rootView = new listView({
viewWindow: ".main1",
depth: -1,
model: rootModel,
metaCollection: metaCollection,
snapView: snapView
})
$(".main1").html(rootView.render().$el);
this.changeView(rootView);
},
changeView: function(view) {
if ( null != this.currentView ) {
if ( this.currentView != null ) {
this.currentView.undelegateEvents();
}
this.currentView = view;
$("textarea").textareaAutoExpand();
},
viewSearchSubset: function(matchedNodes){
console.log("matchedNodes", matchedNodes);
var SUBSET = matchedNodes
augmentedSet = []
_.each(SUBSET, function(matchedNode){
augmentedSet.push([matchedNode.get("_id")]);
augmentedSet.push(matchedNode.getAncestry());
});
var finalSet = _.union(_.flatten(augmentedSet));
var rootView = new listView({
depth: -1,
model: nodesCollection.findWhere({_id: $('.root').attr('data-id')}),
metaCollection: nodesCollection,
snapView: 0 ,
searchSet: finalSet
})
$(".main1").html(rootView.render().$el);
this.changeView(rootView);
},
setUpSocket: function(){
var that = this;
+4 -95
View File
@@ -1,18 +1,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"];
(that.model.attributes["views"] = this.model.attributes["views"] || []).push(that);
that.$el.attr("data-id", that.model.get("_id"));
this.childViews = [];
this.render();
},
this.UL = this.$el;
assignProperties(this, options);
},
tagName: 'ul',
className: 'root subList dd-list',
@@ -26,27 +16,11 @@ 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;
var pathDiv = "";
var ancestry = [];
var parents = that.model.get("parents");
while(parents.length != 0){
ancestry.push(parents);
parents = that.findModel(parents[0]).get("parents");
//making the assumption/simplification that it's a tree. Not a graph.
}
var ancestry = that.model.getAncestry();
_.each(ancestry.reverse(), function(parent){
var parentModel = that.findModel(parent[0]);
@@ -59,59 +33,6 @@ var listView = Backbone.View.extend({
$("#pathDiv").html(pathDiv);
},
//identical except for the .$el part at the end.
renderChildren: function(){
var that = this;
var childrenIds = that.model.get("children");
_.each(childrenIds, function(childId, index){
var childModel = that.findModel(childId);
var tempView = new showView({
depth: 0,
model: childModel,
metaCollection: that.metaCollection,
snapView: that.snapView
});
var tempLI = tempView.render().$el;
tempLI.children("textarea").textareaAutoExpand();
that.$el.append(tempLI);
that.childViews.push(tempView);
});
that.viewWindow.html(that.$el);
},
//adds a CHILD node.
addNode: function(newNode, index, cur){
var that = this;
var newView = new showView({
model: newNode,
depth: 0,
metaCollection: that.metaCollection,
snapView: that.snapView
});
var newLI = newView.render().$el;
if(index == 0){ //just handles edge case where you're using this for indent
that.$el.prepend(newLI);
}else{
that.$el.children(":nth-child(" + (index) + ")").after(newLI);
}
//that.$el.children(":nth-child(" + (index) + ")").after(newLI);
that.childViews.insert(index , newView);
cur = true;
if(cur){
if(vo.cursorHack){ return newView; }
newLI.children().children("textarea").focus();
}
else{
newView.lock();
}
return newView;
},
updateId: function(newId){
that.$el.attr("data-id", newId);
@@ -128,16 +49,4 @@ var listView = Backbone.View.extend({
unlock: function(){
console.log("ROOT UNLOCKED");
},
removeNode: function(index){
var that = this;
console.log(that.childViews);
that.childViews[index].remove();
that.childViews.remove(index);
},
pushView: function(view){
this.childViews.push(view);
this.$el.children().last().after(view.$el);
}
});
+89
View File
@@ -0,0 +1,89 @@
function assignProperties(object, options){ //object is a showView or listView
var that = object;
that.metaCollection = options["metaCollection"];
that.snapView = options["snapView"];
that.model = options["model"];
that.depth = options["depth"];
(that.model.attributes["views"] = that.model.attributes["views"] || []).push(that);
that.$el.attr("data-id", that.model.get("_id")); //booya!
that.childViews = [];
that.searchSet = options["searchSet"];
object.renderChildren = function(){
var that = object;
var childrenIds = that.model.get("children");
_.each(childrenIds, function(childId, index){
var childModel = that.findModel(childId);
var tempView = new showView({
depth: that.depth + 1,
model: childModel,
metaCollection: that.metaCollection,
snapView: that.snapView,
searchSet: that.searchSet
});
that.pushView(tempView, childId);
});
}
object.pushView = function(tempView, childId){
debugger;
var searchSet= object.searchSet;
that.childViews.push(tempView);
var tempLI = tempView.render().$el
that.UL.append(tempLI);
if(searchSet && !_.contains(searchSet, childId)){
$(tempLI).hide();
}
}
object.findModel = function(id){
if(object.snapView){
return object.metaCollection.findWhere({cur_id: id});
}
else{
return object.metaCollection.findWhere({_id: id});
}
}
object.removeNode = function(index){
var that = this;
that.childViews[index].remove();
that.childViews.remove(index);
}
object.addNode = function(newNode, index, cur){
var that = this;
var newView = new showView({
model: newNode,
depth: that.depth +1,
metaCollection: that.metaCollection,
snapView: that.snapView
});
var newLI = newView.render().$el;
//var empty = (that.$el.children("ul").children().length == 0);
if(index == 0){ //just handles edge case where you're using this for indent
that.UL.prepend(newLI);
}else{
that.UL.children(":nth-child(" + (index) + ")").after(newLI);
}
that.childViews.insert(index , newView);
if(cur){
newLI.children().children("textarea").focus().textareaAutoExpand();
}
else{
newView.lock();
}
return newView;
}
}
+4 -83
View File
@@ -1,31 +1,12 @@
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"];
(that.model.attributes["views"] = this.model.attributes["views"] || []).push(that);
that.$el.attr("data-id", that.model.get("_id")); //booya!
this.childViews = [];
//that.UL;
assignProperties(this, options);
},
tagName: 'li',
className: "herez node",
events: {"click .markdown" : "showMarkDownEditor"},
findModel: function(id){
if(this.snapView){
return this.metaCollection.findWhere({cur_id: id});
}
else{
return this.metaCollection.findWhere({_id: id});
}
},
events: {"click .markdown" : "showMarkDownEditor"},
//todo = refactor this function.
render: function(){
@@ -41,6 +22,7 @@ var showView = Backbone.View.extend({
that.$el.attr("data-id", id);
that.$el.html(html);
that.UL = that.$el.children("ul");
if(that.snapView){
that.$el.children().children("textarea").prop("disabled", true);
that.$el.addClass("snapLI");
@@ -51,27 +33,6 @@ var showView = Backbone.View.extend({
return that;
},
renderChildren: function(){
var that = this;
var childrenIds = that.model.get("children");
_.each(childrenIds, function(childId, index){
var childModel = that.findModel(childId);
var tempView = new showView({
depth: that.depth + 1,
model: childModel,
metaCollection: that.metaCollection,
snapView: that.snapView
});
that.childViews.push(tempView)
that.$el.children("ul").append(tempView.render().$el);
});
},
unhide: function(){
alert("bleh");
},
// Moved to app.js to handle bubbling issues.
collapse: function(){
@@ -128,37 +89,6 @@ var showView = Backbone.View.extend({
// setTimeout(function(){ MathJax.Callback(["CreatePreview",Preview]); }, 300);
},
addNode: function(newNode, index, cur){
var that = this;
console.log("addNodeText" + newNode.get("text"))
var newView = new showView({
model: newNode,
depth: that.depth +1,
metaCollection: that.metaCollection,
snapView: that.snapView
});
var newLI = newView.render().$el;
//var empty = (that.$el.children("ul").children().length == 0);
if(index == 0){ //just handles edge case where you're using this for indent
that.$el.children("ul").prepend(newLI);
}else{
that.$el.children("ul").children(":nth-child(" + (index) + ")").after(newLI);
}
that.childViews.insert(index , newView);
if(cur){
newLI.children().children("textarea").focus().textareaAutoExpand();
}
else{
newView.lock();
}
return newView;
},
updateId: function(newId){
this.$el.attr("data-id", newId);
this.$el.children("ul").attr("data-id", newId);
@@ -176,15 +106,6 @@ var showView = Backbone.View.extend({
this.$el.children().children("textarea").removeAttr("readonly");
this.$el.children().children("textarea").val(this.model.get("text"));
this.$el.removeClass("editing");
},
removeNode: function(index){
var that = this;
that.childViews[index].remove();
that.childViews.remove(index);
},
pushView: function(view){
this.childViews.push(view);
this.$el.children("ul").children().last().after(view.$el);
}
File diff suppressed because one or more lines are too long
+60 -38
View File
@@ -1,11 +1,50 @@
var guidGenerator = function() {
var S4 = function() {
return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
};
return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
addNode = function(botStr, topStr){
var modelJSON = generateJSON(botStr);
var newNode = new NodeModel(modelJSON);
nodesCollection.add(newNode);
if(topStr || topStr==""){
vo.thisModel.set("text", topStr);
_.each(vo.thisModel.get("views"), function(view){ view.updateText(topStr); });
socket.emitWrapper("edit", [vo.thisId, topStr]);
}
var data = [ [vo.parentId, vo.thisIndex+1] , modelJSON ];
socket.emitWrapper("newNode", data);
vo.parentModel.get("children").insert(vo.thisIndex + 1, modelJSON._id);
var parentViews = vo.parentModel.get("views");
var tempIndex = vo.thisIndex+1; //adding nodes alters the index.
_.each(parentViews, function(parentView){
parentView.addNode(newNode, tempIndex, true);
});
INPUT_PROCESSED=true;
}
addNode = function(botStr, topStr){
generateJSON = function(botStr){
var randomId = guidGenerator();
var modelJSON = {
_id: randomId
@@ -14,39 +53,19 @@ addNode = function(botStr, topStr){
, children: []
, author: CurrentUser
};
if(topStr || topStr==""){
console.log("TOPSTR IS");
console.log(topStr);
vo.thisModel.set("text", topStr);
_.each(vo.thisModel.get("views"), function(view){
view.updateText(topStr);
});
socket.emitWrapper("edit", [vo.thisId, topStr]);
}
var newNode = new NodeModel(modelJSON);
nodesCollection.add(newNode);
vo.parentModel.get("children").insert(vo.thisIndex + 1, randomId);
var data = [ [vo.parentId, vo.thisIndex+1] , modelJSON ];
console.log("AddNode DATA"); console.log(data);
socket.emitWrapper("newNode", data);
var parentViews = vo.parentModel.get("views");
var tempIndex = vo.thisIndex+1; //adding nodes alters the index.
_.each(parentViews, function(parentView){
parentView.addNode(newNode, tempIndex, true);
});
// vo.thisLI.next().children().children("textarea").focus();
INPUT_PROCESSED=true;
console.log("FINISHED- ADD NODE")
return modelJSON;
}
guidGenerator = function() {
var S4 = function() {
return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
};
return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
}
/*
topStr is to the left. (also, the bottom part will be to the right. )
before: Textarea= topStr + botStr
@@ -76,6 +95,9 @@ splitText = function(that, callback){
callback(botStr, topStr); //addNode(botStr, topStr);
}
transclude = function(){
vo.parentModel.get("children").insert(vo.thisIndex+1, vo.thisId);
var modelJSON = {
+24 -12
View File
@@ -1,8 +1,24 @@
searchHandler = function(event){
console.log("searchHandler");
if(event.which != 13){return;}
event.preventDefault();
var search = event.target.value;
var SUBSET = nodesCollection.filter(function(model){
return model.get('text').indexOf(search) != -1;
});
myRouter.viewSearchSubset(SUBSET);
}
keydownHandler = function(event){ //the entire body is wrapped in this.
var that = this;
// console.log("keyDownHandler");
INPUT_PROCESSED=true;
INPUT_PROCESSED=true;
if(event.target.id == 'searchBar'){searchHandler(event); return;}
if(event.which == undefined){ console.log("ABORTED- event.which==undefined"); return; }
if(!CurrentUser){ alert("only logged in users can edit"); return;}//prevent non-logged in users from editing.
@@ -60,17 +76,13 @@ keydownHandler = function(event){ //the entire body is wrapped in this.
return;
}//
if(!vo.atEnd && !vo.atBeg){ //split bullet(Works correctly)
// var topStr = '';
// var botStr = '';
splitText(that, /*botStr, topStr,*/ addNode);
splitText(that, addNode);
return;
//addNode(botStr, topStr);
}
if(!vo.atEnd && vo.atBeg){//addNode (before). (equivalent to splitting bullet)
vo.thisIndex--; //a hack that works.
//var myLI = vo.thisLI;
// setTimeout(function(){myLI.children().children("textarea").focus()}, 3);
vo.cursorHack=true;
addNode("");
return;
@@ -155,26 +167,26 @@ if((vo.hitTab && event.shiftKey) || (event.keyCode == 37 && event.shiftKey)){//
}
}
if(event.keyCode == 38 && event.shiftKey) {
if(vo.thisLI.is(":first-child")){return;}//don't factor this out into the above if-statement
if(event.keyCode == 38 && event.shiftKey) { //move up
if(vo.thisLI.isFirstViz()){return;}//don't factor this out into the above if-statement
moveNode(vo.thisModel, vo.thisIndex, vo.parentModel, vo.parentModel, vo.thisIndex-1, true);
return;
}
if(event.keyCode == 40 && event.shiftKey) {
if(vo.thisLI.is(":last-child")){return;}
if(event.keyCode == 40 && event.shiftKey) { //move down
if( vo.thisLI.isLastViz() ){return;}
moveNode(vo.thisModel, vo.thisIndex, vo.parentModel, vo.parentModel, vo.thisIndex+1, true);
return;
}
if(event.keyCode == 38){//up
if(vo.thisLI.is(":first-child")){
if( vo.thisLI.isLastViz() ){
vo.thisLI.parent().parent().children().children("textarea").focus();
}
else{
vo.thisLI.prev().children().children("textarea").focus();
}
}
if(event.keyCode == 40){
if(event.keyCode == 40){ //down
vo.thisLI.next().children().children("textarea").focus();
}
+5 -5
View File
@@ -1,13 +1,9 @@
//Handles indenting,outdenting,moving up/down, and drag-n-drop.
var moveNode = function(thisModel, dragIndex, oldParModel, newParModel, dropIndex, chr){
//removeNode from OldParent part 1 = #models
console.log("\n\n");
console.log(dragIndex);
console.log(oldParModel.get("children"));
oldParModel.get("children").remove(dragIndex);
thisModel.get("parents").removeOne(oldParModel.get("_id"));
console.log(oldParModel.get("children"));
console.log("\n\n");
//removeNode from OldParent part 2 = #views
_.each(oldParModel.get("views"), function(oldParView){
@@ -23,6 +19,10 @@ var moveNode = function(thisModel, dragIndex, oldParModel, newParModel, dropInde
newParView.addNode(thisModel, dropIndex, chr);
});
var ids = [thisModel.get("_id"), oldParModel.get("_id"), newParModel.get("_id")];
var arrays = [thisModel.get("parents"), oldParModel.get("children"), newParModel.get("children")];
var indices = [dragIndex, dropIndex];
+1 -1
View File
@@ -27,7 +27,7 @@ var upDateParentModelViews = function(vo, broadcast){
if(!broadcast){ //broadCast=true means we received this update from somebody else.
//UI STUFF
// console.log("what");
if( vo.thisLI.is(":first-child") ){
if( vo.thisLI.isFirstViz() ){
if(vo.thisLI.attr('data-depth')!=0){
var len = vo.thisLI.parent().parent().children().children("textarea").val().length;
vo.thisLI.parent().parent().children().children("textarea").focus();
+58
View File
@@ -0,0 +1,58 @@
/*
I realize that a lot of this logic depends on the UI.
This is an unfortunate consequence of the fact that when I was originally
doing this, I wasn't using back-bone, and wasn't using models.
*/
voInitializer = function(that, event){
//var that = this;
vo = {};
vo.hitEnter = (event.which == 13);
vo.hitTab = (event.which ==9);
vo.atEnd = ( $(that).getSelection().end == $(that).val().length);
vo.atBeg = ( $(that).getSelection().start == 0);
//cursor = $(this).getSelection().start;
vo.hitBack = (event.which ==8);
vo.empty = ($(that).val().length ==0);
vo.highLighted = !vo.empty && ( $(that).getSelection().end != $(that).getSelection().start )
vo.rootLevel = $(that).closest("ul").is(".root")
vo.lastBullet = ( $(that).closest("li").isFirstViz() && vo.rootLevel); //(not useful)
vo.thisLI = $(event.target).closest("li");
vo.thisId = vo.thisLI.attr("data-id"); //data-id.
vo.thisIndex = vo.thisLI.index(); //returns -1 if there's no match.
vo.thisModel = nodesCollection.findWhere({_id: vo.thisId});
vo.thisView = vo.thisModel.get("views").slice(-1)[0]; //we're assuming a tree.
//(also, I'm not garbage collecting extra views when you zoom in/out, so we have to grab last element).
vo.siblingLI = vo.thisLI.prevAll(":visible:first");
vo.siblingIndex = vo.siblingLI.index();
vo.siblingId = vo.siblingLI.attr("data-id");
vo.siblingModel = nodesCollection.findWhere({_id: vo.siblingId});
if(vo.rootLevel){
vo.parentLI = undefined;
vo.parentId = (vo.thisLI.closest("ul").attr("data-id"))
vo.grandParentId = undefined; // won't matter since outTab prevents it. //unless programattic.
}
else{ //not root level.
//debugger;
vo.parentLI = vo.thisLI.parent().closest("li");
vo.parentId = (vo.parentLI.attr("data-id"));
if(vo.parentLI.attr("data-depth") == 0){ //could test this another way.
vo.grandParentId = vo.parentLI.closest("ul").attr("data-id");
//console.log("grandParentId" + grandParentId)
}
else{
vo.grandParentId = (vo.parentLI.parent().closest("li").attr('data-id'));
//console.log("grandParentId" + grandParentId)
}
}
vo.grandParentModel = nodesCollection.findWhere({_id: vo.grandParentId});
vo.parentModel = nodesCollection.findWhere({_id: vo.parentId});
vo.cursorHack = false;
} //(vo-initializer)
+3 -3
View File
@@ -38,7 +38,7 @@ $('body').on("mousedown", ".handle", function(e){
dragState.oldParModel = nodesCollection.findWhere({_id: dragState.thisLI.parent().attr("data-id") });
var firstLI = $(".root").children(":first-child");
var firstLI = $(".root").children(":visible:first");
var firstEntry = [0, firstLI, "above"];
containerArray.push(firstEntry);
@@ -59,7 +59,7 @@ $('body').on("mousedown", ".handle", function(e){
li = $(li);
var collapsed = (li.children(".zoomButton").hasClass("collapsed") || li.children("ul").children().length == 0);
var opened = !collapsed;
var last = li.is(":last-child");
var last = li.isLastViz();
if( !(opened || last) ){
var entry = [ thisTop , li , "below" ];
@@ -68,7 +68,7 @@ $('body').on("mousedown", ".handle", function(e){
else{
if(opened){
console.log("opened");
var firstChild = li.children("ul").children(":first-child")
var firstChild = li.children("ul").children(":visible:first")
var firstEntry = [ thisTop , firstChild, "above"];
containerArray.push(firstEntry);
+33 -3
View File
@@ -24,6 +24,7 @@
<script src="js/libs/externalLibs/jquery-2.0.3.js"></script>
<script src="socket.io/socket.io.js"></script>
<script src="js/libs/myLogic/voInitializer.js"></script>
<script src="js/libs/myLogic/addNode.js"></script>
<script src="js/libs/myLogic/removeNode.js"></script>
<script src="js/libs/myLogic/keydownHandler.js"></script>
@@ -38,10 +39,9 @@
<!-- <script src="./jquery-sortable.js"></script> -->
<script src="js/libs/externalLibs/rangyinputs-jquery-1.1.2.js"></script>
<script src="js/libs/externalLibs/textarea_auto_expand.js"></script>
<script src="js/libs/externalLibs/jqueryTextComplete.js"></script>
<script type="text/x-mathjax-config">
@@ -61,6 +61,7 @@
<script src="js/backbone/models/node.js"></script>
<script src="js/backbone/collections/nodesCollection.js"></script>
<script src="js/backbone/views/metaView.js"></script>
<script src="js/backbone/views/listView.js"></script>
<script src="js/backbone/views/showView.js"></script>
<script src="js/backbone/router.js"></script>
@@ -69,7 +70,7 @@
<body>
<div class='myNav'>
<a class='logoLink'>CoNote</a>
<textarea id='searchBar'> </textarea>
<textarea id='searchBar'></textarea>
<a class='btn btn-default'><i class='icon-star'></i></a>
<ul class='navbar-right'>
@@ -115,6 +116,32 @@
<script>
$(function(){
$('textarea').textareaAutoExpand();
$('#searchBar').textcomplete([
{ // html
mentions: ['yuku_t'],
match: /\B@(\w*)$/,
search: function (term, callback) {
callback($.map(this.mentions, function (mention) {
return mention.indexOf(term) === 0 ? mention : null;
}));
},
index: 1,
replace: function (mention) {
return '@' + mention + ' ';
}
}
], { appendTo: 'body' }).overlay([
{
match: /\B@\w+/g,
css: {
'background-color': '#d8dfea'
}
}
]);
});
var width;
@@ -127,6 +154,9 @@ $(window).resize(function() {
$(".navbar-right").show();
}
});
</script>
</html>