Commit 7024ba85 by tady

編集ページのjsの不具合解消

parent c44e6e14
...@@ -10,10 +10,10 @@ ...@@ -10,10 +10,10 @@
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives. // about supported directives.
// //
//= require_self
// require jquery // require jquery
// require jquery_ujs // require jquery_ujs
// require turbolinks // require turbolinks
//= require_tree ./lib //= require_tree ./lib
//= require_tree . //= require_tree .
//= require_self
window.debug = ->
if console? && console.debug? && location.hash is '#debug'
return console.log.bind(console)
else
->
if window.location.pathname.match /edit/ if window.location.pathname.match /edit|new/
$ -> $ ->
...@@ -17,6 +17,7 @@ if window.location.pathname.match /edit/ ...@@ -17,6 +17,7 @@ if window.location.pathname.match /edit/
$this = $(this) $this = $(this)
keyCode = e.keyCode || e.which keyCode = e.keyCode || e.which
# tab key
if keyCode is 9 if keyCode is 9
e.preventDefault() e.preventDefault()
start = $this.get(0).selectionStart start = $this.get(0).selectionStart
...@@ -31,13 +32,14 @@ if window.location.pathname.match /edit/ ...@@ -31,13 +32,14 @@ if window.location.pathname.match /edit/
$this.get(0).selectionStart = $this.get(0).selectionStart =
$this.get(0).selectionEnd = start + 1 $this.get(0).selectionEnd = start + 1
# enter key
else if keyCode is 13 else if keyCode is 13
val = $this.val() val = $this.val()
start = $this.get(0).selectionStart start = $this.get(0).selectionStart
bl = val.lastIndexOf("\n", start-1) bl = val.lastIndexOf("\n", start-1)
line = val.substring(bl, start) line = val.substring(bl, start)
lm = line.match(/^\s+/) lm = line.match(/^\s+/)
ns = lm ? lm[0].length - 1 : 0 ns = if lm? then lm[0].length - 1 else 0
nv = val.substring(0, start) + "\n" nv = val.substring(0, start) + "\n"
_(ns).times -> _(ns).times ->
nv += "\t" nv += "\t"
......
...@@ -29,7 +29,7 @@ class Post < ActiveRecord::Base ...@@ -29,7 +29,7 @@ class Post < ActiveRecord::Base
_date = Time.new($1, $2, $3) _date = Time.new($1, $2, $3)
_where_list = _where_list.where('updated_at > ? AND updated_at < ?', _date, _date + 1.day) _where_list = _where_list.where('updated_at > ? AND updated_at < ?', _date, _date + 1.day)
else else
_where_list = _where_list.where('body LIKE ? OR body LIKE ?', "%#{_query}%", "%#{_query}%") _where_list = _where_list.where('title LIKE ? OR body LIKE ?', "%#{_query}%", "%#{_query}%")
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment