puffer 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/app/helpers/puffer_helper.rb +8 -0
- data/app/views/layouts/puffer.html.erb +5 -11
- data/lib/generators/puffer/install/install_generator.rb +2 -2
- data/lib/generators/puffer/install/templates/puffer.rb +12 -0
- data/lib/generators/puffer/install/templates/puffer/javascripts/{application.js → puffer.js} +0 -0
- data/lib/generators/puffer/install/templates/puffer/javascripts/{rails-src.js → rails.js} +0 -0
- data/lib/puffer.rb +14 -0
- data/lib/puffer/controller/mutate.rb +8 -2
- data/lib/puffer/extensions/mapper.rb +2 -2
- data/lib/puffer/inputs.rb +1 -1
- data/lib/puffer/path_set.rb +14 -7
- data/lib/puffer/resource.rb +1 -1
- data/puffer.gemspec +8 -44
- data/spec/dummy/config/initializers/puffer.rb +12 -0
- data/spec/dummy/public/puffer/javascripts/{application.js → puffer.js} +0 -0
- data/spec/dummy/public/puffer/javascripts/{rails-src.js → rails.js} +0 -0
- metadata +10 -46
- data/lib/generators/puffer/install/templates/puffer/javascripts/right-autocompleter-src.js +0 -621
- data/lib/generators/puffer/install/templates/puffer/javascripts/right-autocompleter.js.gz +0 -0
- data/lib/generators/puffer/install/templates/puffer/javascripts/right-calendar-src.js +0 -1461
- data/lib/generators/puffer/install/templates/puffer/javascripts/right-calendar.js.gz +0 -0
- data/lib/generators/puffer/install/templates/puffer/javascripts/right-in-edit-src.js +0 -369
- data/lib/generators/puffer/install/templates/puffer/javascripts/right-in-edit.js +0 -13
- data/lib/generators/puffer/install/templates/puffer/javascripts/right-in-edit.js.gz +0 -0
- data/lib/generators/puffer/install/templates/puffer/javascripts/right-lightbox-src.js +0 -905
- data/lib/generators/puffer/install/templates/puffer/javascripts/right-lightbox.js +0 -24
- data/lib/generators/puffer/install/templates/puffer/javascripts/right-lightbox.js.gz +0 -0
- data/lib/generators/puffer/install/templates/puffer/javascripts/right-sortable-src.js +0 -428
- data/lib/generators/puffer/install/templates/puffer/javascripts/right-sortable.js +0 -17
- data/lib/generators/puffer/install/templates/puffer/javascripts/right-sortable.js.gz +0 -0
- data/lib/generators/puffer/install/templates/puffer/javascripts/right-src.js +0 -5892
- data/lib/generators/puffer/install/templates/puffer/javascripts/right-tabs-src.js +0 -1145
- data/lib/generators/puffer/install/templates/puffer/javascripts/right-tabs.js +0 -29
- data/lib/generators/puffer/install/templates/puffer/javascripts/right-tabs.js.gz +0 -0
- data/lib/generators/puffer/install/templates/puffer/javascripts/right.js.gz +0 -0
- data/spec/dummy/config/puffer.rb +0 -0
- data/spec/dummy/public/puffer/javascripts/right-autocompleter-src.js +0 -621
- data/spec/dummy/public/puffer/javascripts/right-autocompleter.js.gz +0 -0
- data/spec/dummy/public/puffer/javascripts/right-calendar-src.js +0 -1461
- data/spec/dummy/public/puffer/javascripts/right-calendar.js.gz +0 -0
- data/spec/dummy/public/puffer/javascripts/right-in-edit-src.js +0 -369
- data/spec/dummy/public/puffer/javascripts/right-in-edit.js +0 -13
- data/spec/dummy/public/puffer/javascripts/right-in-edit.js.gz +0 -0
- data/spec/dummy/public/puffer/javascripts/right-lightbox-src.js +0 -905
- data/spec/dummy/public/puffer/javascripts/right-lightbox.js +0 -24
- data/spec/dummy/public/puffer/javascripts/right-lightbox.js.gz +0 -0
- data/spec/dummy/public/puffer/javascripts/right-sortable-src.js +0 -428
- data/spec/dummy/public/puffer/javascripts/right-sortable.js +0 -17
- data/spec/dummy/public/puffer/javascripts/right-sortable.js.gz +0 -0
- data/spec/dummy/public/puffer/javascripts/right-src.js +0 -5892
- data/spec/dummy/public/puffer/javascripts/right-tabs-src.js +0 -1145
- data/spec/dummy/public/puffer/javascripts/right-tabs.js +0 -29
- data/spec/dummy/public/puffer/javascripts/right-tabs.js.gz +0 -0
- data/spec/dummy/public/puffer/javascripts/right.js.gz +0 -0
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.12
|
@@ -1,5 +1,13 @@
|
|
1
1
|
module PufferHelper
|
2
2
|
|
3
|
+
def puffer_stylesheets
|
4
|
+
stylesheet_link_tag *Puffer.stylesheets.map {|path| "/puffer/stylesheets/#{path}"}.uniq.compact
|
5
|
+
end
|
6
|
+
|
7
|
+
def puffer_javascripts
|
8
|
+
javascript_include_tag *Puffer.javascripts.map {|path| "/puffer/javascripts/#{path}"}.uniq.compact
|
9
|
+
end
|
10
|
+
|
3
11
|
def render_head field
|
4
12
|
field.label
|
5
13
|
end
|
@@ -4,22 +4,16 @@
|
|
4
4
|
<title><%= [@title, 'Puffer'].compact.join(' - ') %></title>
|
5
5
|
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
|
6
6
|
<%= csrf_meta_tag %>
|
7
|
-
<%=
|
8
|
-
<%=
|
9
|
-
<%=
|
10
|
-
|
11
|
-
<%= javascript_include_tag '/puffer/javascripts/right-src' %>
|
12
|
-
<%= javascript_include_tag '/puffer/javascripts/right-calendar-src' %>
|
13
|
-
<%= javascript_include_tag '/puffer/javascripts/right-autocompleter-src' %>
|
14
|
-
<%= javascript_include_tag '/puffer/javascripts/rails-src' %>
|
15
|
-
<%= javascript_include_tag '/puffer/javascripts/application' %>
|
16
|
-
<%= yield :javascript %>
|
7
|
+
<%= puffer_stylesheets %>
|
8
|
+
<%= yield :stylesheets %>
|
9
|
+
<%= puffer_javascripts %>
|
10
|
+
<%= yield :javascripts %>
|
17
11
|
</head>
|
18
12
|
<body>
|
19
13
|
<div class="body">
|
20
14
|
<div class="header">
|
21
15
|
<div class="logo">
|
22
|
-
<%= link_to
|
16
|
+
<%= link_to Puffer.logo, admin_root_path %>
|
23
17
|
</div>
|
24
18
|
<ul class="navigation">
|
25
19
|
<% puffer_navigation do |title, path, current| %>
|
@@ -1,12 +1,12 @@
|
|
1
1
|
class Puffer::InstallGenerator < Rails::Generators::Base
|
2
2
|
source_root File.expand_path('../templates', __FILE__)
|
3
3
|
|
4
|
-
def
|
4
|
+
def generate_assets
|
5
5
|
directory 'puffer', 'public/puffer'
|
6
6
|
end
|
7
7
|
|
8
8
|
def generate_config
|
9
|
-
copy_file 'puffer.rb', 'config/puffer.rb'
|
9
|
+
copy_file 'puffer.rb', 'config/initializers/puffer.rb'
|
10
10
|
end
|
11
11
|
|
12
12
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Use this to configure puffer
|
2
|
+
Puffer.setup do |config|
|
3
|
+
|
4
|
+
# Add additional javascript and stylesheets files to puffer.html.erb layouts
|
5
|
+
# All additional paths should be relative to rails_app/public/puffer/(javascripts|stylesheets)
|
6
|
+
# config.stylesheets += %w(path/to/my/stylesheet)
|
7
|
+
# config.javascripts += %w(path/to/my/javascript)
|
8
|
+
|
9
|
+
# Puffer logo text. At the top-left of the layout. Default - `Puffer`
|
10
|
+
# config.logo = 'My cool application'
|
11
|
+
|
12
|
+
end
|
data/lib/generators/puffer/install/templates/puffer/javascripts/{application.js → puffer.js}
RENAMED
File without changes
|
File without changes
|
data/lib/puffer.rb
CHANGED
@@ -1,4 +1,18 @@
|
|
1
1
|
module Puffer
|
2
|
+
|
3
|
+
mattr_accessor :stylesheets
|
4
|
+
self.stylesheets = %w(reset puffer)
|
5
|
+
|
6
|
+
mattr_accessor :javascripts
|
7
|
+
self.javascripts = %w(right right-calendar right-autocompleter rails puffer)
|
8
|
+
|
9
|
+
mattr_accessor :logo
|
10
|
+
self.logo = 'Puffer'
|
11
|
+
|
12
|
+
def self.setup
|
13
|
+
yield self
|
14
|
+
end
|
15
|
+
|
2
16
|
end
|
3
17
|
|
4
18
|
require 'puffer/engine'
|
@@ -7,10 +7,10 @@ module Puffer
|
|
7
7
|
extend ClassMethods
|
8
8
|
|
9
9
|
layout 'puffer'
|
10
|
-
helper
|
10
|
+
helper :puffer
|
11
11
|
helper_method :puffer?
|
12
12
|
|
13
|
-
|
13
|
+
view_paths_fallbacks :puffer
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -18,6 +18,12 @@ module Puffer
|
|
18
18
|
|
19
19
|
module ClassMethods
|
20
20
|
|
21
|
+
def view_paths_fallbacks *args
|
22
|
+
temp = Puffer::PathSet.new view_paths
|
23
|
+
temp._fallbacks = args.flatten
|
24
|
+
self.view_paths = temp
|
25
|
+
end
|
26
|
+
|
21
27
|
def puffer?; true; end
|
22
28
|
|
23
29
|
end
|
@@ -36,7 +36,7 @@ module Puffer
|
|
36
36
|
end
|
37
37
|
|
38
38
|
resource = ActionDispatch::Routing::Mapper::Resources::SingletonResource.new(resources.pop, options)
|
39
|
-
controller = "#{[@scope[:module], resource.controller].compact.join("/")}_controller".
|
39
|
+
controller = "#{[@scope[:module], resource.controller].compact.join("/")}_controller".camelize.constantize rescue nil
|
40
40
|
|
41
41
|
return if controller.nil? || (controller && !controller.puffer?)
|
42
42
|
|
@@ -95,7 +95,7 @@ module Puffer
|
|
95
95
|
end
|
96
96
|
|
97
97
|
resource = ActionDispatch::Routing::Mapper::Resources::Resource.new(resources.pop, options)
|
98
|
-
controller = "#{[@scope[:module], resource.controller].compact.join("/")}_controller".
|
98
|
+
controller = "#{[@scope[:module], resource.controller].compact.join("/")}_controller".camelize.constantize rescue nil
|
99
99
|
|
100
100
|
return if controller.nil? || (controller && !controller.puffer?)
|
101
101
|
|
data/lib/puffer/inputs.rb
CHANGED
@@ -14,7 +14,7 @@ module Puffer
|
|
14
14
|
map_type :date, :time, :datetime, :timestamp, :to => Puffer::Inputs::DateTime
|
15
15
|
|
16
16
|
def self.map_field field
|
17
|
-
mappings[field.type] || ("Puffer::Inputs::#{field.type.to_s.
|
17
|
+
mappings[field.type] || ("Puffer::Inputs::#{field.type.to_s.camelize}".constantize rescue Puffer::Inputs::Base)
|
18
18
|
end
|
19
19
|
|
20
20
|
end
|
data/lib/puffer/path_set.rb
CHANGED
@@ -1,16 +1,23 @@
|
|
1
1
|
module Puffer
|
2
2
|
class PathSet < ::ActionView::PathSet
|
3
3
|
|
4
|
+
class_attribute :_fallbacks
|
5
|
+
self._fallbacks = []
|
6
|
+
|
4
7
|
def find(path, prefix = nil, partial = false, details = {}, key = nil)
|
8
|
+
prefixes = [prefix].concat _fallbacks
|
9
|
+
paths = prefixes.map {|prefix| "#{prefix}/#{path}"}.join(', ')
|
10
|
+
|
5
11
|
begin
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
rescue ::ActionView::MissingTemplate => ee
|
11
|
-
raise e
|
12
|
+
template = begin
|
13
|
+
super(path, prefixes.shift.to_s, partial, details, key)
|
14
|
+
rescue ::ActionView::MissingTemplate => e
|
15
|
+
nil
|
12
16
|
end
|
13
|
-
end
|
17
|
+
end until prefixes.empty? || template
|
18
|
+
|
19
|
+
raise ::ActionView::MissingTemplate.new(self, paths, details, partial) unless template
|
20
|
+
template
|
14
21
|
end
|
15
22
|
|
16
23
|
end
|
data/lib/puffer/resource.rb
CHANGED
@@ -15,7 +15,7 @@ module Puffer
|
|
15
15
|
|
16
16
|
def initialize params, request = nil
|
17
17
|
@action = params.delete :action
|
18
|
-
@controller = "#{params[:controller]}_controller".
|
18
|
+
@controller = "#{params[:controller]}_controller".camelize.constantize
|
19
19
|
@controller_name = controller.controller_name
|
20
20
|
controller_segments = params.delete(:controller).split('/')
|
21
21
|
@prefix = controller_segments.first
|
data/puffer.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{puffer}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.12"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["pyromaniac"]
|
12
|
-
s.date = %q{2011-02-
|
12
|
+
s.date = %q{2011-02-05}
|
13
13
|
s.description = %q{In Soviet Russia puffer admins you}
|
14
14
|
s.email = %q{kinwizard@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -47,29 +47,11 @@ Gem::Specification.new do |s|
|
|
47
47
|
"lib/generators/puffer/install/USAGE",
|
48
48
|
"lib/generators/puffer/install/install_generator.rb",
|
49
49
|
"lib/generators/puffer/install/templates/puffer.rb",
|
50
|
-
"lib/generators/puffer/install/templates/puffer/javascripts/
|
51
|
-
"lib/generators/puffer/install/templates/puffer/javascripts/rails
|
52
|
-
"lib/generators/puffer/install/templates/puffer/javascripts/right-autocompleter-src.js",
|
50
|
+
"lib/generators/puffer/install/templates/puffer/javascripts/puffer.js",
|
51
|
+
"lib/generators/puffer/install/templates/puffer/javascripts/rails.js",
|
53
52
|
"lib/generators/puffer/install/templates/puffer/javascripts/right-autocompleter.js",
|
54
|
-
"lib/generators/puffer/install/templates/puffer/javascripts/right-autocompleter.js.gz",
|
55
|
-
"lib/generators/puffer/install/templates/puffer/javascripts/right-calendar-src.js",
|
56
53
|
"lib/generators/puffer/install/templates/puffer/javascripts/right-calendar.js",
|
57
|
-
"lib/generators/puffer/install/templates/puffer/javascripts/right-calendar.js.gz",
|
58
|
-
"lib/generators/puffer/install/templates/puffer/javascripts/right-in-edit-src.js",
|
59
|
-
"lib/generators/puffer/install/templates/puffer/javascripts/right-in-edit.js",
|
60
|
-
"lib/generators/puffer/install/templates/puffer/javascripts/right-in-edit.js.gz",
|
61
|
-
"lib/generators/puffer/install/templates/puffer/javascripts/right-lightbox-src.js",
|
62
|
-
"lib/generators/puffer/install/templates/puffer/javascripts/right-lightbox.js",
|
63
|
-
"lib/generators/puffer/install/templates/puffer/javascripts/right-lightbox.js.gz",
|
64
|
-
"lib/generators/puffer/install/templates/puffer/javascripts/right-sortable-src.js",
|
65
|
-
"lib/generators/puffer/install/templates/puffer/javascripts/right-sortable.js",
|
66
|
-
"lib/generators/puffer/install/templates/puffer/javascripts/right-sortable.js.gz",
|
67
|
-
"lib/generators/puffer/install/templates/puffer/javascripts/right-src.js",
|
68
|
-
"lib/generators/puffer/install/templates/puffer/javascripts/right-tabs-src.js",
|
69
|
-
"lib/generators/puffer/install/templates/puffer/javascripts/right-tabs.js",
|
70
|
-
"lib/generators/puffer/install/templates/puffer/javascripts/right-tabs.js.gz",
|
71
54
|
"lib/generators/puffer/install/templates/puffer/javascripts/right.js",
|
72
|
-
"lib/generators/puffer/install/templates/puffer/javascripts/right.js.gz",
|
73
55
|
"lib/generators/puffer/install/templates/puffer/stylesheets/puffer.css",
|
74
56
|
"lib/generators/puffer/install/templates/puffer/stylesheets/reset.css",
|
75
57
|
"lib/puffer.rb",
|
@@ -132,10 +114,10 @@ Gem::Specification.new do |s|
|
|
132
114
|
"spec/dummy/config/initializers/backtrace_silencers.rb",
|
133
115
|
"spec/dummy/config/initializers/inflections.rb",
|
134
116
|
"spec/dummy/config/initializers/mime_types.rb",
|
117
|
+
"spec/dummy/config/initializers/puffer.rb",
|
135
118
|
"spec/dummy/config/initializers/secret_token.rb",
|
136
119
|
"spec/dummy/config/initializers/session_store.rb",
|
137
120
|
"spec/dummy/config/locales/en.yml",
|
138
|
-
"spec/dummy/config/puffer.rb",
|
139
121
|
"spec/dummy/config/routes.rb",
|
140
122
|
"spec/dummy/db/migrate/20100930132559_create_admin_users.rb",
|
141
123
|
"spec/dummy/db/migrate/20100930132656_create_admin_posts.rb",
|
@@ -156,29 +138,11 @@ Gem::Specification.new do |s|
|
|
156
138
|
"spec/dummy/public/javascripts/effects.js",
|
157
139
|
"spec/dummy/public/javascripts/prototype.js",
|
158
140
|
"spec/dummy/public/javascripts/rails.js",
|
159
|
-
"spec/dummy/public/puffer/javascripts/
|
160
|
-
"spec/dummy/public/puffer/javascripts/rails
|
161
|
-
"spec/dummy/public/puffer/javascripts/right-autocompleter-src.js",
|
141
|
+
"spec/dummy/public/puffer/javascripts/puffer.js",
|
142
|
+
"spec/dummy/public/puffer/javascripts/rails.js",
|
162
143
|
"spec/dummy/public/puffer/javascripts/right-autocompleter.js",
|
163
|
-
"spec/dummy/public/puffer/javascripts/right-autocompleter.js.gz",
|
164
|
-
"spec/dummy/public/puffer/javascripts/right-calendar-src.js",
|
165
144
|
"spec/dummy/public/puffer/javascripts/right-calendar.js",
|
166
|
-
"spec/dummy/public/puffer/javascripts/right-calendar.js.gz",
|
167
|
-
"spec/dummy/public/puffer/javascripts/right-in-edit-src.js",
|
168
|
-
"spec/dummy/public/puffer/javascripts/right-in-edit.js",
|
169
|
-
"spec/dummy/public/puffer/javascripts/right-in-edit.js.gz",
|
170
|
-
"spec/dummy/public/puffer/javascripts/right-lightbox-src.js",
|
171
|
-
"spec/dummy/public/puffer/javascripts/right-lightbox.js",
|
172
|
-
"spec/dummy/public/puffer/javascripts/right-lightbox.js.gz",
|
173
|
-
"spec/dummy/public/puffer/javascripts/right-sortable-src.js",
|
174
|
-
"spec/dummy/public/puffer/javascripts/right-sortable.js",
|
175
|
-
"spec/dummy/public/puffer/javascripts/right-sortable.js.gz",
|
176
|
-
"spec/dummy/public/puffer/javascripts/right-src.js",
|
177
|
-
"spec/dummy/public/puffer/javascripts/right-tabs-src.js",
|
178
|
-
"spec/dummy/public/puffer/javascripts/right-tabs.js",
|
179
|
-
"spec/dummy/public/puffer/javascripts/right-tabs.js.gz",
|
180
145
|
"spec/dummy/public/puffer/javascripts/right.js",
|
181
|
-
"spec/dummy/public/puffer/javascripts/right.js.gz",
|
182
146
|
"spec/dummy/public/puffer/stylesheets/puffer.css",
|
183
147
|
"spec/dummy/public/puffer/stylesheets/reset.css",
|
184
148
|
"spec/dummy/public/stylesheets/.gitkeep",
|
@@ -227,9 +191,9 @@ Gem::Specification.new do |s|
|
|
227
191
|
"spec/dummy/config/initializers/backtrace_silencers.rb",
|
228
192
|
"spec/dummy/config/initializers/inflections.rb",
|
229
193
|
"spec/dummy/config/initializers/mime_types.rb",
|
194
|
+
"spec/dummy/config/initializers/puffer.rb",
|
230
195
|
"spec/dummy/config/initializers/secret_token.rb",
|
231
196
|
"spec/dummy/config/initializers/session_store.rb",
|
232
|
-
"spec/dummy/config/puffer.rb",
|
233
197
|
"spec/dummy/config/routes.rb",
|
234
198
|
"spec/dummy/db/migrate/20100930132559_create_admin_users.rb",
|
235
199
|
"spec/dummy/db/migrate/20100930132656_create_admin_posts.rb",
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Use this to configure puffer
|
2
|
+
Puffer.setup do |config|
|
3
|
+
|
4
|
+
# Add additional javascript and stylesheets files to puffer.html.erb layouts
|
5
|
+
# All additional paths should be relative to rails_app/public/puffer/(javascripts|stylesheets)
|
6
|
+
# config.stylesheets += %w(path/to/my/stylesheet)
|
7
|
+
# config.javascripts += %w(path/to/my/javascript)
|
8
|
+
|
9
|
+
# Puffer logo text. At the top-left of the layout. Default - `Puffer`
|
10
|
+
# config.logo = 'My cool application'
|
11
|
+
|
12
|
+
end
|
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puffer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 12
|
10
|
+
version: 0.0.12
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- pyromaniac
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-05 00:00:00 +03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -221,29 +221,11 @@ files:
|
|
221
221
|
- lib/generators/puffer/install/USAGE
|
222
222
|
- lib/generators/puffer/install/install_generator.rb
|
223
223
|
- lib/generators/puffer/install/templates/puffer.rb
|
224
|
-
- lib/generators/puffer/install/templates/puffer/javascripts/
|
225
|
-
- lib/generators/puffer/install/templates/puffer/javascripts/rails
|
226
|
-
- lib/generators/puffer/install/templates/puffer/javascripts/right-autocompleter-src.js
|
224
|
+
- lib/generators/puffer/install/templates/puffer/javascripts/puffer.js
|
225
|
+
- lib/generators/puffer/install/templates/puffer/javascripts/rails.js
|
227
226
|
- lib/generators/puffer/install/templates/puffer/javascripts/right-autocompleter.js
|
228
|
-
- lib/generators/puffer/install/templates/puffer/javascripts/right-autocompleter.js.gz
|
229
|
-
- lib/generators/puffer/install/templates/puffer/javascripts/right-calendar-src.js
|
230
227
|
- lib/generators/puffer/install/templates/puffer/javascripts/right-calendar.js
|
231
|
-
- lib/generators/puffer/install/templates/puffer/javascripts/right-calendar.js.gz
|
232
|
-
- lib/generators/puffer/install/templates/puffer/javascripts/right-in-edit-src.js
|
233
|
-
- lib/generators/puffer/install/templates/puffer/javascripts/right-in-edit.js
|
234
|
-
- lib/generators/puffer/install/templates/puffer/javascripts/right-in-edit.js.gz
|
235
|
-
- lib/generators/puffer/install/templates/puffer/javascripts/right-lightbox-src.js
|
236
|
-
- lib/generators/puffer/install/templates/puffer/javascripts/right-lightbox.js
|
237
|
-
- lib/generators/puffer/install/templates/puffer/javascripts/right-lightbox.js.gz
|
238
|
-
- lib/generators/puffer/install/templates/puffer/javascripts/right-sortable-src.js
|
239
|
-
- lib/generators/puffer/install/templates/puffer/javascripts/right-sortable.js
|
240
|
-
- lib/generators/puffer/install/templates/puffer/javascripts/right-sortable.js.gz
|
241
|
-
- lib/generators/puffer/install/templates/puffer/javascripts/right-src.js
|
242
|
-
- lib/generators/puffer/install/templates/puffer/javascripts/right-tabs-src.js
|
243
|
-
- lib/generators/puffer/install/templates/puffer/javascripts/right-tabs.js
|
244
|
-
- lib/generators/puffer/install/templates/puffer/javascripts/right-tabs.js.gz
|
245
228
|
- lib/generators/puffer/install/templates/puffer/javascripts/right.js
|
246
|
-
- lib/generators/puffer/install/templates/puffer/javascripts/right.js.gz
|
247
229
|
- lib/generators/puffer/install/templates/puffer/stylesheets/puffer.css
|
248
230
|
- lib/generators/puffer/install/templates/puffer/stylesheets/reset.css
|
249
231
|
- lib/puffer.rb
|
@@ -306,10 +288,10 @@ files:
|
|
306
288
|
- spec/dummy/config/initializers/backtrace_silencers.rb
|
307
289
|
- spec/dummy/config/initializers/inflections.rb
|
308
290
|
- spec/dummy/config/initializers/mime_types.rb
|
291
|
+
- spec/dummy/config/initializers/puffer.rb
|
309
292
|
- spec/dummy/config/initializers/secret_token.rb
|
310
293
|
- spec/dummy/config/initializers/session_store.rb
|
311
294
|
- spec/dummy/config/locales/en.yml
|
312
|
-
- spec/dummy/config/puffer.rb
|
313
295
|
- spec/dummy/config/routes.rb
|
314
296
|
- spec/dummy/db/migrate/20100930132559_create_admin_users.rb
|
315
297
|
- spec/dummy/db/migrate/20100930132656_create_admin_posts.rb
|
@@ -330,29 +312,11 @@ files:
|
|
330
312
|
- spec/dummy/public/javascripts/effects.js
|
331
313
|
- spec/dummy/public/javascripts/prototype.js
|
332
314
|
- spec/dummy/public/javascripts/rails.js
|
333
|
-
- spec/dummy/public/puffer/javascripts/
|
334
|
-
- spec/dummy/public/puffer/javascripts/rails
|
335
|
-
- spec/dummy/public/puffer/javascripts/right-autocompleter-src.js
|
315
|
+
- spec/dummy/public/puffer/javascripts/puffer.js
|
316
|
+
- spec/dummy/public/puffer/javascripts/rails.js
|
336
317
|
- spec/dummy/public/puffer/javascripts/right-autocompleter.js
|
337
|
-
- spec/dummy/public/puffer/javascripts/right-autocompleter.js.gz
|
338
|
-
- spec/dummy/public/puffer/javascripts/right-calendar-src.js
|
339
318
|
- spec/dummy/public/puffer/javascripts/right-calendar.js
|
340
|
-
- spec/dummy/public/puffer/javascripts/right-calendar.js.gz
|
341
|
-
- spec/dummy/public/puffer/javascripts/right-in-edit-src.js
|
342
|
-
- spec/dummy/public/puffer/javascripts/right-in-edit.js
|
343
|
-
- spec/dummy/public/puffer/javascripts/right-in-edit.js.gz
|
344
|
-
- spec/dummy/public/puffer/javascripts/right-lightbox-src.js
|
345
|
-
- spec/dummy/public/puffer/javascripts/right-lightbox.js
|
346
|
-
- spec/dummy/public/puffer/javascripts/right-lightbox.js.gz
|
347
|
-
- spec/dummy/public/puffer/javascripts/right-sortable-src.js
|
348
|
-
- spec/dummy/public/puffer/javascripts/right-sortable.js
|
349
|
-
- spec/dummy/public/puffer/javascripts/right-sortable.js.gz
|
350
|
-
- spec/dummy/public/puffer/javascripts/right-src.js
|
351
|
-
- spec/dummy/public/puffer/javascripts/right-tabs-src.js
|
352
|
-
- spec/dummy/public/puffer/javascripts/right-tabs.js
|
353
|
-
- spec/dummy/public/puffer/javascripts/right-tabs.js.gz
|
354
319
|
- spec/dummy/public/puffer/javascripts/right.js
|
355
|
-
- spec/dummy/public/puffer/javascripts/right.js.gz
|
356
320
|
- spec/dummy/public/puffer/stylesheets/puffer.css
|
357
321
|
- spec/dummy/public/puffer/stylesheets/reset.css
|
358
322
|
- spec/dummy/public/stylesheets/.gitkeep
|
@@ -430,9 +394,9 @@ test_files:
|
|
430
394
|
- spec/dummy/config/initializers/backtrace_silencers.rb
|
431
395
|
- spec/dummy/config/initializers/inflections.rb
|
432
396
|
- spec/dummy/config/initializers/mime_types.rb
|
397
|
+
- spec/dummy/config/initializers/puffer.rb
|
433
398
|
- spec/dummy/config/initializers/secret_token.rb
|
434
399
|
- spec/dummy/config/initializers/session_store.rb
|
435
|
-
- spec/dummy/config/puffer.rb
|
436
400
|
- spec/dummy/config/routes.rb
|
437
401
|
- spec/dummy/db/migrate/20100930132559_create_admin_users.rb
|
438
402
|
- spec/dummy/db/migrate/20100930132656_create_admin_posts.rb
|
@@ -1,621 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* RightJS-UI: Autocompleter
|
3
|
-
* http://rightjs.org/ui/autocompleter
|
4
|
-
*
|
5
|
-
* Copyright (C) 2010 Nikolay Nemshilov
|
6
|
-
*/
|
7
|
-
var Autocompleter = RightJS.Autocompleter = (function(document, RightJS) {
|
8
|
-
/**
|
9
|
-
* This module defines the basic widgets constructor
|
10
|
-
* it creates an abstract proxy with the common functionality
|
11
|
-
* which then we reuse and override in the actual widgets
|
12
|
-
*
|
13
|
-
* Copyright (C) 2010-2011 Nikolay Nemshilov
|
14
|
-
*/
|
15
|
-
|
16
|
-
/**
|
17
|
-
* Autocompleter initializer
|
18
|
-
*
|
19
|
-
* Copyright (C) 2010 Nikolay Nemshilov
|
20
|
-
*/
|
21
|
-
var R = RightJS,
|
22
|
-
$ = RightJS.$,
|
23
|
-
$w = RightJS.$w,
|
24
|
-
$E = RightJS.$E,
|
25
|
-
Xhr = RightJS.Xhr,
|
26
|
-
RegExp = RightJS.RegExp,
|
27
|
-
isArray = RightJS.isArray;
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
/**
|
37
|
-
* The widget units constructor
|
38
|
-
*
|
39
|
-
* @param String tag-name or Object methods
|
40
|
-
* @param Object methods
|
41
|
-
* @return Widget wrapper
|
42
|
-
*/
|
43
|
-
function Widget(tag_name, methods) {
|
44
|
-
if (!methods) {
|
45
|
-
methods = tag_name;
|
46
|
-
tag_name = 'DIV';
|
47
|
-
}
|
48
|
-
|
49
|
-
/**
|
50
|
-
* An Abstract Widget Unit
|
51
|
-
*
|
52
|
-
* Copyright (C) 2010 Nikolay Nemshilov
|
53
|
-
*/
|
54
|
-
var AbstractWidget = new RightJS.Class(RightJS.Element.Wrappers[tag_name] || RightJS.Element, {
|
55
|
-
/**
|
56
|
-
* The common constructor
|
57
|
-
*
|
58
|
-
* @param Object options
|
59
|
-
* @param String optional tag name
|
60
|
-
* @return void
|
61
|
-
*/
|
62
|
-
initialize: function(key, options) {
|
63
|
-
this.key = key;
|
64
|
-
var args = [{'class': 'rui-' + key}];
|
65
|
-
|
66
|
-
// those two have different constructors
|
67
|
-
if (!(this instanceof RightJS.Input || this instanceof RightJS.Form)) {
|
68
|
-
args.unshift(tag_name);
|
69
|
-
}
|
70
|
-
this.$super.apply(this, args);
|
71
|
-
|
72
|
-
if (RightJS.isString(options)) {
|
73
|
-
options = RightJS.$(options);
|
74
|
-
}
|
75
|
-
|
76
|
-
// if the options is another element then
|
77
|
-
// try to dynamically rewrap it with our widget
|
78
|
-
if (options instanceof RightJS.Element) {
|
79
|
-
this._ = options._;
|
80
|
-
if ('$listeners' in options) {
|
81
|
-
options.$listeners = options.$listeners;
|
82
|
-
}
|
83
|
-
options = {};
|
84
|
-
}
|
85
|
-
this.setOptions(options, this);
|
86
|
-
|
87
|
-
return (RightJS.Wrapper.Cache[RightJS.$uid(this._)] = this);
|
88
|
-
},
|
89
|
-
|
90
|
-
// protected
|
91
|
-
|
92
|
-
/**
|
93
|
-
* Catches the options
|
94
|
-
*
|
95
|
-
* @param Object user-options
|
96
|
-
* @param Element element with contextual options
|
97
|
-
* @return void
|
98
|
-
*/
|
99
|
-
setOptions: function(options, element) {
|
100
|
-
element = element || this;
|
101
|
-
RightJS.Options.setOptions.call(this,
|
102
|
-
RightJS.Object.merge(options, eval("("+(
|
103
|
-
element.get('data-'+ this.key) || '{}'
|
104
|
-
)+")"))
|
105
|
-
);
|
106
|
-
return this;
|
107
|
-
}
|
108
|
-
});
|
109
|
-
|
110
|
-
/**
|
111
|
-
* Creating the actual widget class
|
112
|
-
*
|
113
|
-
*/
|
114
|
-
var Klass = new RightJS.Class(AbstractWidget, methods);
|
115
|
-
|
116
|
-
// creating the widget related shortcuts
|
117
|
-
RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || []);
|
118
|
-
|
119
|
-
return Klass;
|
120
|
-
}
|
121
|
-
|
122
|
-
|
123
|
-
/**
|
124
|
-
* A shared module to create textual spinners
|
125
|
-
*
|
126
|
-
* Copyright (C) 2010-2011 Nikolay Nemshilov
|
127
|
-
*/
|
128
|
-
var Spinner = new RightJS.Class(RightJS.Element, {
|
129
|
-
/**
|
130
|
-
* Constructor
|
131
|
-
*
|
132
|
-
* @param Number optional spinner size (4 by default)
|
133
|
-
* @return void
|
134
|
-
*/
|
135
|
-
initialize: function(size) {
|
136
|
-
this.$super('div', {'class': 'rui-spinner'});
|
137
|
-
this.dots = [];
|
138
|
-
|
139
|
-
for (var i=0; i < (size || 4); i++) {
|
140
|
-
this.dots.push(new RightJS.Element('div'));
|
141
|
-
}
|
142
|
-
|
143
|
-
this.dots[0].addClass('glowing');
|
144
|
-
this.insert(this.dots);
|
145
|
-
RightJS(this.shift).bind(this).periodical(300);
|
146
|
-
},
|
147
|
-
|
148
|
-
/**
|
149
|
-
* Shifts the spinner elements
|
150
|
-
*
|
151
|
-
* @return void
|
152
|
-
*/
|
153
|
-
shift: function() {
|
154
|
-
if (this.visible()) {
|
155
|
-
var dot = this.dots.pop();
|
156
|
-
this.dots.unshift(dot);
|
157
|
-
this.insert(dot, 'top');
|
158
|
-
}
|
159
|
-
}
|
160
|
-
});
|
161
|
-
|
162
|
-
|
163
|
-
/**
|
164
|
-
* A shared module that toggles a widget visibility status
|
165
|
-
* in a uniformed way according to the options settings
|
166
|
-
*
|
167
|
-
* Copyright (C) 2010-2011 Nikolay Nemshilov
|
168
|
-
*/
|
169
|
-
var Toggler = {
|
170
|
-
/**
|
171
|
-
* Shows the element
|
172
|
-
*
|
173
|
-
* @param String fx-name
|
174
|
-
* @param Object fx-options
|
175
|
-
* @return Element this
|
176
|
-
*/
|
177
|
-
show: function(fx_name, fx_options) {
|
178
|
-
this.constructor.current = this;
|
179
|
-
return Toggler_toggle(this, 'show', fx_name, fx_options);
|
180
|
-
},
|
181
|
-
|
182
|
-
/**
|
183
|
-
* Hides the element
|
184
|
-
*
|
185
|
-
* @param String fx-name
|
186
|
-
* @param Object fx-options
|
187
|
-
* @return Element this
|
188
|
-
*/
|
189
|
-
hide: function(fx_name, fx_options) {
|
190
|
-
this.constructor.current = null;
|
191
|
-
return Toggler_toggle(this, 'show', fx_name, fx_options);
|
192
|
-
},
|
193
|
-
|
194
|
-
/**
|
195
|
-
* Toggles the widget at the given element
|
196
|
-
*
|
197
|
-
* @param Element the related element
|
198
|
-
* @param String position right/bottom (bottom is the default)
|
199
|
-
* @param Boolean marker if the element should be resized to the element size
|
200
|
-
* @return Widget this
|
201
|
-
*/
|
202
|
-
showAt: function(element, where, resize) {
|
203
|
-
this.hide(null).shownAt = element = RightJS.$(element);
|
204
|
-
|
205
|
-
// moves this element at the given one
|
206
|
-
Toggler_re_position.call(this, element, where, resize);
|
207
|
-
|
208
|
-
return this.show();
|
209
|
-
},
|
210
|
-
|
211
|
-
/**
|
212
|
-
* Toggles the widget at the given element
|
213
|
-
*
|
214
|
-
* @param Element the related element
|
215
|
-
* @param String position top/left/right/bottom (bottom is the default)
|
216
|
-
* @param Boolean marker if the element should be resized to the element size
|
217
|
-
* @return Widget this
|
218
|
-
*/
|
219
|
-
toggleAt: function(element, where, resize) {
|
220
|
-
return this.hidden() ? this.showAt(element, where, resize) : this.hide();
|
221
|
-
}
|
222
|
-
};
|
223
|
-
|
224
|
-
|
225
|
-
/**
|
226
|
-
* toggles the element's state according to the current settings
|
227
|
-
*
|
228
|
-
* @param event String 'show' or 'hide' the event name
|
229
|
-
* @param String an optional fx-name
|
230
|
-
* @param Object an optional fx-options hash
|
231
|
-
* @return void
|
232
|
-
*/
|
233
|
-
function Toggler_toggle(element, event, fx_name, fx_options) {
|
234
|
-
if (RightJS.Fx) {
|
235
|
-
if (fx_name === undefined) {
|
236
|
-
fx_name = element.options.fxName;
|
237
|
-
|
238
|
-
if (fx_options === undefined) {
|
239
|
-
fx_options = {
|
240
|
-
duration: element.options.fxDuration,
|
241
|
-
onFinish: RightJS(element.fire).bind(element, event)
|
242
|
-
};
|
243
|
-
|
244
|
-
// hide on double time
|
245
|
-
if (event === 'hide') {
|
246
|
-
fx_options.duration = (RightJS.Fx.Durations[fx_options.duration] ||
|
247
|
-
fx_options.duration) / 2;
|
248
|
-
}
|
249
|
-
}
|
250
|
-
}
|
251
|
-
}
|
252
|
-
|
253
|
-
// manually trigger the event if no fx were specified
|
254
|
-
if (!RightJS.Fx || !fx_name) { element.fire(event); }
|
255
|
-
|
256
|
-
return element.$super(fx_name, fx_options);
|
257
|
-
}
|
258
|
-
|
259
|
-
/**
|
260
|
-
* Relatively positions the current element
|
261
|
-
* against the specified one
|
262
|
-
*
|
263
|
-
* NOTE: this function is called in a context
|
264
|
-
* of another element
|
265
|
-
*
|
266
|
-
* @param Element the target element
|
267
|
-
* @param String position 'right' or 'bottom'
|
268
|
-
* @param Boolean if `true` then the element size will be adjusted
|
269
|
-
* @return void
|
270
|
-
*/
|
271
|
-
function Toggler_re_position(element, where, resize) {
|
272
|
-
var anchor = this.reAnchor || (this.reAnchor =
|
273
|
-
new RightJS.Element('div', {'class': 'rui-re-anchor'}))
|
274
|
-
.insert(this),
|
275
|
-
|
276
|
-
pos = anchor.insertTo(element, 'after').position(),
|
277
|
-
dims = element.dimensions(), target = this,
|
278
|
-
|
279
|
-
border_top = parseInt(element.getStyle('borderTopWidth')),
|
280
|
-
border_left = parseInt(element.getStyle('borderLeftWidth')),
|
281
|
-
border_right = parseInt(element.getStyle('borderRightWidth')),
|
282
|
-
border_bottom = parseInt(element.getStyle('borderBottomWidth')),
|
283
|
-
|
284
|
-
top = dims.top - pos.y + border_top,
|
285
|
-
left = dims.left - pos.x + border_left,
|
286
|
-
width = dims.width - border_left - border_right,
|
287
|
-
height = dims.height - border_top - border_bottom;
|
288
|
-
|
289
|
-
// making the element to appear so we could read it's sizes
|
290
|
-
target.setStyle('visibility:hidden').show(null);
|
291
|
-
|
292
|
-
if (where === 'right') {
|
293
|
-
left += width - target.size().x;
|
294
|
-
} else { // bottom
|
295
|
-
top += height;
|
296
|
-
}
|
297
|
-
|
298
|
-
target.moveTo(left, top);
|
299
|
-
|
300
|
-
if (resize) {
|
301
|
-
if (where === 'left' || where === 'right') {
|
302
|
-
target.setHeight(height);
|
303
|
-
} else {
|
304
|
-
target.setWidth(width);
|
305
|
-
}
|
306
|
-
}
|
307
|
-
|
308
|
-
// rolling the invisibility back
|
309
|
-
target.setStyle('visibility:visible').hide(null);
|
310
|
-
}
|
311
|
-
|
312
|
-
/**
|
313
|
-
* The RightJS UI Autocompleter unit base class
|
314
|
-
*
|
315
|
-
* Copyright (C) 2009-2011 Nikolay Nemshilov
|
316
|
-
*/
|
317
|
-
var Autocompleter = new Widget('UL', {
|
318
|
-
include: Toggler,
|
319
|
-
|
320
|
-
extend: {
|
321
|
-
version: '2.2.0',
|
322
|
-
|
323
|
-
EVENTS: $w('show hide update load select done'),
|
324
|
-
|
325
|
-
Options: {
|
326
|
-
url: document.location.href,
|
327
|
-
param: 'search',
|
328
|
-
method: 'get',
|
329
|
-
|
330
|
-
minLength: 1, // the minimal length when it starts work
|
331
|
-
threshold: 200, // the typing pause threshold
|
332
|
-
|
333
|
-
cache: true, // use the results cache
|
334
|
-
local: null, // an optional local search results list
|
335
|
-
|
336
|
-
fxName: 'slide', // list appearance fx name
|
337
|
-
fxDuration: 'short', // list appearance fx duration
|
338
|
-
|
339
|
-
spinner: 'native', // spinner element reference
|
340
|
-
|
341
|
-
cssRule: 'input[data-autocompleter]' // the auto-initialization css-rule
|
342
|
-
}
|
343
|
-
},
|
344
|
-
|
345
|
-
/**
|
346
|
-
* basic constructor
|
347
|
-
*
|
348
|
-
* @param mixed the input element reference, a string id or the element instance
|
349
|
-
* @param Object options
|
350
|
-
*/
|
351
|
-
initialize: function(input, options) {
|
352
|
-
this.input = $(input); // KEEP IT before the super call
|
353
|
-
|
354
|
-
this
|
355
|
-
.$super('autocompleter', options)
|
356
|
-
.addClass('rui-dd-menu')
|
357
|
-
.onMousedown(this.clicked);
|
358
|
-
|
359
|
-
this.input.autocompleter = this;
|
360
|
-
},
|
361
|
-
|
362
|
-
/**
|
363
|
-
* Destructor
|
364
|
-
*
|
365
|
-
* @return Autocompleter this
|
366
|
-
*/
|
367
|
-
destroy: function() {
|
368
|
-
delete(this.input.autocompleter);
|
369
|
-
return this;
|
370
|
-
},
|
371
|
-
|
372
|
-
/**
|
373
|
-
* picks the next item on the list
|
374
|
-
*
|
375
|
-
* @return Autocompleter this
|
376
|
-
*/
|
377
|
-
prev: function() {
|
378
|
-
return this.pick('prev');
|
379
|
-
},
|
380
|
-
|
381
|
-
/**
|
382
|
-
* picks the next item on the list
|
383
|
-
*
|
384
|
-
* @return Autocompleter this
|
385
|
-
*/
|
386
|
-
next: function() {
|
387
|
-
return this.pick('next');
|
388
|
-
},
|
389
|
-
|
390
|
-
/**
|
391
|
-
* triggers the done event, sets up the value and closes the list
|
392
|
-
*
|
393
|
-
* @return Autocompleter this
|
394
|
-
*/
|
395
|
-
done: function(current) {
|
396
|
-
current = current || this.first('li.current');
|
397
|
-
|
398
|
-
if (current) {
|
399
|
-
current.radioClass('current');
|
400
|
-
this.input.setValue(R(current.html()).stripTags());
|
401
|
-
this.fire('done');
|
402
|
-
}
|
403
|
-
|
404
|
-
return this.hide();
|
405
|
-
},
|
406
|
-
|
407
|
-
// protected
|
408
|
-
|
409
|
-
// preprocessing the urls a bit
|
410
|
-
setOptions: function(options) {
|
411
|
-
this.$super(options, this.input);
|
412
|
-
|
413
|
-
options = this.options;
|
414
|
-
|
415
|
-
// building the correct url template with a placeholder
|
416
|
-
if (!R(options.url).includes('%{search}')) {
|
417
|
-
options.url += (R(options.url).includes('?') ? '&' : '?') + options.param + '=%{search}';
|
418
|
-
}
|
419
|
-
},
|
420
|
-
|
421
|
-
// works with the 'prev' and 'next' methods
|
422
|
-
pick: function(which_one) {
|
423
|
-
var items = this.children(),
|
424
|
-
current = items.first('hasClass', 'current'),
|
425
|
-
index = items.indexOf(current);
|
426
|
-
|
427
|
-
if (which_one == 'prev') {
|
428
|
-
current = index < 1 ? items.last() : items[index < 0 ? 0 : (index-1)];
|
429
|
-
} else if (which_one == 'next') {
|
430
|
-
current = index < 0 || index == (items.length - 1) ?
|
431
|
-
items.first() : items[index + 1];
|
432
|
-
}
|
433
|
-
|
434
|
-
return this.fire('select', {item: current.radioClass('current')});
|
435
|
-
},
|
436
|
-
|
437
|
-
// handles mouse clicks on the list element
|
438
|
-
clicked: function(event) {
|
439
|
-
this.done(event.stop().find('li'));
|
440
|
-
},
|
441
|
-
|
442
|
-
// handles the key-press events
|
443
|
-
keypressed: function(event) {
|
444
|
-
if (this.input.value().length >= this.options.minLength) {
|
445
|
-
if (this.timeout) {
|
446
|
-
this.timeout.cancel();
|
447
|
-
}
|
448
|
-
this.timeout = R(this.trigger).bind(this).delay(this.options.threshold);
|
449
|
-
} else {
|
450
|
-
return this.hide();
|
451
|
-
}
|
452
|
-
},
|
453
|
-
|
454
|
-
// triggers the actual action
|
455
|
-
trigger: function() {
|
456
|
-
this.timeout = null;
|
457
|
-
|
458
|
-
this.cache = this.cache || {};
|
459
|
-
var search = this.input.value(), options = this.options;
|
460
|
-
|
461
|
-
if (search.length < options.minLength) { return this.hide(); }
|
462
|
-
|
463
|
-
if (this.cache[search]) {
|
464
|
-
this.suggest(this.cache[search], search);
|
465
|
-
} else if (isArray(options.local)) {
|
466
|
-
this.suggest(this.findLocal(search), search);
|
467
|
-
} else {
|
468
|
-
this.request = Xhr.load(options.url.replace('%{search}', encodeURIComponent(search)), {
|
469
|
-
method: options.method,
|
470
|
-
spinner: this.getSpinner(),
|
471
|
-
onComplete: R(function(response) {
|
472
|
-
this.fire('load').suggest(response.text, search);
|
473
|
-
}).bind(this)
|
474
|
-
});
|
475
|
-
}
|
476
|
-
},
|
477
|
-
|
478
|
-
// updates the suggestions list
|
479
|
-
suggest: function(result_text, search) {
|
480
|
-
// saving the result in cache
|
481
|
-
if (this.options.cache) {
|
482
|
-
this.cache[search] = result_text;
|
483
|
-
}
|
484
|
-
|
485
|
-
if (!R(result_text).blank()) {
|
486
|
-
this.update(result_text.replace(/<ul[^>]*>|<\/ul>/im, ''));
|
487
|
-
this.fire('update');
|
488
|
-
if (!this._connected || this.hidden()) {
|
489
|
-
this.showAt(this.input, 'bottom', 'resize');
|
490
|
-
this._connected = true;
|
491
|
-
}
|
492
|
-
} else {
|
493
|
-
this.hide();
|
494
|
-
}
|
495
|
-
|
496
|
-
return this;
|
497
|
-
},
|
498
|
-
|
499
|
-
// performs the locals search
|
500
|
-
findLocal: function(search) {
|
501
|
-
var regexp = new RegExp("("+RegExp.escape(search)+")", 'ig');
|
502
|
-
|
503
|
-
return R(this.options.local).map(function(option) {
|
504
|
-
if (option.match(regexp)) {
|
505
|
-
return '<li>'+ option.replace(regexp, '<strong>$1</strong>') +'</li>';
|
506
|
-
}
|
507
|
-
}).compact().join('');
|
508
|
-
},
|
509
|
-
|
510
|
-
// builds a native textual spinner if necessary
|
511
|
-
getSpinner: function() {
|
512
|
-
var options = this.options, spinner = options.spinner;
|
513
|
-
|
514
|
-
if (spinner == 'native') {
|
515
|
-
spinner = options.spinner = new Spinner(3).insertTo(this);
|
516
|
-
spinner.addClass('rui-autocompleter-spinner');
|
517
|
-
}
|
518
|
-
|
519
|
-
// positioning the native spinner
|
520
|
-
if (spinner instanceof Spinner) {
|
521
|
-
Toggler_re_position.call(spinner, this.input, 'right', 'resize');
|
522
|
-
}
|
523
|
-
|
524
|
-
return spinner;
|
525
|
-
}
|
526
|
-
});
|
527
|
-
|
528
|
-
|
529
|
-
/**
|
530
|
-
* The document events hooking
|
531
|
-
*
|
532
|
-
* Copyright (C) 2009-2010 Nikolay Nemshilov
|
533
|
-
*/
|
534
|
-
$(document).on({
|
535
|
-
/**
|
536
|
-
* Initializes autocompleters on-focus
|
537
|
-
*
|
538
|
-
* @param Event focus
|
539
|
-
* @return void
|
540
|
-
*/
|
541
|
-
focus: function(event) {
|
542
|
-
var target = event.target;
|
543
|
-
|
544
|
-
if (target && (target instanceof RightJS.Element) && (target.autocompleter || target.match(Autocompleter.Options.cssRule))) {
|
545
|
-
if (!target.autocompleter) {
|
546
|
-
new Autocompleter(target);
|
547
|
-
}
|
548
|
-
}
|
549
|
-
},
|
550
|
-
|
551
|
-
/**
|
552
|
-
* Hides autocompleters on-blur
|
553
|
-
*
|
554
|
-
* @param Event blur
|
555
|
-
* @return void
|
556
|
-
*/
|
557
|
-
blur: function(event) {
|
558
|
-
var autocompleter = event.target ? event.target.autocompleter : null;
|
559
|
-
|
560
|
-
if (autocompleter && autocompleter.visible()) {
|
561
|
-
autocompleter.hide();
|
562
|
-
}
|
563
|
-
},
|
564
|
-
|
565
|
-
/**
|
566
|
-
* Catching the basic keyboard events
|
567
|
-
* to navigate through the autocompletion list
|
568
|
-
*
|
569
|
-
* @param Event keydown
|
570
|
-
* @return void
|
571
|
-
*/
|
572
|
-
keydown: function(event) {
|
573
|
-
var autocompleter = event.target ? event.target.autocompleter : null;
|
574
|
-
|
575
|
-
if (autocompleter && autocompleter.visible()) {
|
576
|
-
var method_name = ({
|
577
|
-
27: 'hide', // Esc
|
578
|
-
38: 'prev', // Up
|
579
|
-
40: 'next', // Down
|
580
|
-
13: 'done' // Enter
|
581
|
-
})[event.keyCode];
|
582
|
-
|
583
|
-
if (method_name) {
|
584
|
-
event.stop();
|
585
|
-
autocompleter[method_name]();
|
586
|
-
}
|
587
|
-
}
|
588
|
-
},
|
589
|
-
|
590
|
-
/**
|
591
|
-
* Catches the input fields keyup events
|
592
|
-
* and tries to make the autocompleter to show some suggestions
|
593
|
-
*
|
594
|
-
* @param Event keyup
|
595
|
-
* @return void
|
596
|
-
*/
|
597
|
-
keyup: function(event) {
|
598
|
-
var autocompleter = event.target ? event.target.autocompleter : null;
|
599
|
-
|
600
|
-
if (autocompleter && !R([9, 27, 37, 38, 39, 40, 13]).include(event.keyCode)) {
|
601
|
-
autocompleter.keypressed(event);
|
602
|
-
}
|
603
|
-
}
|
604
|
-
});
|
605
|
-
(function() {
|
606
|
-
var style = document.createElement('style'),
|
607
|
-
rules = document.createTextNode(" *.rui-dd-menu, *.rui-dd-menu li{margin:0;padding:0;border:none;background:none;list-style:none;font-weight:normal;float:none} *.rui-dd-menu{display:none;position:absolute;z-index:9999;background:white;border:1px solid #BBB;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;box-shadow:#DDD .2em .2em .4em;-moz-box-shadow:#DDD .2em .2em .4em;-webkit-box-shadow:#DDD .2em .2em .4em} *.rui-dd-menu li{padding:.2em .4em;border-top:none;border-bottom:none;cursor:pointer} *.rui-dd-menu li.current{background:#DDD} *.rui-dd-menu li:hover{background:#EEE}dl.rui-dd-menu dt{padding:.3em .5em;cursor:default;font-weight:bold;font-style:italic;color:#444;background:#EEE}dl.rui-dd-menu dd li{padding-left:1.5em}div.rui-spinner,div.rui-spinner div{margin:0;padding:0;border:none;background:none;list-style:none;font-weight:normal;float:none;display:inline-block; *display:inline; *zoom:1;border-radius:.12em;-moz-border-radius:.12em;-webkit-border-radius:.12em}div.rui-spinner{text-align:center;white-space:nowrap;background:#EEE;border:1px solid #DDD;height:1.2em;padding:0 .2em}div.rui-spinner div{width:.4em;height:70%;background:#BBB;margin-left:1px}div.rui-spinner div:first-child{margin-left:0}div.rui-spinner div.glowing{background:#777}div.rui-re-anchor{margin:0;padding:0;background:none;border:none;float:none;display:inline;position:absolute;z-index:9999}.rui-autocompleter{border-top-color:#DDD !important;border-top-left-radius:0 !important;border-top-right-radius:0 !important;-moz-border-radius-topleft:0 !important;-moz-border-radius-topright:0 !important;-webkit-border-top-left-radius:0 !important;-webkit-border-top-right-radius:0 !important}.rui-autocompleter-spinner{border:none !important;background:none !important;position:absolute;z-index:9999}.rui-autocompleter-spinner div{margin-top:.2em !important; *margin-top:0.1em !important}");
|
608
|
-
|
609
|
-
style.type = 'text/css';
|
610
|
-
|
611
|
-
if(style.styleSheet) {
|
612
|
-
style.styleSheet.cssText = rules.nodeValue;
|
613
|
-
} else {
|
614
|
-
style.appendChild(rules);
|
615
|
-
}
|
616
|
-
|
617
|
-
document.getElementsByTagName('head')[0].appendChild(style);
|
618
|
-
})();
|
619
|
-
|
620
|
-
return Autocompleter;
|
621
|
-
})(document, RightJS);
|