esphinx-rails-ui 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +21 -0
- data/bin/rails +12 -0
- data/config/environments/production.rb +1 -0
- data/config/environments/staging.rb +1 -0
- data/config/initializers/assets.rb +2 -0
- data/esphinx_ui.gemspec +23 -0
- data/lib/assets/javascripts/esphinx/ui/handlers/tabs.js +228 -0
- data/lib/assets/javascripts/esphinx/ui/handlers/tooltip.js +90 -0
- data/lib/assets/javascripts/esphinx/ui/index.js +4 -0
- data/lib/assets/javascripts/esphinx/ui/main.js +17 -0
- data/lib/assets/javascripts/esphinx/ui/panels/autocomplete.js +270 -0
- data/lib/assets/javascripts/esphinx/ui/panels/modal.js +451 -0
- data/lib/assets/javascripts/esphinx/ui/selectors/select.js +238 -0
- data/lib/assets/stylesheets/esphinx/ui/class.sass +13 -0
- data/lib/assets/stylesheets/esphinx/ui/index.sass +1 -0
- data/lib/assets/stylesheets/esphinx/ui/mixins.sass +1 -0
- data/lib/assets/stylesheets/esphinx/ui/modal.sass +61 -0
- data/lib/assets/stylesheets/esphinx/ui/selects.sass +69 -0
- data/lib/assets/stylesheets/esphinx/ui/tabs.sass +14 -0
- data/lib/assets/stylesheets/esphinx/ui/tooltips.sass +17 -0
- data/lib/esphinx-rails-ui.rb +1 -0
- data/lib/esphinx/rails/ui/engine.rb +9 -0
- data/lib/esphinx/rails/ui/version.rb +7 -0
- metadata +97 -0
@@ -0,0 +1,238 @@
|
|
1
|
+
var
|
2
|
+
esPhinx;
|
3
|
+
|
4
|
+
|
5
|
+
(function($, $module) {
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
var
|
9
|
+
CSS_CLASS = "esphinx ui",
|
10
|
+
CSS_CLASS_QUERY = "." + CSS_CLASS.replace(/ +/g, ".");
|
11
|
+
|
12
|
+
|
13
|
+
$module.extend({
|
14
|
+
selectors: {Select: {}}
|
15
|
+
});
|
16
|
+
|
17
|
+
$.Extender.extend($module.selectors.Select, true, {
|
18
|
+
new: function(select, options) {
|
19
|
+
var
|
20
|
+
ConstructorReference = $module.selectors.Select.new,
|
21
|
+
wrapper = $("<div></div>"),
|
22
|
+
caption = $("<div></div>"),
|
23
|
+
optionsPanel = $("<div></div>"),
|
24
|
+
searchTextBox = $("<input></input>"),
|
25
|
+
abstractSelect = $("<ul></ul>"),
|
26
|
+
abstractOptions = [],
|
27
|
+
captionText = $("<div></div>"),
|
28
|
+
selectElement = $(select),
|
29
|
+
optionElements = selectElement.find("option"),
|
30
|
+
|
31
|
+
resolveArguments = function(options) {
|
32
|
+
if(!options) {
|
33
|
+
options = {};
|
34
|
+
}
|
35
|
+
|
36
|
+
if(!options.developmentMode ||
|
37
|
+
typeof options.developmentMode != "boolean") {
|
38
|
+
options.developmentMode = false;
|
39
|
+
}
|
40
|
+
},
|
41
|
+
|
42
|
+
selected = function(select) {
|
43
|
+
return $(select).find("option:checked");
|
44
|
+
},
|
45
|
+
|
46
|
+
toggleCaptionClass = function(caption) {
|
47
|
+
caption.toggleClass("expanded-arrow", "retracted-arrow");
|
48
|
+
},
|
49
|
+
|
50
|
+
reattachFoundListEventListener = function(abstractOptions) {
|
51
|
+
var
|
52
|
+
callback = function(abstractOption) {
|
53
|
+
$(abstractOption.element()).off("click");
|
54
|
+
$(abstractOption.element()).on("click", function() {
|
55
|
+
abstractOption.select();
|
56
|
+
});
|
57
|
+
};
|
58
|
+
|
59
|
+
abstractOptions.forEach(callback);
|
60
|
+
},
|
61
|
+
|
62
|
+
composeOptions = function(optionElements) {
|
63
|
+
var
|
64
|
+
callback = function(option) {
|
65
|
+
option = Option.new({
|
66
|
+
option: option,
|
67
|
+
select: selectElement,
|
68
|
+
caption: caption,
|
69
|
+
captionText: captionText,
|
70
|
+
optionsPanel: optionsPanel,
|
71
|
+
abstractSelect: abstractSelect
|
72
|
+
});
|
73
|
+
|
74
|
+
abstractOptions.push(option);
|
75
|
+
};
|
76
|
+
|
77
|
+
$(optionElements).each(callback);
|
78
|
+
|
79
|
+
reattachFoundListEventListener(abstractOptions);
|
80
|
+
abstractOptions = [];
|
81
|
+
},
|
82
|
+
|
83
|
+
compose = function() {
|
84
|
+
if (!options.developmentMode) {
|
85
|
+
selectElement.hide();
|
86
|
+
}
|
87
|
+
|
88
|
+
wrapper.insertAfter(selectElement);
|
89
|
+
captionText.text(selected(selectElement).text());
|
90
|
+
caption.append(captionText);
|
91
|
+
wrapper.prepend(caption);
|
92
|
+
wrapper.append(optionsPanel);
|
93
|
+
optionsPanel.append(abstractSelect);
|
94
|
+
|
95
|
+
var
|
96
|
+
|
97
|
+
composeSearchTextBox = function() {
|
98
|
+
searchTextBox.attribute("type", "text");
|
99
|
+
optionsPanel.prepend(searchTextBox);
|
100
|
+
|
101
|
+
$.ui.panels.autocomplete.new(searchTextBox,
|
102
|
+
abstractSelect,
|
103
|
+
options.autocomplete,
|
104
|
+
function(found) {
|
105
|
+
composeOptions(found);
|
106
|
+
}
|
107
|
+
);
|
108
|
+
};
|
109
|
+
|
110
|
+
wrapper.addClass(CSS_CLASS + " select");
|
111
|
+
caption.addClass("caption retracted-arrow");
|
112
|
+
optionsPanel.addClass("options-panel");
|
113
|
+
captionText.addClass("text");
|
114
|
+
|
115
|
+
// toggle on click on caption
|
116
|
+
caption.on("click", function() {
|
117
|
+
optionsPanel.toggle();
|
118
|
+
toggleCaptionClass($(this));
|
119
|
+
});
|
120
|
+
|
121
|
+
if (typeof options.searchTextBox == "boolean" &&
|
122
|
+
options.searchTextBox) {
|
123
|
+
composeSearchTextBox();
|
124
|
+
}
|
125
|
+
|
126
|
+
composeOptions(optionElements);
|
127
|
+
},
|
128
|
+
|
129
|
+
attachClickFromOutsideEventListener = function() {
|
130
|
+
var
|
131
|
+
wrapper = $(CSS_CLASS_QUERY + ".select"),
|
132
|
+
optionsPanels = wrapper.find(".options-panel"),
|
133
|
+
captions = wrapper.find(".caption");
|
134
|
+
|
135
|
+
$(window.document).on("click", function(e) {
|
136
|
+
|
137
|
+
if (!$(e.target).parent(CSS_CLASS_QUERY + ".select")
|
138
|
+
.some()) {
|
139
|
+
if (optionsPanels.visible()) {
|
140
|
+
optionsPanels.hide();
|
141
|
+
captions.removeClass("expanded-arrow");
|
142
|
+
captions.addClass("retracted-arrow");
|
143
|
+
}
|
144
|
+
}
|
145
|
+
});
|
146
|
+
},
|
147
|
+
|
148
|
+
addOptions = function(select, optionElements) {
|
149
|
+
var
|
150
|
+
callback = function(optionElement) {
|
151
|
+
select.append(optionElement);
|
152
|
+
};
|
153
|
+
|
154
|
+
$(optionElements).each(callback);
|
155
|
+
},
|
156
|
+
|
157
|
+
replaceSelectOptions = function(select, optionElements) {
|
158
|
+
select.clean();
|
159
|
+
addOptions(select, $(optionElements));
|
160
|
+
},
|
161
|
+
|
162
|
+
Option = {
|
163
|
+
new: function(data) {
|
164
|
+
var
|
165
|
+
option,
|
166
|
+
abstractOption,
|
167
|
+
ConstructorReference = Option.new,
|
168
|
+
select = $(data.select),
|
169
|
+
|
170
|
+
buildAbstractOption = function(li, option) {
|
171
|
+
li = $(li);
|
172
|
+
option = $(option);
|
173
|
+
li.text(option.text());
|
174
|
+
li.attribute("data-value", option
|
175
|
+
.attribute("value"));
|
176
|
+
},
|
177
|
+
|
178
|
+
append = function(abstractOption) {
|
179
|
+
if (abstractOption.tagName() != "option") {
|
180
|
+
data.abstractSelect.append(abstractOption);
|
181
|
+
}
|
182
|
+
};
|
183
|
+
|
184
|
+
if (!(this instanceof ConstructorReference)) {
|
185
|
+
return new ConstructorReference(data);
|
186
|
+
}
|
187
|
+
|
188
|
+
if ($(data.option).tagName() == "option") {
|
189
|
+
option = $(data.option);
|
190
|
+
abstractOption = $("<li></li>");
|
191
|
+
buildAbstractOption(abstractOption, option);
|
192
|
+
append(abstractOption);
|
193
|
+
} else {
|
194
|
+
abstractOption = $(data.option);
|
195
|
+
option = select.find("option[value='" +
|
196
|
+
abstractOption.data("value") + "']");
|
197
|
+
}
|
198
|
+
|
199
|
+
this.select = function() {
|
200
|
+
$(data.captionText).text($(abstractOption)
|
201
|
+
.textContent());
|
202
|
+
select.find("option:checked").unselect();
|
203
|
+
option.select();
|
204
|
+
$(data.optionsPanel).hide();
|
205
|
+
toggleCaptionClass(data.caption);
|
206
|
+
};
|
207
|
+
|
208
|
+
this.element = function() {
|
209
|
+
return abstractOption;
|
210
|
+
};
|
211
|
+
}
|
212
|
+
};
|
213
|
+
|
214
|
+
if (!(this instanceof ConstructorReference)) {
|
215
|
+
return new ConstructorReference(select, options);
|
216
|
+
}
|
217
|
+
|
218
|
+
resolveArguments(options);
|
219
|
+
select = $(select);
|
220
|
+
compose();
|
221
|
+
attachClickFromOutsideEventListener();
|
222
|
+
|
223
|
+
this.addOptions = function(optionElements) {
|
224
|
+
addOptions(select, optionElements);
|
225
|
+
composeOptions(optionElements);
|
226
|
+
};
|
227
|
+
|
228
|
+
this.replaceOptions = function(optionElements) {
|
229
|
+
abstractSelect.clean();
|
230
|
+
replaceSelectOptions(select, optionElements);
|
231
|
+
composeOptions(optionElements);
|
232
|
+
};
|
233
|
+
|
234
|
+
return this;
|
235
|
+
}
|
236
|
+
});
|
237
|
+
|
238
|
+
}(esPhinx, esPhinx.ui));
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require_directory .
|
@@ -0,0 +1 @@
|
|
1
|
+
@import basicss/mixins
|
@@ -0,0 +1,61 @@
|
|
1
|
+
@import mixins
|
2
|
+
|
3
|
+
.esphinx.ui
|
4
|
+
|
5
|
+
&.modal
|
6
|
+
position: absolute
|
7
|
+
top: 0
|
8
|
+
bottom: 0
|
9
|
+
left: 0
|
10
|
+
right: 0
|
11
|
+
|
12
|
+
.mask
|
13
|
+
top: 0
|
14
|
+
bottom: 0
|
15
|
+
left: 0
|
16
|
+
right: 0
|
17
|
+
background-color: black
|
18
|
+
opacity: 0.3
|
19
|
+
|
20
|
+
section
|
21
|
+
+shadow(gray, 3px, 3px, 2px)
|
22
|
+
background: white
|
23
|
+
height: initial
|
24
|
+
width: initial
|
25
|
+
position: fixed !important
|
26
|
+
//alterou a centralização da imagem oO
|
27
|
+
//z-index: 1
|
28
|
+
|
29
|
+
header
|
30
|
+
padding: 5px 10px
|
31
|
+
|
32
|
+
.actions
|
33
|
+
|
34
|
+
display: inline-block
|
35
|
+
|
36
|
+
a
|
37
|
+
color: #ccc
|
38
|
+
font-weight: bold
|
39
|
+
font-size: 20px
|
40
|
+
text-decoration: none
|
41
|
+
|
42
|
+
&.close-button
|
43
|
+
|
44
|
+
&:before
|
45
|
+
content: "×"
|
46
|
+
|
47
|
+
&.hide-button
|
48
|
+
margin-left: 5px
|
49
|
+
|
50
|
+
&:before
|
51
|
+
content: "−"
|
52
|
+
|
53
|
+
&.close-button,
|
54
|
+
&.hide-button
|
55
|
+
&:hover
|
56
|
+
cursor: pointer
|
57
|
+
color: #999
|
58
|
+
|
59
|
+
.main
|
60
|
+
margin: 0
|
61
|
+
text-align: left
|
@@ -0,0 +1,69 @@
|
|
1
|
+
.esphinx.ui
|
2
|
+
&.select
|
3
|
+
display: inline-block
|
4
|
+
|
5
|
+
.caption
|
6
|
+
border: 1px solid
|
7
|
+
padding: 5px
|
8
|
+
display: inline-block
|
9
|
+
|
10
|
+
cursor: pointer
|
11
|
+
|
12
|
+
.text
|
13
|
+
white-space: nowrap
|
14
|
+
overflow-x: hidden
|
15
|
+
text-overflow: ellipsis
|
16
|
+
|
17
|
+
display: inline-block
|
18
|
+
margin-right: 6px
|
19
|
+
|
20
|
+
&::after
|
21
|
+
vertical-align: top
|
22
|
+
display: inline-block
|
23
|
+
margin-right: -4px
|
24
|
+
text-align: center
|
25
|
+
|
26
|
+
&.retracted-arrow
|
27
|
+
&::after
|
28
|
+
content: '▼'
|
29
|
+
|
30
|
+
&.expanded-arrow
|
31
|
+
&::after
|
32
|
+
content: '▲'
|
33
|
+
|
34
|
+
.options-panel
|
35
|
+
display: none
|
36
|
+
border: 1px solid
|
37
|
+
margin-top: -1px
|
38
|
+
padding: 10px
|
39
|
+
|
40
|
+
position: absolute
|
41
|
+
background: white
|
42
|
+
|
43
|
+
ol, ul
|
44
|
+
overflow-y: auto
|
45
|
+
|
46
|
+
background: white
|
47
|
+
|
48
|
+
list-style: none
|
49
|
+
margin: 0
|
50
|
+
|
51
|
+
li
|
52
|
+
cursor: pointer
|
53
|
+
|
54
|
+
white-space: nowrap
|
55
|
+
overflow-x: hidden
|
56
|
+
text-overflow: ellipsis
|
57
|
+
|
58
|
+
padding: 3px 0
|
59
|
+
|
60
|
+
&.list-built-found
|
61
|
+
li
|
62
|
+
&:first-of-type
|
63
|
+
padding-top: 9px
|
64
|
+
|
65
|
+
&.list-built-found
|
66
|
+
background: white
|
67
|
+
|
68
|
+
li
|
69
|
+
cursor: default
|
@@ -0,0 +1 @@
|
|
1
|
+
require "esphinx/rails/ui/engine"
|