trestle 0.8.5 → 0.8.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/trestle/admin.js +11 -10
- data/app/assets/javascripts/trestle/{_confirmation.js → components/_confirmation.js} +1 -1
- data/app/assets/javascripts/trestle/{_datepicker.js → components/_datepicker.js} +4 -4
- data/app/assets/javascripts/trestle/components/_dialog.js +107 -0
- data/app/assets/javascripts/trestle/{_errors.js → components/_errors.js} +2 -2
- data/app/assets/javascripts/trestle/components/_form.js +48 -0
- data/app/assets/javascripts/trestle/{_gallery.js → components/_gallery.js} +3 -3
- data/app/assets/javascripts/trestle/{_select.js → components/_select.js} +2 -2
- data/app/assets/javascripts/trestle/{_sidebar.js → components/_sidebar.js} +3 -1
- data/app/assets/javascripts/trestle/{_table.js → components/_table.js} +1 -1
- data/app/assets/javascripts/trestle/components/_tabs.js +24 -0
- data/app/assets/javascripts/trestle/components/_tooltips.js +3 -0
- data/app/assets/javascripts/trestle/core/_contexts.js +13 -0
- data/app/assets/javascripts/trestle/{_cookies.js → core/_cookies.js} +2 -1
- data/app/assets/javascripts/trestle/core/_events.js +39 -0
- data/app/assets/javascripts/trestle/core/_visit.js +10 -0
- data/app/assets/stylesheets/trestle/components/_buttons.scss +9 -0
- data/app/assets/stylesheets/trestle/components/_modal.scss +92 -0
- data/app/assets/stylesheets/trestle/components/_navigation.scss +47 -12
- data/app/assets/stylesheets/trestle/components/_sidebar.scss +1 -0
- data/app/assets/stylesheets/trestle/core/_defaults.scss +5 -1
- data/app/controllers/trestle/application_controller.rb +5 -1
- data/app/helpers/trestle/dialog_helper.rb +7 -0
- data/app/helpers/trestle/form_helper.rb +7 -0
- data/app/helpers/trestle/url_helper.rb +34 -6
- data/app/views/layouts/trestle/admin.html.erb +1 -1
- data/app/views/trestle/application/_dialog.html.erb +36 -0
- data/app/views/trestle/application/_tabs.html.erb +7 -1
- data/app/views/trestle/resource/edit.html.erb +5 -5
- data/app/views/trestle/resource/index.html.erb +2 -2
- data/app/views/trestle/resource/new.html.erb +2 -2
- data/app/views/trestle/resource/show.html.erb +5 -5
- data/bower.json +1 -1
- data/config/locales/en.yml +25 -21
- data/config/locales/fr.rb +18 -0
- data/config/locales/fr.yml +69 -0
- data/config/locales/nl.yml +14 -14
- data/config/locales/pl.rb +18 -0
- data/config/locales/pl.yml +70 -0
- data/config/locales/pt-BR.yml +22 -22
- data/lib/generators/trestle/resource/templates/admin.rb.erb +1 -1
- data/lib/trestle/admin.rb +14 -1
- data/lib/trestle/admin/builder.rb +10 -2
- data/lib/trestle/breadcrumb.rb +13 -0
- data/lib/trestle/configuration.rb +6 -1
- data/lib/trestle/form.rb +7 -3
- data/lib/trestle/form/automatic.rb +1 -1
- data/lib/trestle/reloader.rb +1 -1
- data/lib/trestle/resource.rb +20 -5
- data/lib/trestle/resource/builder.rb +15 -0
- data/lib/trestle/resource/controller.rb +19 -6
- data/lib/trestle/table.rb +4 -0
- data/lib/trestle/table/actions_column.rb +9 -7
- data/lib/trestle/table/column.rb +3 -2
- data/lib/trestle/table/row.rb +7 -1
- data/lib/trestle/version.rb +1 -1
- data/trestle.gemspec +3 -3
- data/vendor/assets/bower_components/trestle/select2/dist/js/select2.full.js +90 -69
- metadata +30 -19
- data/app/assets/javascripts/trestle/_form.js +0 -6
- data/app/assets/javascripts/trestle/_tabs.js +0 -13
- data/app/assets/javascripts/trestle/_tooltips.js +0 -3
data/lib/trestle/reloader.rb
CHANGED
data/lib/trestle/resource.rb
CHANGED
@@ -5,6 +5,9 @@ module Trestle
|
|
5
5
|
autoload :Builder
|
6
6
|
autoload :Controller
|
7
7
|
|
8
|
+
RESOURCE_ACTIONS = [:index, :show, :new, :create, :edit, :update, :destroy]
|
9
|
+
READONLY_ACTIONS = [:index, :show]
|
10
|
+
|
8
11
|
class << self
|
9
12
|
def adapter
|
10
13
|
@adapter ||= Trestle.config.default_adapter.new(self)
|
@@ -122,26 +125,38 @@ module Trestle
|
|
122
125
|
@model_name ||= Trestle::ModelName.new(model)
|
123
126
|
end
|
124
127
|
|
128
|
+
def actions
|
129
|
+
@actions ||= (readonly? ? READONLY_ACTIONS : RESOURCE_ACTIONS).dup
|
130
|
+
end
|
131
|
+
|
125
132
|
def readonly?
|
126
133
|
options[:readonly]
|
127
134
|
end
|
128
135
|
|
129
|
-
def
|
130
|
-
Breadcrumb.new(model_name.plural.titleize, path)
|
136
|
+
def default_breadcrumb
|
137
|
+
Breadcrumb.new(I18n.t("admin.breadcrumbs.#{admin_name}", default: model_name.plural.titleize), path)
|
131
138
|
end
|
132
139
|
|
133
140
|
def routes
|
134
141
|
admin = self
|
135
142
|
|
136
143
|
Proc.new do
|
137
|
-
resources admin.admin_name, controller: admin.controller_namespace, as: admin.route_name, path: admin.options[:path], except: admin.
|
144
|
+
resources admin.admin_name, controller: admin.controller_namespace, as: admin.route_name, path: admin.options[:path], except: (RESOURCE_ACTIONS - admin.actions) do
|
138
145
|
instance_exec(&admin.additional_routes) if admin.additional_routes
|
139
146
|
end
|
140
147
|
end
|
141
148
|
end
|
142
149
|
|
143
|
-
def
|
144
|
-
|
150
|
+
def return_locations
|
151
|
+
@return_locations ||= {
|
152
|
+
create: Proc.new { |instance| path(:show, id: to_param(instance)) },
|
153
|
+
update: Proc.new { |instance| path(:show, id: to_param(instance)) },
|
154
|
+
destroy: Proc.new { path(:index) }
|
155
|
+
}
|
156
|
+
end
|
157
|
+
|
158
|
+
def return_location(action, instance=nil)
|
159
|
+
instance_exec(instance, &return_locations[action])
|
145
160
|
end
|
146
161
|
|
147
162
|
private
|
@@ -14,6 +14,13 @@ module Trestle
|
|
14
14
|
admin.adapter = adapter
|
15
15
|
end
|
16
16
|
|
17
|
+
def remove_action(*actions)
|
18
|
+
actions.each do |action|
|
19
|
+
controller.remove_possible_method(action.to_sym)
|
20
|
+
admin.actions.delete(action.to_sym)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
17
24
|
def collection(&block)
|
18
25
|
admin.collection = block
|
19
26
|
end
|
@@ -83,6 +90,14 @@ module Trestle
|
|
83
90
|
|
84
91
|
admin.scopes[name] = Scope.new(admin, name, options, &(scope || block))
|
85
92
|
end
|
93
|
+
|
94
|
+
def return_to(options={}, &block)
|
95
|
+
actions = options.key?(:on) ? Array(options[:on]) : [:create, :update, :destroy]
|
96
|
+
|
97
|
+
actions.each do |action|
|
98
|
+
admin.return_locations[action.to_sym] = block
|
99
|
+
end
|
100
|
+
end
|
86
101
|
end
|
87
102
|
end
|
88
103
|
end
|
@@ -1,12 +1,15 @@
|
|
1
1
|
module Trestle
|
2
2
|
class Resource
|
3
3
|
class Controller < Admin::Controller
|
4
|
+
after_action :set_trestle_location_header
|
5
|
+
|
4
6
|
def index
|
5
7
|
self.collection = admin.prepare_collection(params)
|
6
8
|
|
7
9
|
respond_to do |format|
|
8
10
|
format.html
|
9
11
|
format.json { render json: collection }
|
12
|
+
format.js
|
10
13
|
end
|
11
14
|
end
|
12
15
|
|
@@ -16,6 +19,7 @@ module Trestle
|
|
16
19
|
respond_to do |format|
|
17
20
|
format.html
|
18
21
|
format.json { render json: instance }
|
22
|
+
format.js
|
19
23
|
end
|
20
24
|
end
|
21
25
|
|
@@ -26,7 +30,7 @@ module Trestle
|
|
26
30
|
respond_to do |format|
|
27
31
|
format.html do
|
28
32
|
flash[:message] = flash_message("success.create", default: "The %{lowercase_model_name} was successfully created.")
|
29
|
-
redirect_to
|
33
|
+
redirect_to(admin.return_location(:create, instance), turbolinks: false)
|
30
34
|
end
|
31
35
|
format.json { render json: instance, status: :created, location: { action: :show, id: admin.to_param(instance) } }
|
32
36
|
format.js
|
@@ -35,9 +39,10 @@ module Trestle
|
|
35
39
|
respond_to do |format|
|
36
40
|
format.html do
|
37
41
|
flash.now[:error] = flash_message("failure.create", default: "Please correct the errors below.")
|
38
|
-
render "new"
|
42
|
+
render "new", status: :unprocessable_entity
|
39
43
|
end
|
40
44
|
format.json { render json: instance.errors, status: :unprocessable_entity }
|
45
|
+
format.js
|
41
46
|
end
|
42
47
|
end
|
43
48
|
end
|
@@ -48,6 +53,7 @@ module Trestle
|
|
48
53
|
respond_to do |format|
|
49
54
|
format.html
|
50
55
|
format.json { render json: instance }
|
56
|
+
format.js
|
51
57
|
end
|
52
58
|
end
|
53
59
|
|
@@ -63,7 +69,7 @@ module Trestle
|
|
63
69
|
respond_to do |format|
|
64
70
|
format.html do
|
65
71
|
flash[:message] = flash_message("success.update", default: "The %{lowercase_model_name} was successfully updated.")
|
66
|
-
redirect_to
|
72
|
+
redirect_to(admin.return_location(:update, instance), turbolinks: false)
|
67
73
|
end
|
68
74
|
format.json { render json: instance, status: :ok }
|
69
75
|
format.js
|
@@ -72,9 +78,10 @@ module Trestle
|
|
72
78
|
respond_to do |format|
|
73
79
|
format.html do
|
74
80
|
flash.now[:error] = flash_message("failure.update", default: "Please correct the errors below.")
|
75
|
-
render "show"
|
81
|
+
render "show", status: :unprocessable_entity
|
76
82
|
end
|
77
83
|
format.json { render json: instance.errors, status: :unprocessable_entity }
|
84
|
+
format.js
|
78
85
|
end
|
79
86
|
end
|
80
87
|
end
|
@@ -87,14 +94,14 @@ module Trestle
|
|
87
94
|
format.html do
|
88
95
|
if success
|
89
96
|
flash[:message] = flash_message("success.destroy", default: "The %{lowercase_model_name} was successfully deleted.")
|
90
|
-
redirect_to
|
97
|
+
redirect_to admin.return_location(:destroy)
|
91
98
|
else
|
92
99
|
flash[:error] = flash_message("failure.destroy", default: "Could not delete %{lowercase_model_name}.")
|
93
100
|
|
94
101
|
if self.instance = admin.find_instance(params)
|
95
102
|
redirect_to action: :show, id: admin.to_param(instance)
|
96
103
|
else
|
97
|
-
redirect_to
|
104
|
+
redirect_to admin.return_location(:destroy)
|
98
105
|
end
|
99
106
|
end
|
100
107
|
end
|
@@ -113,6 +120,12 @@ module Trestle
|
|
113
120
|
def flash_message(type, options={})
|
114
121
|
t("trestle.flash.#{type}", options.merge(model_name: admin.model_name, lowercase_model_name: admin.model_name.downcase))
|
115
122
|
end
|
123
|
+
|
124
|
+
def set_trestle_location_header
|
125
|
+
unless request.headers["X-Trestle-Dialog"]
|
126
|
+
headers["X-Trestle-Location"] = request.path
|
127
|
+
end
|
128
|
+
end
|
116
129
|
end
|
117
130
|
end
|
118
131
|
end
|
data/lib/trestle/table.rb
CHANGED
@@ -13,8 +13,10 @@ module Trestle
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def default_actions
|
16
|
+
admin = table.admin
|
17
|
+
|
16
18
|
->(action) do
|
17
|
-
action.delete
|
19
|
+
action.delete if admin && admin.actions.include?(:destroy)
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
@@ -23,29 +25,29 @@ module Trestle
|
|
23
25
|
|
24
26
|
delegate :table, to: :@column
|
25
27
|
|
26
|
-
delegate :icon, :
|
28
|
+
delegate :concat, :icon, :link_to, :admin_url_for, :admin_link_to, to: :@template
|
27
29
|
|
28
30
|
def initialize(column, template, instance)
|
29
31
|
@column, @template, @instance = column, template, instance
|
30
32
|
end
|
31
33
|
|
32
34
|
def show
|
33
|
-
button(icon("fa fa-info"),
|
35
|
+
button(icon("fa fa-info"), instance, action: :show, class: "btn-info")
|
34
36
|
end
|
35
37
|
|
36
38
|
def edit
|
37
|
-
button(icon("fa fa-pencil"),
|
39
|
+
button(icon("fa fa-pencil"), instance, action: :edit, class: "btn-warning")
|
38
40
|
end
|
39
41
|
|
40
42
|
def delete
|
41
|
-
button(icon("fa fa-trash"),
|
43
|
+
button(icon("fa fa-trash"), instance, action: :destroy, method: :delete, class: "btn-danger", data: { toggle: "confirm-delete", placement: "left" })
|
42
44
|
end
|
43
45
|
|
44
|
-
def button(content,
|
46
|
+
def button(content, instance_or_url, options={})
|
45
47
|
options[:class] = Array(options[:class])
|
46
48
|
options[:class] << "btn" unless options[:class].include?("btn")
|
47
49
|
|
48
|
-
concat
|
50
|
+
concat admin_link_to(content, instance_or_url, options.reverse_merge(admin: table.admin))
|
49
51
|
end
|
50
52
|
alias_method :link, :button
|
51
53
|
end
|
data/lib/trestle/table/column.rb
CHANGED
@@ -39,7 +39,7 @@ module Trestle
|
|
39
39
|
end
|
40
40
|
|
41
41
|
class Renderer
|
42
|
-
delegate :options, to: :@column
|
42
|
+
delegate :options, :table, to: :@column
|
43
43
|
|
44
44
|
def initialize(column, template)
|
45
45
|
@column, @template = column, template
|
@@ -58,11 +58,12 @@ module Trestle
|
|
58
58
|
content = @template.format_value(value, options)
|
59
59
|
|
60
60
|
if value.respond_to?(:id) && options[:link] != false
|
61
|
+
# Column value was a model instance (e.g. from an association).
|
61
62
|
# Automatically link to instance's admin if available
|
62
63
|
content = @template.admin_link_to(content, value)
|
63
64
|
elsif options[:link]
|
64
65
|
# Explicitly link to the specified admin, or the table's admin
|
65
|
-
content = @template.admin_link_to(content, instance, admin: options[:admin] ||
|
66
|
+
content = @template.admin_link_to(content, instance, admin: options[:admin] || table.admin)
|
66
67
|
end
|
67
68
|
|
68
69
|
content
|
data/lib/trestle/table/row.rb
CHANGED
@@ -21,9 +21,15 @@ module Trestle
|
|
21
21
|
|
22
22
|
def options(instance)
|
23
23
|
options = Trestle::Options.new
|
24
|
-
|
24
|
+
|
25
|
+
if table.admin && table.autolink?
|
26
|
+
options.merge!(data: { url: admin_url_for(instance) })
|
27
|
+
options.merge!(data: { behavior: "dialog" }) if table.admin.form.dialog?
|
28
|
+
end
|
29
|
+
|
25
30
|
options.merge!(@row.options)
|
26
31
|
options.merge!(@template.instance_exec(instance, &@row.block)) if @row.block
|
32
|
+
|
27
33
|
options
|
28
34
|
end
|
29
35
|
|
data/lib/trestle/version.rb
CHANGED
data/trestle.gemspec
CHANGED
@@ -35,9 +35,9 @@ Gem::Specification.new do |spec|
|
|
35
35
|
|
36
36
|
spec.add_dependency "railties", ">= 4.2.0"
|
37
37
|
spec.add_dependency "activemodel", ">= 4.2.0"
|
38
|
-
spec.add_dependency "sass-rails", "
|
39
|
-
spec.add_dependency "autoprefixer-rails", "
|
40
|
-
spec.add_dependency "kaminari", "~> 1.0
|
38
|
+
spec.add_dependency "sass-rails", ">= 5.0.6"
|
39
|
+
spec.add_dependency "autoprefixer-rails", ">= 7.1.2"
|
40
|
+
spec.add_dependency "kaminari", "~> 1.1.0"
|
41
41
|
|
42
42
|
spec.add_development_dependency "bundler", "~> 1.12"
|
43
43
|
spec.add_development_dependency "rake", "~> 10.0"
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*!
|
2
|
-
* Select2 4.0.
|
2
|
+
* Select2 4.0.5
|
3
3
|
* https://select2.github.io
|
4
4
|
*
|
5
5
|
* Released under the MIT license
|
@@ -9,19 +9,33 @@
|
|
9
9
|
if (typeof define === 'function' && define.amd) {
|
10
10
|
// AMD. Register as an anonymous module.
|
11
11
|
define(['jquery'], factory);
|
12
|
-
} else if (typeof
|
12
|
+
} else if (typeof module === 'object' && module.exports) {
|
13
13
|
// Node/CommonJS
|
14
|
-
|
14
|
+
module.exports = function (root, jQuery) {
|
15
|
+
if (jQuery === undefined) {
|
16
|
+
// require('jQuery') returns a factory that requires window to
|
17
|
+
// build a jQuery instance, we normalize how we use modules
|
18
|
+
// that require this pattern but the window provided is a noop
|
19
|
+
// if it's defined (how jquery works)
|
20
|
+
if (typeof window !== 'undefined') {
|
21
|
+
jQuery = require('jquery');
|
22
|
+
}
|
23
|
+
else {
|
24
|
+
jQuery = require('jquery')(root);
|
25
|
+
}
|
26
|
+
}
|
27
|
+
factory(jQuery);
|
28
|
+
return jQuery;
|
29
|
+
};
|
15
30
|
} else {
|
16
31
|
// Browser globals
|
17
32
|
factory(jQuery);
|
18
33
|
}
|
19
|
-
}(function (jQuery) {
|
34
|
+
} (function (jQuery) {
|
20
35
|
// This is needed so we can catch the AMD loader configuration and use it
|
21
36
|
// The inner file should be wrapped (by `banner.start.js`) in a function that
|
22
37
|
// returns the AMD loader references.
|
23
|
-
var S2 =
|
24
|
-
(function () {
|
38
|
+
var S2 =(function () {
|
25
39
|
// Restore the Select2 AMD loader so it can be used
|
26
40
|
// Needed mostly in the language files, where the loader is not inserted
|
27
41
|
if (jQuery && jQuery.fn && jQuery.fn.select2 && jQuery.fn.select2.amd) {
|
@@ -30,13 +44,11 @@
|
|
30
44
|
var S2;(function () { if (!S2 || !S2.requirejs) {
|
31
45
|
if (!S2) { S2 = {}; } else { require = S2; }
|
32
46
|
/**
|
33
|
-
* @license almond 0.3.
|
34
|
-
*
|
35
|
-
* see: http://github.com/jrburke/almond for details
|
47
|
+
* @license almond 0.3.3 Copyright jQuery Foundation and other contributors.
|
48
|
+
* Released under MIT license, http://github.com/requirejs/almond/LICENSE
|
36
49
|
*/
|
37
50
|
//Going sloppy to avoid 'use strict' string cost, but strict practices should
|
38
51
|
//be followed.
|
39
|
-
/*jslint sloppy: true */
|
40
52
|
/*global setTimeout: false */
|
41
53
|
|
42
54
|
var requirejs, require, define;
|
@@ -64,60 +76,58 @@ var requirejs, require, define;
|
|
64
76
|
*/
|
65
77
|
function normalize(name, baseName) {
|
66
78
|
var nameParts, nameSegment, mapValue, foundMap, lastIndex,
|
67
|
-
foundI, foundStarMap, starI, i, j, part,
|
79
|
+
foundI, foundStarMap, starI, i, j, part, normalizedBaseParts,
|
68
80
|
baseParts = baseName && baseName.split("/"),
|
69
81
|
map = config.map,
|
70
82
|
starMap = (map && map['*']) || {};
|
71
83
|
|
72
84
|
//Adjust any relative paths.
|
73
|
-
if (name
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
}
|
85
|
+
if (name) {
|
86
|
+
name = name.split('/');
|
87
|
+
lastIndex = name.length - 1;
|
88
|
+
|
89
|
+
// If wanting node ID compatibility, strip .js from end
|
90
|
+
// of IDs. Have to do this here, and not in nameToUrl
|
91
|
+
// because node allows either .js or non .js to map
|
92
|
+
// to same file.
|
93
|
+
if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
|
94
|
+
name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
|
95
|
+
}
|
85
96
|
|
86
|
-
|
87
|
-
|
88
|
-
//baseName
|
89
|
-
//
|
90
|
-
|
91
|
-
|
92
|
-
//
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
97
|
+
// Starts with a '.' so need the baseName
|
98
|
+
if (name[0].charAt(0) === '.' && baseParts) {
|
99
|
+
//Convert baseName to array, and lop off the last part,
|
100
|
+
//so that . matches that 'directory' and not name of the baseName's
|
101
|
+
//module. For instance, baseName of 'one/two/three', maps to
|
102
|
+
//'one/two/three.js', but we want the directory, 'one/two' for
|
103
|
+
//this normalization.
|
104
|
+
normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
|
105
|
+
name = normalizedBaseParts.concat(name);
|
106
|
+
}
|
107
|
+
|
108
|
+
//start trimDots
|
109
|
+
for (i = 0; i < name.length; i++) {
|
110
|
+
part = name[i];
|
111
|
+
if (part === '.') {
|
112
|
+
name.splice(i, 1);
|
113
|
+
i -= 1;
|
114
|
+
} else if (part === '..') {
|
115
|
+
// If at the start, or previous value is still ..,
|
116
|
+
// keep them so that when converted to a path it may
|
117
|
+
// still work when converted to a path, even though
|
118
|
+
// as an ID it is less than ideal. In larger point
|
119
|
+
// releases, may be better to just kick out an error.
|
120
|
+
if (i === 0 || (i === 1 && name[2] === '..') || name[i - 1] === '..') {
|
121
|
+
continue;
|
122
|
+
} else if (i > 0) {
|
123
|
+
name.splice(i - 1, 2);
|
124
|
+
i -= 2;
|
111
125
|
}
|
112
126
|
}
|
113
|
-
//end trimDots
|
114
|
-
|
115
|
-
name = name.join("/");
|
116
|
-
} else if (name.indexOf('./') === 0) {
|
117
|
-
// No baseName, so this is ID is resolved relative
|
118
|
-
// to baseUrl, pull off the leading dot.
|
119
|
-
name = name.substring(2);
|
120
127
|
}
|
128
|
+
//end trimDots
|
129
|
+
|
130
|
+
name = name.join('/');
|
121
131
|
}
|
122
132
|
|
123
133
|
//Apply map config if available.
|
@@ -230,32 +240,39 @@ var requirejs, require, define;
|
|
230
240
|
return [prefix, name];
|
231
241
|
}
|
232
242
|
|
243
|
+
//Creates a parts array for a relName where first part is plugin ID,
|
244
|
+
//second part is resource ID. Assumes relName has already been normalized.
|
245
|
+
function makeRelParts(relName) {
|
246
|
+
return relName ? splitPrefix(relName) : [];
|
247
|
+
}
|
248
|
+
|
233
249
|
/**
|
234
250
|
* Makes a name map, normalizing the name, and using a plugin
|
235
251
|
* for normalization if necessary. Grabs a ref to plugin
|
236
252
|
* too, as an optimization.
|
237
253
|
*/
|
238
|
-
makeMap = function (name,
|
254
|
+
makeMap = function (name, relParts) {
|
239
255
|
var plugin,
|
240
256
|
parts = splitPrefix(name),
|
241
|
-
prefix = parts[0]
|
257
|
+
prefix = parts[0],
|
258
|
+
relResourceName = relParts[1];
|
242
259
|
|
243
260
|
name = parts[1];
|
244
261
|
|
245
262
|
if (prefix) {
|
246
|
-
prefix = normalize(prefix,
|
263
|
+
prefix = normalize(prefix, relResourceName);
|
247
264
|
plugin = callDep(prefix);
|
248
265
|
}
|
249
266
|
|
250
267
|
//Normalize according
|
251
268
|
if (prefix) {
|
252
269
|
if (plugin && plugin.normalize) {
|
253
|
-
name = plugin.normalize(name, makeNormalize(
|
270
|
+
name = plugin.normalize(name, makeNormalize(relResourceName));
|
254
271
|
} else {
|
255
|
-
name = normalize(name,
|
272
|
+
name = normalize(name, relResourceName);
|
256
273
|
}
|
257
274
|
} else {
|
258
|
-
name = normalize(name,
|
275
|
+
name = normalize(name, relResourceName);
|
259
276
|
parts = splitPrefix(name);
|
260
277
|
prefix = parts[0];
|
261
278
|
name = parts[1];
|
@@ -302,13 +319,14 @@ var requirejs, require, define;
|
|
302
319
|
};
|
303
320
|
|
304
321
|
main = function (name, deps, callback, relName) {
|
305
|
-
var cjsModule, depName, ret, map, i,
|
322
|
+
var cjsModule, depName, ret, map, i, relParts,
|
306
323
|
args = [],
|
307
324
|
callbackType = typeof callback,
|
308
325
|
usingExports;
|
309
326
|
|
310
327
|
//Use name if no relName
|
311
328
|
relName = relName || name;
|
329
|
+
relParts = makeRelParts(relName);
|
312
330
|
|
313
331
|
//Call the callback to define the module, if necessary.
|
314
332
|
if (callbackType === 'undefined' || callbackType === 'function') {
|
@@ -317,7 +335,7 @@ var requirejs, require, define;
|
|
317
335
|
//Default to [require, exports, module] if no deps
|
318
336
|
deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps;
|
319
337
|
for (i = 0; i < deps.length; i += 1) {
|
320
|
-
map = makeMap(deps[i],
|
338
|
+
map = makeMap(deps[i], relParts);
|
321
339
|
depName = map.f;
|
322
340
|
|
323
341
|
//Fast path CommonJS standard dependencies.
|
@@ -373,7 +391,7 @@ var requirejs, require, define;
|
|
373
391
|
//deps arg is the module name, and second arg (if passed)
|
374
392
|
//is just the relName.
|
375
393
|
//Normalize module name, if it contains . or ..
|
376
|
-
return callDep(makeMap(deps, callback).f);
|
394
|
+
return callDep(makeMap(deps, makeRelParts(callback)).f);
|
377
395
|
} else if (!deps.splice) {
|
378
396
|
//deps is a config object, not an array.
|
379
397
|
config = deps;
|
@@ -1837,7 +1855,7 @@ S2.define('select2/selection/search',[
|
|
1837
1855
|
var $search = $(
|
1838
1856
|
'<li class="select2-search select2-search--inline">' +
|
1839
1857
|
'<input class="select2-search__field" type="search" tabindex="-1"' +
|
1840
|
-
' autocomplete="off" autocorrect="off" autocapitalize="
|
1858
|
+
' autocomplete="off" autocorrect="off" autocapitalize="none"' +
|
1841
1859
|
' spellcheck="false" role="textbox" aria-autocomplete="list" />' +
|
1842
1860
|
'</li>'
|
1843
1861
|
);
|
@@ -3191,7 +3209,7 @@ S2.define('select2/data/select',[
|
|
3191
3209
|
}
|
3192
3210
|
}
|
3193
3211
|
|
3194
|
-
if (data.id) {
|
3212
|
+
if (data.id !== undefined) {
|
3195
3213
|
option.value = data.id;
|
3196
3214
|
}
|
3197
3215
|
|
@@ -3550,7 +3568,10 @@ S2.define('select2/data/tags',[
|
|
3550
3568
|
}, true)
|
3551
3569
|
);
|
3552
3570
|
|
3553
|
-
var
|
3571
|
+
var optionText = (option.text || '').toUpperCase();
|
3572
|
+
var paramsTerm = (params.term || '').toUpperCase();
|
3573
|
+
|
3574
|
+
var checkText = optionText === paramsTerm;
|
3554
3575
|
|
3555
3576
|
if (checkText || checkChildren) {
|
3556
3577
|
if (child) {
|
@@ -3888,7 +3909,7 @@ S2.define('select2/dropdown/search',[
|
|
3888
3909
|
var $search = $(
|
3889
3910
|
'<span class="select2-search select2-search--dropdown">' +
|
3890
3911
|
'<input class="select2-search__field" type="search" tabindex="-1"' +
|
3891
|
-
' autocomplete="off" autocorrect="off" autocapitalize="
|
3912
|
+
' autocomplete="off" autocorrect="off" autocapitalize="none"' +
|
3892
3913
|
' spellcheck="false" role="textbox" />' +
|
3893
3914
|
'</span>'
|
3894
3915
|
);
|
@@ -3941,7 +3962,7 @@ S2.define('select2/dropdown/search',[
|
|
3941
3962
|
});
|
3942
3963
|
|
3943
3964
|
container.on('focus', function () {
|
3944
|
-
if (container.isOpen()) {
|
3965
|
+
if (!container.isOpen()) {
|
3945
3966
|
self.$search.focus();
|
3946
3967
|
}
|
3947
3968
|
});
|