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
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3e759a2150c696a4d886df0abb178f4e952df2cb
|
4
|
+
data.tar.gz: 0c18d5ae11605241d059aaaf58eff22d45416387
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 32f937a1fa77efa874c36f2de7b93c6628bb98346dccffe549adcfde1dc6976b760950f1062639c75e1a2dc489eb3640047c11cb0dd8e4a5be2d785908ccc162
|
7
|
+
data.tar.gz: 8f9c0a43caaab3cbfd754e72b4bcac52894e5886f00c41d58956093624d0faea7b9541a527d27bfa6823b369e139b3f396eab7d4586968b6922eade98b709027
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2015 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
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
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'ESphinxRailsUI'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
data/bin/rails
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
|
3
|
+
|
4
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
5
|
+
ENGINE_PATH = File.expand_path('../../lib/esphinx/rails/ui/engine', __FILE__)
|
6
|
+
|
7
|
+
# Set up gems listed in the Gemfile.
|
8
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
9
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
10
|
+
|
11
|
+
require 'rails/all'
|
12
|
+
require 'rails/engine/commands'
|
@@ -0,0 +1 @@
|
|
1
|
+
Rails.application.config.assets.precompile += %w( esphinx/ui.css esphinx/ui.js )
|
@@ -0,0 +1 @@
|
|
1
|
+
Rails.application.config.assets.precompile += %w( esphinx/ui.css esphinx/ui.js )
|
data/esphinx_ui.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
require "esphinx/rails/ui/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "esphinx-rails-ui"
|
7
|
+
spec.version = ESphinx::Rails::UI::VERSION
|
8
|
+
spec.authors = ["Home Labs"]
|
9
|
+
spec.email = ["home-labs@outlook.com"]
|
10
|
+
spec.homepage = "https://rubygemspec.org/gems/esphinx-rails-ui"
|
11
|
+
spec.summary = %q{Summary of ESphinx UI.}
|
12
|
+
spec.description = %q{User Interface plugin for ESphinx.}
|
13
|
+
spec.license = "MIT"
|
14
|
+
spec.test_files = Dir["test/**/*"]
|
15
|
+
|
16
|
+
spec.files = Dir["{bin,config,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md", "esphinx_ui.gemspec"]
|
17
|
+
spec.require_paths = %w{lib vendor}
|
18
|
+
|
19
|
+
# this is just for solve compatibility, but not to install gem
|
20
|
+
spec.add_dependency 'esphinx-rails', '~> 0.2'
|
21
|
+
spec.add_dependency 'basicss-rails', '~> 0.1'
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,228 @@
|
|
1
|
+
// require esphinx_ui
|
2
|
+
|
3
|
+
var
|
4
|
+
esPhinx;
|
5
|
+
|
6
|
+
|
7
|
+
(function($, $module) {
|
8
|
+
"use strict";
|
9
|
+
|
10
|
+
$module.extend({
|
11
|
+
handlers: {tabs: {}}
|
12
|
+
});
|
13
|
+
|
14
|
+
$.Extender.extend($module.handlers.tabs, true, {
|
15
|
+
// new: function(selector, content, options) {
|
16
|
+
new: function(data) {
|
17
|
+
var
|
18
|
+
navs,
|
19
|
+
contents,
|
20
|
+
tabs = [],
|
21
|
+
ConstructorReference = $module.handlers.tabs.new,
|
22
|
+
|
23
|
+
showContentOnload = function(navs, contents) {
|
24
|
+
var
|
25
|
+
id = navs.parent().findHasNotAttr("a", "href")
|
26
|
+
.attribute("id"),
|
27
|
+
content = contents.parent().first()
|
28
|
+
.find(".content#" + id);
|
29
|
+
|
30
|
+
contents.hide();
|
31
|
+
content.show();
|
32
|
+
},
|
33
|
+
|
34
|
+
checkNav = function(target, onload) {
|
35
|
+
var
|
36
|
+
navs,
|
37
|
+
selected,
|
38
|
+
selectOnload;
|
39
|
+
|
40
|
+
navs = $(target).parent("ul").find("li");
|
41
|
+
|
42
|
+
selected = navs.findHasNotAttr("a.selector", "href");
|
43
|
+
|
44
|
+
if (selected.length) {
|
45
|
+
selected.attribute("href", "#");
|
46
|
+
}
|
47
|
+
|
48
|
+
selected.removeClass("selected");
|
49
|
+
$(target).addClass("selected");
|
50
|
+
$(target).removeAttr("href");
|
51
|
+
|
52
|
+
selectOnload = navs.parent("ul.select-onload");
|
53
|
+
if (!onload && selectOnload.length) {
|
54
|
+
window.location.queryParameter('tab', $(target)
|
55
|
+
.attribute("id"));
|
56
|
+
}
|
57
|
+
},
|
58
|
+
|
59
|
+
checkNavOnload = function(selectors) {
|
60
|
+
var
|
61
|
+
tabParam = window.location.queryParameter("tab"),
|
62
|
+
parent = selectors.parent(),
|
63
|
+
href,
|
64
|
+
anchor;
|
65
|
+
|
66
|
+
if (tabParam) {
|
67
|
+
checkNav(parent.find("a#" + tabParam));
|
68
|
+
} else {
|
69
|
+
href = window.location.pathname
|
70
|
+
.match(/[a-z\/\_\-]+[a-z]+/);
|
71
|
+
|
72
|
+
anchor = parent.findHasNotAttr("a", "href");
|
73
|
+
|
74
|
+
if (anchor.length) {
|
75
|
+
checkNav(anchor);
|
76
|
+
} else {
|
77
|
+
checkNav(selectors.asNode(), true);
|
78
|
+
}
|
79
|
+
}
|
80
|
+
},
|
81
|
+
|
82
|
+
resolveNavs = function(navs, options) {
|
83
|
+
var
|
84
|
+
anchor,
|
85
|
+
selectors,
|
86
|
+
tagName = navs.tagName().toLowerCase(),
|
87
|
+
|
88
|
+
callback = function(nav, i) {
|
89
|
+
nav = $(nav);
|
90
|
+
anchor = nav.find("a");
|
91
|
+
|
92
|
+
if (!anchor.count()) {
|
93
|
+
anchor = $("<a></a>");
|
94
|
+
anchor.append(window.document.createTextNode(nav
|
95
|
+
.text()));
|
96
|
+
|
97
|
+
nav.text("");
|
98
|
+
nav.prepend(anchor);
|
99
|
+
}
|
100
|
+
|
101
|
+
i = parseInt(i);
|
102
|
+
anchor.attribute("id", "tab-" + (i + 1));
|
103
|
+
anchor.attribute("class", "selector");
|
104
|
+
anchor.attribute("href", "#");
|
105
|
+
};
|
106
|
+
|
107
|
+
if (tagName != "li" && tagName != "a") {
|
108
|
+
navs = navs.find("li");
|
109
|
+
} else if (tagName == "a") {
|
110
|
+
navs = navs.parent();
|
111
|
+
}
|
112
|
+
|
113
|
+
navs.each(callback);
|
114
|
+
|
115
|
+
selectors = navs.find("a.selector");
|
116
|
+
|
117
|
+
if (options) {
|
118
|
+
if (options.selectOnload) {
|
119
|
+
navs.parent("ul").addClass("select-onload");
|
120
|
+
}
|
121
|
+
} else {
|
122
|
+
$(selectors.asNode()).removeAttr("href");
|
123
|
+
}
|
124
|
+
|
125
|
+
return selectors;
|
126
|
+
},
|
127
|
+
|
128
|
+
resolveContents = function(contents, navs) {
|
129
|
+
var
|
130
|
+
contentTagName = contents.tagName().toLowerCase(),
|
131
|
+
|
132
|
+
callback = function(content, i) {
|
133
|
+
i = parseInt(i);
|
134
|
+
content.id = "tab-" + (i + 1);
|
135
|
+
content.classList.add("content");
|
136
|
+
};
|
137
|
+
|
138
|
+
if (contentTagName != "li") {
|
139
|
+
contents = contents.find("li");
|
140
|
+
}
|
141
|
+
|
142
|
+
contents.each(callback);
|
143
|
+
|
144
|
+
showContentOnload(navs, contents);
|
145
|
+
},
|
146
|
+
|
147
|
+
init = function(navs, contents, options) {
|
148
|
+
if (contents) {
|
149
|
+
if (options) {
|
150
|
+
if (options.selectOnload) {
|
151
|
+
checkNavOnload(navs);
|
152
|
+
}
|
153
|
+
}
|
154
|
+
resolveContents(contents, navs);
|
155
|
+
} else {
|
156
|
+
checkNavOnload(navs);
|
157
|
+
}
|
158
|
+
},
|
159
|
+
|
160
|
+
showContent = function(target, content) {
|
161
|
+
var
|
162
|
+
contents = $(content).parent("ul")
|
163
|
+
.find(".content");
|
164
|
+
contents.hide();
|
165
|
+
content.show();
|
166
|
+
},
|
167
|
+
|
168
|
+
map = function(navs, contents, options) {
|
169
|
+
var
|
170
|
+
callback = function(a) {
|
171
|
+
tabs.push({
|
172
|
+
// to set event
|
173
|
+
handler: a,
|
174
|
+
tab: Tab.new(a, contents.parent()
|
175
|
+
.find(".content#" + a.id))
|
176
|
+
});
|
177
|
+
};
|
178
|
+
|
179
|
+
if (navs && navs instanceof $ && navs.some()) {
|
180
|
+
navs = resolveNavs(navs, options);
|
181
|
+
init(navs, contents, options);
|
182
|
+
navs.each(callback);
|
183
|
+
}
|
184
|
+
},
|
185
|
+
|
186
|
+
Tab = {
|
187
|
+
new: function(handler, content) {
|
188
|
+
|
189
|
+
var
|
190
|
+
ConstructorReference = Tab.new;
|
191
|
+
|
192
|
+
if (!(this instanceof ConstructorReference)) {
|
193
|
+
return new ConstructorReference(handler, content);
|
194
|
+
}
|
195
|
+
|
196
|
+
this.select = function() {
|
197
|
+
checkNav(handler);
|
198
|
+
showContent(handler, content);
|
199
|
+
};
|
200
|
+
}
|
201
|
+
};
|
202
|
+
|
203
|
+
if (!(this instanceof ConstructorReference)) {
|
204
|
+
return new ConstructorReference(data);
|
205
|
+
}
|
206
|
+
|
207
|
+
navs = data.selectors;
|
208
|
+
contents = data.contents;
|
209
|
+
|
210
|
+
map(navs, contents, data.options);
|
211
|
+
|
212
|
+
this.all = function() {
|
213
|
+
return tabs;
|
214
|
+
};
|
215
|
+
|
216
|
+
this.addTabs = function() {
|
217
|
+
|
218
|
+
};
|
219
|
+
|
220
|
+
this.replaceContent = function() {
|
221
|
+
|
222
|
+
};
|
223
|
+
|
224
|
+
return this;
|
225
|
+
}
|
226
|
+
});
|
227
|
+
|
228
|
+
}(esPhinx, esPhinx.ui));
|
@@ -0,0 +1,90 @@
|
|
1
|
+
// require esphinx/support/object
|
2
|
+
// require esphinx_ui
|
3
|
+
|
4
|
+
var
|
5
|
+
esPhinx;
|
6
|
+
|
7
|
+
|
8
|
+
(function($, $module) {
|
9
|
+
"use strict";
|
10
|
+
|
11
|
+
var
|
12
|
+
resolveArguments = function(colletion, options) {
|
13
|
+
if (options.addClass) {
|
14
|
+
colletion.addClass(options.addClass);
|
15
|
+
}
|
16
|
+
|
17
|
+
if (options.removeClass) {
|
18
|
+
colletion.addClass(options.removeClass);
|
19
|
+
}
|
20
|
+
},
|
21
|
+
|
22
|
+
hide = function(colletion, options) {
|
23
|
+
// faltam testes para suporte a estilização. Talvez tenha de mapear as propriedades do css para ver se há transition, o tipo, caso tenha pegar os ms para usar no setTimeout
|
24
|
+
colletion.hide();
|
25
|
+
|
26
|
+
if (options) {
|
27
|
+
resolveArguments(colletion, options);
|
28
|
+
}
|
29
|
+
};
|
30
|
+
|
31
|
+
$module.extend({
|
32
|
+
handlers: {tooltip: {}}
|
33
|
+
});
|
34
|
+
|
35
|
+
$.Extender.extend($module.handlers.tooltip, true, {
|
36
|
+
hideAll: function(e, tooltipClass, options) {
|
37
|
+
var
|
38
|
+
target = $(e.target),
|
39
|
+
|
40
|
+
closeAll = function(colletion, options) {
|
41
|
+
hide(colletion, options);
|
42
|
+
};
|
43
|
+
|
44
|
+
if (target.childElements(tooltipClass).count() === 0 &&
|
45
|
+
!target.is(tooltipClass)) {
|
46
|
+
closeAll(target.find(tooltipClass), options);
|
47
|
+
}
|
48
|
+
},
|
49
|
+
|
50
|
+
new: function(tooltip, options) {
|
51
|
+
var
|
52
|
+
ConstructorReference = $module.handlers.tooltip.new,
|
53
|
+
|
54
|
+
show = function(colletion, options) {
|
55
|
+
colletion.show();
|
56
|
+
|
57
|
+
if (options) {
|
58
|
+
resolveArguments(colletion, options);
|
59
|
+
}
|
60
|
+
};
|
61
|
+
|
62
|
+
|
63
|
+
if (!(this instanceof ConstructorReference)) {
|
64
|
+
return new ConstructorReference(tooltip, options);
|
65
|
+
}
|
66
|
+
|
67
|
+
|
68
|
+
// when click on son, the parent too will answer, because son it is contained in parent
|
69
|
+
this.toggle = function(e) {
|
70
|
+
var
|
71
|
+
target = $(e.target);
|
72
|
+
|
73
|
+
// debugger
|
74
|
+
if (!target.is(tooltip)) {
|
75
|
+
tooltip.css("position", "absolute");
|
76
|
+
|
77
|
+
if (tooltip.visible()) {
|
78
|
+
hide(tooltip, options);
|
79
|
+
}
|
80
|
+
else {
|
81
|
+
show(tooltip, options);
|
82
|
+
}
|
83
|
+
|
84
|
+
// toggle(tooltip, options);
|
85
|
+
}
|
86
|
+
};
|
87
|
+
}
|
88
|
+
});
|
89
|
+
|
90
|
+
})(esPhinx, esPhinx.ui);
|