Permalink
Browse files

replace \n with ^

  • Loading branch information...
1 parent a99f86d commit 6b8174414639ebca2c3eb1283db0724eee37275c @brownman committed Nov 16, 2012
View
BIN .sass-cache/dde4918d3d6e6208f003e8a059cae43f879f4cbf/bootstrap_and_overrides.css.scssc
Binary file not shown.
View
34 app/assets/javascripts/backbone/models/comment.js.coffee
@@ -3,30 +3,23 @@ class RailsBackboneRelational.Models.Comment extends Backbone.RelationalModel
@array = []
defaults:
- content: null
+ content: 'content'
direction: true
- title: null
+ title: 'title'
initialize: () ->
- tmp = @get('content')
- if (tmp && tmp.length > 0)
- @array = @split()
- obj = { counter: 0 }
- _.extend(obj,Backbone.Events)
- obj.on('event',
- () -> obj.counter += 1
- )
- obj.trigger('event')
- @equal1(obj.counter,1,'counter should be incremented.')
- obj.trigger('event')
- obj.trigger('event')
- obj.trigger('event')
- obj.trigger('event')
- @equal1(obj.counter, 5, 'counter should be incremented five times.')
+
+ this.on('change:content', @update_array)
+ @update_array()
#console.log(this)
#save: ->
+ update_array: () =>
+ #alert('update array')
+ tmp = @get('content')
+ if (tmp && tmp.length > 0)
+ @array = @split()
equal1: (a,b,c) ->
#alert(a + '|' + '|' +c)
@@ -47,8 +40,11 @@ class RailsBackboneRelational.Models.Comment extends Backbone.RelationalModel
split : () ->
str = @get('content')
story_enc = str
- # story_enc = story_enc.replace(/\n/g, "^")
- arr_symbols = [',', '!', '.', "?", ":", ";", "=", "\n" ]
+ story_enc = story_enc.replace(/\n/g, "^")
+
+ arr_symbols = [',', '!', '.', "?", ":", ";", "=" ]
+ #if !@direction
+ #arr_symbols.push "\n"
story_enc = @replace(story_enc, arr_symbols)
story_arr = story_enc.split('$')
story_arr
View
41 app/assets/javascripts/backbone/models/comment.js.coffee~
@@ -3,30 +3,23 @@ class RailsBackboneRelational.Models.Comment extends Backbone.RelationalModel
@array = []
defaults:
- content: null
+ content: 'content'
direction: true
- title: null
+ title: 'title'
initialize: () ->
- tmp = @get('content')
- if (tmp && tmp.length > 0)
- @array = @split()
- obj = { counter: 0 }
- _.extend(obj,Backbone.Events)
- obj.on('event',
- () -> obj.counter += 1
- )
- obj.trigger('event')
- @equal1(obj.counter,1,'counter should be incremented.')
- obj.trigger('event')
- obj.trigger('event')
- obj.trigger('event')
- obj.trigger('event')
- @equal1(obj.counter, 5, 'counter should be incremented five times.')
+
+ this.on('change:content', @update_array)
+ @update_array()
#console.log(this)
#save: ->
+ update_array: () =>
+ #alert('update array')
+ tmp = @get('content')
+ if (tmp && tmp.length > 0)
+ @array = @split()
equal1: (a,b,c) ->
#alert(a + '|' + '|' +c)
@@ -47,8 +40,11 @@ class RailsBackboneRelational.Models.Comment extends Backbone.RelationalModel
split : () ->
str = @get('content')
story_enc = str
- # story_enc = story_enc.replace(/\n/g, "^")
- arr_symbols = [',', '!', '.', "?", ":", ";", "=", "\n" ]
+ story_enc = story_enc.replace(/\n/g, "^")
+
+ arr_symbols = [',', '!', '.', "?", ":", ";", "=" ]
+ #if !@direction
+ #arr_symbols.push "\n"
story_enc = @replace(story_enc, arr_symbols)
story_arr = story_enc.split('$')
story_arr
@@ -84,8 +80,9 @@ class RailsBackboneRelational.Collections.CommentsCollection extends Backbone.Co
add1: () =>
- console.log(this)
- length_i = this.models.length
+ console.log(this)
+ length_i = this.models.length
+ if length_i > 0
length_j = this.models[0].array.length
#find min array
@@ -104,7 +101,7 @@ class RailsBackboneRelational.Collections.CommentsCollection extends Backbone.Co
if ( num1 == length_i)
for i in [0...length_i]
this.models[i].array[j..j] = []
- this.trigger('add2')
+ this.trigger('add2')
View
24 app/assets/javascripts/backbone/templates/comments/comment.jst.ejs
@@ -4,28 +4,38 @@
-<input type="checkbox" name="direction" class="direction checkbox span12" <%= obj.direction ? 'checked="checked"' : '' %> />
-<input class='span12' height='1em' type='text' value='<%= obj.title %>'></input>
+<input type="checkbox" name="direction" class="span12 direction checkbox " <%= obj.direction ? 'checked="checked"' : '' %> ></input>
+id:
+<input class='' height='1em' type='text' label='id' value='<%= obj.id %>'></input>
+<br>
+title:
+<input class='title' height='1em' type='text' value='<%= obj.title %>'></input>
+<br>
-<input label='time: ' tooltip='delay in seconds' class='seconds span12' height='1em' type='text' value='<%= obj3 %>'></input>
+delay(s):
+<input label='time: ' tooltip='delay in seconds' class='seconds' height='1em' type='text' value='<%= obj3 %>'></input>
+<br>
-<input label='span: ' tooltip='delay in seconds' class='seconds span12' height='1em' type='text' value='<%= obj4 %>'></input>
+span:
+<input label='span: ' tooltip='delay in seconds' class='seconds' height='1em' type='text' value='<%= obj4 %>'></input>
+<br>
-
-<textarea rows="4" height='1em' class='span12' name="content1" >
+content:
+<textarea class="content" rows="4" height='1em' class='' name="content1" >
<%= obj.content %>
</textarea>
+<br>
@@ -47,4 +57,4 @@
<a href="/comments#/<%= obj.id %>/destroy" class="destroy">kill</a>
</div>
-
+<span padding='3px' height='100%'></span>
View
22 app/assets/javascripts/backbone/templates/comments/comment.jst.ejs~
@@ -4,26 +4,38 @@
-<input type="checkbox" name="direction" class="direction checkbox span12" <%= obj.direction ? 'checked="checked"' : '' %> />
-<input class='span12' height='1em' type='text' value='<%= obj.title %>'></input>
+<input type="checkbox" name="direction" class="span12 direction checkbox " <%= obj.direction ? 'checked="checked"' : '' %> ></input>
+id:
+<input class='' height='1em' type='text' label='id' value='<%= obj.id %>'></input>
+<br>
+title:
+<input class='title' height='1em' type='text' value='<%= obj.title %>'></input>
+<br>
-<input label='time: ' tooltip='delay in seconds' class='seconds span12' height='1em' type='text' value='<%= obj3 %>'></input>
+delay(s):
+<input label='time: ' tooltip='delay in seconds' class='seconds' height='1em' type='text' value='<%= obj3 %>'></input>
+<br>
+span:
+<input label='span: ' tooltip='delay in seconds' class='seconds' height='1em' type='text' value='<%= obj4 %>'></input>
+<br>
-<textarea rows="4" height='1em' class='span12' name="content1" >
+content:
+<textarea rows="4" height='1em' class='' name="content1" >
<%= obj.content %>
</textarea>
+<br>
@@ -45,4 +57,4 @@
<a href="/comments#/<%= obj.id %>/destroy" class="destroy">kill</a>
</div>
-
+<span padding='3px' height='100%'></span>
View
3 app/assets/javascripts/backbone/templates/posts/post.jst.ejs
@@ -1,16 +1,19 @@
<div class="accordion-heading">
<div class="accordion-toggle" data-toggle="collapse" data-parent="#posts-list" href="#collapseOne<%= post.id %>">
+<button class='open btn span2' >fetch</button>
<a class="id"><%= post.id %></a>
<input class="title" value=<%= post.title %> >title: </input>
<a href="#/posts<%= post.id %>/edit" class="edit">edit</a>
<a href="/posts#/<%= post.id %>/destroy" class="destroy">delete</a>
+
<a class="c_length" >length:<%= length %> </a>
+
</div>
</div>
<div id="collapseOne<%= post.id %>" class="accordion-body collapse">
View
6 app/assets/javascripts/backbone/templates/posts/post.jst.ejs~
@@ -1,15 +1,19 @@
<div class="accordion-heading">
<div class="accordion-toggle" data-toggle="collapse" data-parent="#posts-list" href="#collapseOne<%= post.id %>">
+<button class='open btn span2' >open</button>
<a class="id"><%= post.id %></a>
<input class="title" value=<%= post.title %> >title: </input>
<a href="#/posts<%= post.id %>/edit" class="edit">edit</a>
-<a class="c_length" >length:<%= length %> </a>
<a href="/posts#/<%= post.id %>/destroy" class="destroy">delete</a>
+<a class="c_length" >length:<%= length %> </a>
+
+
+
</div>
</div>
<div id="collapseOne<%= post.id %>" class="accordion-body collapse">
View
45 app/assets/javascripts/backbone/views/comments/comment_view.js.coffee
@@ -18,18 +18,45 @@ class RailsBackboneRelational.Views.Comments.CommentView extends Backbone.View
"blur .seconds" : "set_delay"
+ "blur .content" : "set_content"
+
+ "keypress .title" : "updateOnEnter"
#"hover .todo-array button": "show_tooltip"
+ set_content: (e) ->
+ console.log(e)
+ input = e.target.value
+
+ #this.$(".content");
+ console.log(input)
+
+ @model.set({ content: input })
+ #@render()
+
+
+ updateOnEnter: (e) ->
+
+ #this.trigger('somethingHappened')
+ if e.keyCode is 13
+ console.log(e)
+ @input = this.$(".title");
+ console.log(@input)
- initialize: () =>
+ @model.save({ title: @input.val() })
+
+ #$(@el).removeClass("editing")
+ initialize: () ->
console.log(this)
console.log(@options)
- num = @options['c_length']
- #this.model.collection.length
+ num =
+
+ this.model.collection.length
+
+ #@options['c_length']
@update_span(num)
#@options.c_length
@status = 'saved'
@@ -50,9 +77,10 @@ class RailsBackboneRelational.Views.Comments.CommentView extends Backbone.View
toggleDone : () ->
@model.save(
-
- direction : !this.model.get('direction')
+ {direction : !this.model.get('direction') }
+ {silent: true}
)
+ @render()
@@ -65,10 +93,11 @@ class RailsBackboneRelational.Views.Comments.CommentView extends Backbone.View
- render: =>
+ render: ->
listed2 = this.splitted2()
comment = @model.toJSON()
+
status = @status.toString()
seconds = @seconds.toString()
spans = @el.className.toString()
@@ -81,6 +110,7 @@ class RailsBackboneRelational.Views.Comments.CommentView extends Backbone.View
'obj3': seconds
'obj4': spans
+
)
$(@el).html(tmp)
@@ -132,7 +162,8 @@ class RailsBackboneRelational.Views.Comments.CommentView extends Backbone.View
@model.save(
content: text
)
- this.trigger('somethingHappened');
+ #this.trigger('somethingHappened');
+ #@render
View
42 app/assets/javascripts/backbone/views/comments/comment_view.js.coffee~
@@ -18,17 +18,45 @@ class RailsBackboneRelational.Views.Comments.CommentView extends Backbone.View
"blur .seconds" : "set_delay"
+ "blur .content" : "set_content"
+
+ "keypress .title" : "updateOnEnter"
#"hover .todo-array button": "show_tooltip"
+ set_content: (e) ->
+ console.log(e)
+ input = e.target.value
+
+ #this.$(".content");
+ console.log(input)
+
+ @model.save({ content: input })
+ #@render()
+
+ updateOnEnter: (e) ->
+
+ #this.trigger('somethingHappened')
+ if e.keyCode is 13
+ console.log(e)
+ @input = this.$(".title");
+ console.log(@input)
+
+ @model.save({ title: @input.val() })
+
+ #$(@el).removeClass("editing")
initialize: () ->
console.log(this)
console.log(@options)
- num = this.model.collection.length
+ num =
+
+ this.model.collection.length
+
+ #@options['c_length']
@update_span(num)
#@options.c_length
@status = 'saved'
@@ -49,9 +77,10 @@ class RailsBackboneRelational.Views.Comments.CommentView extends Backbone.View
toggleDone : () ->
@model.save(
-
- direction : !this.model.get('direction')
+ {direction : !this.model.get('direction') }
+ {silent: true}
)
+ @render()
@@ -64,10 +93,11 @@ class RailsBackboneRelational.Views.Comments.CommentView extends Backbone.View
- render: =>
+ render: ->
listed2 = this.splitted2()
comment = @model.toJSON()
+
status = @status.toString()
seconds = @seconds.toString()
spans = @el.className.toString()
@@ -80,6 +110,7 @@ class RailsBackboneRelational.Views.Comments.CommentView extends Backbone.View
'obj3': seconds
'obj4': spans
+
)
$(@el).html(tmp)
@@ -131,7 +162,8 @@ class RailsBackboneRelational.Views.Comments.CommentView extends Backbone.View
@model.save(
content: text
)
- this.trigger('somethingHappened');
+ #this.trigger('somethingHappened');
+ #@render
View
7 app/assets/javascripts/backbone/views/comments/index_view.js.coffee
@@ -16,7 +16,7 @@ class RailsBackboneRelational.Views.Comments.IndexView extends Backbone.View
#@options.comments.each(@update_span(num))
#.on('add2', this.alert_parent);
- @options.comments.bind('reset', @addAll)
+ #@options.comments.bind('reset', @addAll)
@options.comments.bind('add2', @add2_view)
#@options.comments.bind('remove', @addAll)
@@ -66,20 +66,21 @@ class RailsBackboneRelational.Views.Comments.IndexView extends Backbone.View
addAll: () =>
#console.log(@options.comments)
comments1 = @options.comments
- comments1.each(@addOne, num: comments1.length)
+ comments1.each(@addOne)
addOne: (comment ) =>
#this.trigger('somethingHappened')
abcd =
model : comment
- c_length: @num.toString()
+ #c_length: @num.toString()
view = new RailsBackboneRelational.Views.Comments.CommentView(abcd)
#view.el.className =
view.update_span(@num)
+ #view.model.collection.each(@update_span)
@$(".comments-list").append(view.render().el)
render: =>
View
5 app/assets/javascripts/backbone/views/comments/index_view.js.coffee~
@@ -66,20 +66,21 @@ class RailsBackboneRelational.Views.Comments.IndexView extends Backbone.View
addAll: () =>
#console.log(@options.comments)
comments1 = @options.comments
- comments1.each(@addOne, num: comments1.length)
+ comments1.each(@addOne)
addOne: (comment ) =>
#this.trigger('somethingHappened')
abcd =
model : comment
- c_length: num
+ #c_length: @num.toString()
view = new RailsBackboneRelational.Views.Comments.CommentView(abcd)
#view.el.className =
view.update_span(@num)
+ #view.model.collection.each(@update_span)
@$(".comments-list").append(view.render().el)
render: =>
View
9 app/assets/javascripts/backbone/views/comments/new_view.js.coffee
@@ -31,10 +31,10 @@ class RailsBackboneRelational.Views.Comments.NewView extends Backbone.View
@collection.create(@model.toJSON(),
success: (comment) =>
alert('success')
- view = new RailsBackboneRelational.Views.Comments.CommentView({model : comment})
- tmp = view.render().el
- tmp1 = $(@.el).parent().parent().find('.comments-list')
- $(tmp1).append(tmp)
+ #view = new RailsBackboneRelational.Views.Comments.CommentView({model : comment})
+ #tmp = view.render().el
+ #tmp1 = $(@.el).parent().parent().find('.comments-list')
+ #$(tmp1).append(tmp)
@$('.content').val('good')
@$('.title').val('good1')
@@ -51,3 +51,4 @@ class RailsBackboneRelational.Views.Comments.NewView extends Backbone.View
$(@el).html(@template(@model.toJSON() ))
return this
+
View
9 app/assets/javascripts/backbone/views/comments/new_view.js.coffee~
@@ -31,16 +31,15 @@ class RailsBackboneRelational.Views.Comments.NewView extends Backbone.View
@collection.create(@model.toJSON(),
success: (comment) =>
alert('success')
- view = new RailsBackboneRelational.Views.Comments.CommentView({model : comment})
- tmp = view.render().el
- tmp1 = $(@.el).parent().parent().find('.comments-list')
- $(tmp1).append(tmp)
+ #view = new RailsBackboneRelational.Views.Comments.CommentView({model : comment})
+ #tmp = view.render().el
+ #tmp1 = $(@.el).parent().parent().find('.comments-list')
+ #$(tmp1).append(tmp)
@$('.content').val('good')
@$('.title').val('good1')
error: (comment, jqXHR) =>
alert('error')
-
console.log(comment)
console.log(jqXHR)
@model.set({errors: $.parseJSON(jqXHR.responseText)})
View
6 app/assets/javascripts/backbone/views/posts/post_view.js.coffee
@@ -9,7 +9,7 @@ class RailsBackboneRelational.Views.Posts.PostView extends Backbone.View
#"dblclick a.todo-content" : "edit",
"keypress .title" : "updateOnEnter"
- "dblclick .accordion-toggle" : "show_post"
+ "click .accordion-toggle .open" : "show_post"
@@ -56,13 +56,13 @@ class RailsBackboneRelational.Views.Posts.PostView extends Backbone.View
#
updateOnEnter: (e) ->
- this.trigger('somethingHappened')
+ #this.trigger('somethingHappened')
if e.keyCode is 13
console.log(e)
@input = this.$(".title");
console.log(@input)
- #@model.save({ title: @input.val() })
+ @model.save({ title: @input.val() })
#$(@el).removeClass("editing")
render: ->
View
6 app/assets/javascripts/backbone/views/posts/post_view.js.coffee~
@@ -9,7 +9,7 @@ class RailsBackboneRelational.Views.Posts.PostView extends Backbone.View
#"dblclick a.todo-content" : "edit",
"keypress .title" : "updateOnEnter"
- "dblclick .accordion-toggle" : "show_post"
+ "click .accordion-toggle .open" : "show_post"
@@ -37,7 +37,7 @@ class RailsBackboneRelational.Views.Posts.PostView extends Backbone.View
ofer_length: num
comments_view = new RailsBackboneRelational.Views.Comments.IndexView(abc)
- view.$(".comments").html(comments_view.render().el)
+ view.$(".comments").html(comments_view.render().$el)
new_comment_view = new RailsBackboneRelational.Views.Comments.NewView(collection: post.get('comments'))
view.$(".new_comment").html(new_comment_view.render().el)
@@ -62,7 +62,7 @@ class RailsBackboneRelational.Views.Posts.PostView extends Backbone.View
@input = this.$(".title");
console.log(@input)
- #@model.save({ title: @input.val() })
+ @model.save({ title: @input.val() })
#$(@el).removeClass("editing")
render: ->
View
6 app/assets/stylesheets/bootstrap_and_overrides.css.scss
@@ -102,8 +102,10 @@ font-weight:bold;
}
-.direction {
-
+.direction .checkbox {
+/*
+ *height: 22em;
+ */
/*
*padding-left:0;
*/
View
2 app/views/layouts/application.html.erb
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
- <title>TodoList</title>
+ <title>Book-splitter</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
View
3 app/views/layouts/application.html.erb~
@@ -7,7 +7,8 @@
<%= csrf_meta_tags %>
-<meta name="viewport" content="width=device-width, initial-scale=1.0">
+
+<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
</head>

0 comments on commit 6b81744

Please sign in to comment.