Commit 7024ba85 by tady

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

parent c44e6e14
......@@ -10,10 +10,10 @@
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require_self
// require jquery
// require jquery_ujs
// require turbolinks
//= require_tree ./lib
//= 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/
$this = $(this)
keyCode = e.keyCode || e.which
# tab key
if keyCode is 9
e.preventDefault()
start = $this.get(0).selectionStart
......@@ -31,19 +32,20 @@ if window.location.pathname.match /edit/
$this.get(0).selectionStart =
$this.get(0).selectionEnd = start + 1
# enter key
else if keyCode is 13
val = $this.val()
start = $this.get(0).selectionStart
bl = val.lastIndexOf("\n", start-1)
line = val.substring(bl, start)
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"
_(ns).times ->
nv += "\t"
$this.val(nv + val.substring(start))
$this.get(0).selectionStart =
$this.get(0).selectionEnd = start + ns + 1
$this.get(0).selectionEnd = start + ns + 1
e.preventDefault()
# new post tags
......
......@@ -29,7 +29,7 @@ class Post < ActiveRecord::Base
_date = Time.new($1, $2, $3)
_where_list = _where_list.where('updated_at > ? AND updated_at < ?', _date, _date + 1.day)
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
......
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