district_cn_selector 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +27 -0
- data/.rspec +1 -0
- data/.travis.yml +14 -0
- data/Gemfile +37 -0
- data/LICENSE.txt +22 -0
- data/README.md +138 -0
- data/Rakefile +21 -0
- data/config/routes.rb +7 -0
- data/district_cn_selector.gemspec +27 -0
- data/lib/district_cn_selector.rb +22 -0
- data/lib/district_cn_selector/district_controller.rb +26 -0
- data/lib/district_cn_selector/district_select_helper.rb +46 -0
- data/lib/district_cn_selector/district_select_ul_helper.rb +48 -0
- data/lib/district_cn_selector/engine.rb +22 -0
- data/lib/district_cn_selector/helpers/form_builder.rb +13 -0
- data/lib/district_cn_selector/helpers/form_builder_extension.rb +49 -0
- data/lib/district_cn_selector/hooks/simple_form.rb +72 -0
- data/lib/district_cn_selector/selector.rb +202 -0
- data/lib/district_cn_selector/theme.rb +19 -0
- data/lib/district_cn_selector/version.rb +3 -0
- data/spec/controllers/district_cn_selector/district_controller_spec.rb +13 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +5 -0
- data/spec/dummy/app/assets/stylesheets/application.css.scss +31 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/home_controller.rb +7 -0
- data/spec/dummy/app/controllers/tests_controller.rb +10 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/company.rb +8 -0
- data/spec/dummy/app/views/home/index.html.erb +31 -0
- data/spec/dummy/app/views/home/select2_backup.html.erb +49 -0
- data/spec/dummy/app/views/layouts/application.html.erb +15 -0
- data/spec/dummy/app/views/tests/1.html.erb +8 -0
- data/spec/dummy/app/views/tests/2.html.erb +9 -0
- data/spec/dummy/app/views/tests/3.html.erb +7 -0
- data/spec/dummy/app/views/tests/4.html.erb +7 -0
- data/spec/dummy/app/views/tests/5.html.erb +7 -0
- data/spec/dummy/app/views/tests/6.html.erb +7 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +75 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +16 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/simple_form.rb +142 -0
- data/spec/dummy/config/initializers/simple_form_bootstrap.rb +45 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/active_record.zh-CN.yml +11 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/locales/simple_form.en.yml +26 -0
- data/spec/dummy/config/routes.rb +5 -0
- data/spec/dummy/db/migrate/20130717055253_create_companies.rb +10 -0
- data/spec/dummy/db/schema.rb +24 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/area_select_cn/area-bg1.jpg +0 -0
- data/spec/dummy/public/area_select_cn/area-bg2.jpg +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/.gitkeep +0 -0
- data/spec/features/visit_testpage_spec.rb +93 -0
- data/spec/helpers/form_spec.rb +106 -0
- data/spec/helpers/simple_form_spec.rb +101 -0
- data/spec/spec_helper.rb +48 -0
- data/spec/support/mock_controller.rb +22 -0
- data/spec/support/view_test_helper.rb +29 -0
- data/vendor/assets/images/district_cn_selector/area-bg1.jpg +0 -0
- data/vendor/assets/images/district_cn_selector/area-bg2.jpg +0 -0
- data/vendor/assets/images/district_cn_selector/bootstrap-theme.png +0 -0
- data/vendor/assets/images/district_cn_selector/default-theme.png +0 -0
- data/vendor/assets/javascripts/district_cn_selector/jquery.district-ul.js +224 -0
- data/vendor/assets/javascripts/district_cn_selector/jquery.district.js +119 -0
- data/vendor/assets/stylesheets/district_cn_selector/district-ul.css +93 -0
- metadata +269 -0
data/.gitignore
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
|
2
|
+
#
|
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
|
5
|
+
# git config --global core.excludesfile ~/.gitignore_global
|
|
6
|
+
|
|
7
|
+
# Ignore bundler config
|
|
8
|
+
/.bundle
|
|
9
|
+
|
|
10
|
+
# Ignore the default SQLite database.
|
|
11
|
+
*.sqlite3
|
|
12
|
+
|
|
13
|
+
# Ignore all logfiles and tempfiles.
|
|
14
|
+
/log/*.log
|
|
15
|
+
/tmp
|
|
16
|
+
/public/assets
|
|
17
|
+
/public/uploads
|
|
18
|
+
/public/uploads/*.*
|
|
19
|
+
/config/database.yml
|
|
20
|
+
*.swp
|
|
21
|
+
.DS_Store
|
|
22
|
+
.DS_Store?
|
|
23
|
+
Gemfile.lock
|
|
24
|
+
/doc/TODO
|
|
25
|
+
/spec/dummy/log/*.log
|
|
26
|
+
/spec/dummy/tmp/
|
|
27
|
+
/.idea
|
data/.rspec
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--drb --color -f n
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
source 'http://ruby.taobao.org/'
|
|
2
|
+
|
|
3
|
+
# Declare your gem's dependencies in area_select_cn.gemspec.
|
|
4
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
|
5
|
+
# development dependencies will be added by default to the :development group.
|
|
6
|
+
gemspec
|
|
7
|
+
|
|
8
|
+
# jquery-rails is used by the dummy application
|
|
9
|
+
gem "sqlite3"
|
|
10
|
+
group :development, :test do
|
|
11
|
+
gem "rspec-rails"
|
|
12
|
+
gem "capybara"
|
|
13
|
+
gem "capybara-webkit"
|
|
14
|
+
gem "factory_girl_rails"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
gem 'therubyracer'
|
|
18
|
+
gem 'uglifier', '>= 1.0.3'
|
|
19
|
+
|
|
20
|
+
gem 'jquery-rails'
|
|
21
|
+
gem 'sass-rails', '~> 3.2.3'
|
|
22
|
+
gem 'less-rails'
|
|
23
|
+
gem 'bootstrap-sass'
|
|
24
|
+
gem 'font-awesome-rails'
|
|
25
|
+
gem 'simple_form'
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
#gem 'select2-rails'
|
|
29
|
+
#gem 'snap_js-rails'
|
|
30
|
+
|
|
31
|
+
# Declare any dependencies that are still in development here instead of in
|
|
32
|
+
# your gemspec. These might include edge Rails or gems from your path or
|
|
33
|
+
# Git. Remember to move these dependencies to your gemspec before releasing
|
|
34
|
+
# your gem to rubygems.org.
|
|
35
|
+
|
|
36
|
+
# To use debugger
|
|
37
|
+
# gem 'debugger'
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2013 kehao.qiu
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
[](http://badge.fury.io/rb/district_cn_selector)
|
|
2
|
+
## 地区选择插件(测试中)
|
|
3
|
+
三级联动地区选择器:
|
|
4
|
+
|
|
5
|
+
1. select-ul 模拟下拉菜单
|
|
6
|
+
2. select 下拉菜单(done,testing)
|
|
7
|
+
|
|
8
|
+
## Example
|
|
9
|
+
[Online Demo](http://112.124.38.145:9292).
|
|
10
|
+
|
|
11
|
+
##Features
|
|
12
|
+
1. 支持bootstrap
|
|
13
|
+
2. 支持simple_form
|
|
14
|
+
3. 支持select和select-ul
|
|
15
|
+
4. 基于[district_cn](https://github.com/Kehao/district_cn),有一些实用的方法
|
|
16
|
+
|
|
17
|
+
##Installation
|
|
18
|
+
Add it to your Gemfile:
|
|
19
|
+
```ruby
|
|
20
|
+
gem 'district_cn_selector'
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
And then execute:
|
|
24
|
+
```console
|
|
25
|
+
bundle install
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Add it to your application.js:
|
|
29
|
+
|
|
30
|
+
```console
|
|
31
|
+
// select
|
|
32
|
+
//= require district_cn_selector/jquery.district
|
|
33
|
+
// select-ul
|
|
34
|
+
//= require district_cn_selector/jquery.district-ul
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
if you want to use the default theme, add it to your application.css:
|
|
38
|
+
```console
|
|
39
|
+
*= require district_cn_selector/district-ul
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## FormHelper
|
|
43
|
+
###form_tag
|
|
44
|
+
```erb
|
|
45
|
+
|
|
46
|
+
<%= form_tag "" do %>
|
|
47
|
+
<!-- select -->
|
|
48
|
+
<%= district_select(:company,:region_code,"331000") %>
|
|
49
|
+
|
|
50
|
+
<!-- select-ul -->
|
|
51
|
+
<%= district_select_ul(:company,:region_code,"331000") %>
|
|
52
|
+
<% end %>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
###form_for
|
|
56
|
+
```erb
|
|
57
|
+
<%= form_for Company.new,:builder => DistrictCnSelector::Helpers::FormBuilder do |f| %>
|
|
58
|
+
<!-- select -->
|
|
59
|
+
<%= f.district_select :region_code%>
|
|
60
|
+
|
|
61
|
+
<!-- select-ul -->
|
|
62
|
+
<%= f.district_select_ul :region_code%>
|
|
63
|
+
<%end%>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
###simple_form_for
|
|
67
|
+
```erb
|
|
68
|
+
<%= simple_form_for Company.new,:html => { :class => 'form-horizontal' } do |f| %>
|
|
69
|
+
<!-- select -->
|
|
70
|
+
<%= f.input :region_code,:as => :district_select %>
|
|
71
|
+
|
|
72
|
+
<!-- select-ul -->
|
|
73
|
+
<%= f.input :region_code,:as => :district_select_ul %>
|
|
74
|
+
<% end %>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
###province,city,district select helper
|
|
78
|
+
```erb
|
|
79
|
+
<!-- select,select-ul适用 -->
|
|
80
|
+
<!-- form_tag -->
|
|
81
|
+
<%= district_select_ul(:company,:region_code,"331000") %>
|
|
82
|
+
<%= city_select_ul(:company,:region_code,"331000") %>
|
|
83
|
+
<%= province_select_ul(:company,:region_code,"331000") %>
|
|
84
|
+
|
|
85
|
+
<!-- form_for -->
|
|
86
|
+
<%= f.district_select_ul :region_code %>
|
|
87
|
+
<%= f.city_select_ul :region_code %>
|
|
88
|
+
<%= f.province_select_ul :region_code %>
|
|
89
|
+
|
|
90
|
+
<!-- simple_form_for -->
|
|
91
|
+
<%= f.input :region_code,:as => :district_select_ul %>
|
|
92
|
+
<%= f.input :region_code,:as => :city_select_ul %>
|
|
93
|
+
<%= f.input :region_code,:as => :province_select_ul %>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
##Theme(select-ul适用)
|
|
97
|
+
1. default
|
|
98
|
+
2. bootstrap
|
|
99
|
+
|
|
100
|
+
if you want to use the default theme, add it to your application.css:
|
|
101
|
+
```console
|
|
102
|
+
*= require district_cn_selector/district-ul
|
|
103
|
+
```
|
|
104
|
+
if you want to use bootstrap theme, you should import bootstrap css.
|
|
105
|
+
|
|
106
|
+
```erb
|
|
107
|
+
<!-- form_tag -->
|
|
108
|
+
<%= district_select_ul(:company,:region_code,"331000",:theme=>:bootstrap) %>
|
|
109
|
+
|
|
110
|
+
<!-- form_for -->
|
|
111
|
+
<%= f.district_select_ul :region_code,:theme=>:bootstrap,:prompt_class=>"btn btn-success"%>
|
|
112
|
+
|
|
113
|
+
<!-- simple_form_for,如果SimpleForm.wrapper等于:bootstrap,默认样式为:bootstrap -->
|
|
114
|
+
<%= f.input :region_code,:as => :district_select_ul %>
|
|
115
|
+
```
|
|
116
|
+
## Test
|
|
117
|
+
``` ruby
|
|
118
|
+
rake spec
|
|
119
|
+
```
|
|
120
|
+
## Resources
|
|
121
|
+
* Chosen(http://harvesthq.github.io/chosen/)
|
|
122
|
+
* X-editable(http://vitalets.github.io/x-editable/demo.html)
|
|
123
|
+
* Jquery-addresspicker(http://xilinus.com/jquery-addresspicker/demos/index.html)
|
|
124
|
+
* Jquery-Autocomplete(https://github.com/devbridge/jQuery-Autocomplete)
|
|
125
|
+
* Jquery-tokeninput(https://github.com/loopj/jquery-tokeninput)
|
|
126
|
+
* Jquery-ui(http://jqueryui.com/autocomplete/)
|
|
127
|
+
* Select2(http://ivaynberg.github.io/select2/)
|
|
128
|
+
* typeahead.js(https://github.com/twitter/typeahead.js/)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
##Contributing
|
|
132
|
+
|
|
133
|
+
1. Fork it
|
|
134
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
135
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
|
136
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
137
|
+
5. Create new Pull Request
|
|
138
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env rake
|
|
2
|
+
begin
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
rescue LoadError
|
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
|
9
|
+
load 'rails/tasks/engine.rake'
|
|
10
|
+
|
|
11
|
+
Bundler::GemHelper.install_tasks
|
|
12
|
+
|
|
13
|
+
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
|
|
14
|
+
|
|
15
|
+
require 'rspec/core'
|
|
16
|
+
require 'rspec/core/rake_task'
|
|
17
|
+
|
|
18
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
|
19
|
+
RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
|
|
20
|
+
task :default => :spec
|
|
21
|
+
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Rails.application.routes.draw do
|
|
2
|
+
# 返回树状结构的省,市,区县数据
|
|
3
|
+
get '/district_cn_selector/district',
|
|
4
|
+
:to => DistrictCnSelector::DistrictController.action(:index)
|
|
5
|
+
get '/district_cn_selector/district/search',
|
|
6
|
+
:to => DistrictCnSelector::DistrictController.action(:search)
|
|
7
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'district_cn_selector/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "district_cn_selector"
|
|
8
|
+
spec.version = DistrictCnSelector::VERSION
|
|
9
|
+
spec.authors = ["kehao"]
|
|
10
|
+
spec.email = ["kehao.qiu@gmail.com"]
|
|
11
|
+
spec.description = %q{三级联动地区选择器}
|
|
12
|
+
spec.summary = %q{三级联动地区选择器}
|
|
13
|
+
#spec.homepage = ""
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files`.split($/)
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
|
22
|
+
spec.add_development_dependency "rake"
|
|
23
|
+
|
|
24
|
+
spec.add_dependency "rails", ">= 3.2.6"
|
|
25
|
+
spec.add_dependency "jquery-rails"
|
|
26
|
+
spec.add_dependency "district_cn",">= 1.0.2"
|
|
27
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require "district_cn"
|
|
2
|
+
require "district_cn_selector/engine"
|
|
3
|
+
|
|
4
|
+
module DistrictCnSelector
|
|
5
|
+
autoload :Theme, 'district_cn_selector/theme'
|
|
6
|
+
autoload :DistrictController, 'district_cn_selector/district_controller'
|
|
7
|
+
|
|
8
|
+
module Helpers
|
|
9
|
+
autoload :FormBuilderExtension, 'district_cn_selector/helpers/form_builder_extension'
|
|
10
|
+
autoload :FormBuilder, 'district_cn_selector/helpers/form_builder'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
begin
|
|
14
|
+
require 'simple_form'
|
|
15
|
+
require 'district_cn_selector/hooks/simple_form'
|
|
16
|
+
rescue LoadError
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
require 'district_cn_selector/selector'
|
|
20
|
+
require 'district_cn_selector/district_select_ul_helper'
|
|
21
|
+
require 'district_cn_selector/district_select_helper'
|
|
22
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
module DistrictCnSelector
|
|
3
|
+
class DistrictController < ActionController::Base
|
|
4
|
+
layout nil
|
|
5
|
+
# 返回树状结构的整个省份,城市,区域列表,
|
|
6
|
+
# 避免选择地区时的多次请求
|
|
7
|
+
def index
|
|
8
|
+
code = params[:region_code]
|
|
9
|
+
results =
|
|
10
|
+
if code
|
|
11
|
+
DistrictCn.code(code).children
|
|
12
|
+
else
|
|
13
|
+
DistrictCn.tree
|
|
14
|
+
end
|
|
15
|
+
render :json => results
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def search
|
|
19
|
+
ids = []
|
|
20
|
+
if params[:region_name]
|
|
21
|
+
ids = DistrictCn.search(params[:region_name])
|
|
22
|
+
end
|
|
23
|
+
render :json => ids.map{|id|{:id=>id.code,:text=>id.area_name}}
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
module ActionView
|
|
3
|
+
module Helpers
|
|
4
|
+
module FormOptionsHelper
|
|
5
|
+
def district_select(object, method, region_code=nil, options={}, html_options={})
|
|
6
|
+
tag = InstanceTag.new(object, method, self, options.delete(:object))
|
|
7
|
+
tag.to_district_select_tag(region_code, options, html_options)
|
|
8
|
+
end
|
|
9
|
+
alias_method :area_select, :district_select
|
|
10
|
+
|
|
11
|
+
def city_select(object, method, region_code=nil, options={}, html_options={})
|
|
12
|
+
tag = InstanceTag.new(object, method, self, options.delete(:object))
|
|
13
|
+
tag.to_city_select_tag(region_code, options, html_options)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def province_select(object, method, region_code=nil, options={}, html_options={})
|
|
17
|
+
tag = InstanceTag.new(object, method, self, options.delete(:object))
|
|
18
|
+
tag.to_province_select_tag(region_code, options, html_options)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
module SelectHelperInstanceTag
|
|
23
|
+
def to_district_select_tag(region_code=nil, options={}, html_options={})
|
|
24
|
+
district_selector(region_code, options, html_options).to_select(:district)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def to_city_select_tag(region_code=nil,options={}, html_options={})
|
|
28
|
+
district_selector(region_code, options, html_options).to_select(:city)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def to_province_select_tag(region_code=nil,options={}, html_options={})
|
|
32
|
+
district_selector(region_code, options, html_options).to_select(:province)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
def district_selector(region_code,options, html_options)
|
|
37
|
+
DistrictCnSelector::SelectSelector.new(self, region_code, options, html_options)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
class InstanceTag #:nodoc:
|
|
42
|
+
include SelectHelperInstanceTag
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
module ActionView
|
|
3
|
+
module Helpers
|
|
4
|
+
module FormOptionsHelper
|
|
5
|
+
def district_select_ul(object, method, region_code=nil, options={}, html_options={})
|
|
6
|
+
tag = InstanceTag.new(object, method, self, options.delete(:object))
|
|
7
|
+
tag.to_district_select_ul_tag(region_code, options, html_options)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
alias_method :area_select_ul, :district_select_ul
|
|
11
|
+
|
|
12
|
+
def city_select_ul(object, method, region_code=nil, options={}, html_options={})
|
|
13
|
+
tag = InstanceTag.new(object, method, self, options.delete(:object))
|
|
14
|
+
tag.to_city_select_ul_tag(region_code, options, html_options)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def province_select_ul(object, method, region_code=nil, options={}, html_options={})
|
|
18
|
+
tag = InstanceTag.new(object, method, self, options.delete(:object))
|
|
19
|
+
tag.to_province_select_ul_tag(region_code, options, html_options)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
module SelectUlHelperInstanceTag
|
|
24
|
+
def to_district_select_ul_tag(region_code=nil,options={}, html_options={})
|
|
25
|
+
district_ul_selector(region_code, options, html_options).to_select(:district)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def to_city_select_ul_tag(region_code=nil,options={}, html_options={})
|
|
29
|
+
district_ul_selector(region_code, options, html_options).to_select(:city)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def to_province_select_ul_tag(region_code=nil,options={}, html_options={})
|
|
33
|
+
district_ul_selector(region_code, options, html_options).to_select(:province)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
def district_ul_selector(region_code,options, html_options)
|
|
38
|
+
DistrictCnSelector::SelectUlSelector.new(self, region_code, options, html_options)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
class InstanceTag #:nodoc:
|
|
43
|
+
include SelectUlHelperInstanceTag
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|