File: category_autocomplete.rb

package info (click to toggle)
tdiary 5.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,088 kB
  • sloc: ruby: 23,031; javascript: 1,029; xml: 325; makefile: 26; sh: 4
file content (32 lines) | stat: -rw-r--r-- 989 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#
# category_autocomplete.rb : Support the automatic input of the category
#                            using jQuery UI autocomplete.
#
# Copyright (C) 2010-2012, tamoot <tamoot+tdiary@gmail.com>
# You can redistribute it and/or modify it under GPL2 or any later version.
#

if /\A(?:form|preview|append|edit|update)\z/ =~ @mode
	add_header_proc do
		%Q|<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.min.css"/>|
	end

	enable_js('//ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js')
	enable_js('caretposition.js')
	enable_js('category_autocomplete.js')

	if @categories.size > 0
		categories_json = @categories.map{ |c| "\"#{c}\"" }
		add_js_setting('$tDiary.plugin.category_autocomplete')
		add_js_setting('$tDiary.plugin.category_autocomplete.candidates',
			"[#{categories_json.join(",")}]")
	end
end

# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:
# vim: ts=3