floating_action 0.0.3
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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +56 -0
- data/Rakefile +37 -0
- data/app/assets/javascripts/floating_action/floating_action.css +32 -0
- data/app/assets/stylesheets/floating_action/floating_action.js +64 -0
- data/lib/floating_action.rb +4 -0
- data/lib/floating_action/engine.rb +4 -0
- data/lib/floating_action/version.rb +3 -0
- data/lib/tasks/floating_action_tasks.rake +4 -0
- metadata +53 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ae5959e97cd436c86c32c84906f5c5d7ea932988
|
4
|
+
data.tar.gz: b34d2f868c2133d440f2116bec8ecf1ef48325ba
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: aaabb5e48cecad9051a259321eee393a2d9101ab82d12bd61311182a5ac7a1afd9a243a7d50233d898a31a22e4185f18e064dfadc951050dcd9d55b2b6c55967
|
7
|
+
data.tar.gz: 8f15d5661413cb43ddebd95912dfe48d33b99ff3ef9586cfb16b117b5e0599c5d3672f997a263c68550a7d9d97c607229862b86423b694b4c2e5643791011caa
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2016 Bruno Porto
|
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/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
Floating Action
|
2
|
+
=======
|
3
|
+
|
4
|
+
[](https://codeclimate.com/github/brunoporto/floating_action)
|
5
|
+
|
6
|
+
Essa GEM fornece acesso ao plugin jQuery para colocar ações como barra flutuante anexa a um container
|
7
|
+
|
8
|
+
# Requisitos
|
9
|
+
|
10
|
+
- jQuery 1.2+
|
11
|
+
|
12
|
+
# Instalação
|
13
|
+
|
14
|
+
Adicione essa linha no Gemfile do projeto:
|
15
|
+
```ruby
|
16
|
+
gem 'floating_action'
|
17
|
+
```
|
18
|
+
|
19
|
+
Adicione a seguinte linha no seu arquivo `application.css`:
|
20
|
+
```css
|
21
|
+
*= require floating_action/floating_action
|
22
|
+
```
|
23
|
+
|
24
|
+
Adicione a seguinte linha no seu arquivo `application.js`:
|
25
|
+
```js
|
26
|
+
//= require floating_action/floating_action
|
27
|
+
```
|
28
|
+
|
29
|
+
Para inicializar o plugin você utilizará o código abaixo:
|
30
|
+
```js
|
31
|
+
var floating_action = new FloatingAction({
|
32
|
+
containerClass: 'floating-container-style',
|
33
|
+
contentClass: 'floating-content-style',
|
34
|
+
direction: 'center'
|
35
|
+
}).init();
|
36
|
+
```
|
37
|
+
|
38
|
+
Seus eventos são baseados em [delegator](https://learn.jquery.com/events/event-delegation/) do jQuery e estão vinculados ao **document**.
|
39
|
+
|
40
|
+
# Utilização
|
41
|
+
|
42
|
+
Para transformar um grupo de ação em barra flutuante você deve adicionar a classe `.float-actions-container` a um elemento e a classe `.float-actions-content` a um elemento filho.
|
43
|
+
Exemplo:
|
44
|
+
```haml
|
45
|
+
%table.table
|
46
|
+
%tr.floating-action-container
|
47
|
+
%td José da Silva
|
48
|
+
%td Empresa XYZ
|
49
|
+
%td.floating-action-content
|
50
|
+
%a{:href => '#'} Editar
|
51
|
+
%a{:href => '#'} Remover
|
52
|
+
```
|
53
|
+
|
54
|
+
## Comportamento
|
55
|
+
|
56
|
+
A barra só aparecerá em resolução acima de 992px onde o dispositivo é considerado DESKTOP, abaixo dessa resolução não haverá modificações no elemento e a barra não aparecerá, mantendo o elemento original com a classe `float-actions-content` visível.
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'FloatingAction'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
Bundler::GemHelper.install_tasks
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'lib'
|
31
|
+
t.libs << 'test'
|
32
|
+
t.pattern = 'test/**/*_test.rb'
|
33
|
+
t.verbose = false
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
task default: :test
|
@@ -0,0 +1,32 @@
|
|
1
|
+
@media (min-width: 992px) {
|
2
|
+
|
3
|
+
.floating-action-container .floating-action-content {
|
4
|
+
display: none !important;
|
5
|
+
}
|
6
|
+
|
7
|
+
.floating-action-container:hover .floating-action-content {
|
8
|
+
display: inline !important;
|
9
|
+
z-index: 99999;
|
10
|
+
position: absolute;
|
11
|
+
padding: 10px;
|
12
|
+
border: none;
|
13
|
+
|
14
|
+
-webkit-border-bottom-right-radius: 6px;
|
15
|
+
-webkit-border-bottom-left-radius: 6px;
|
16
|
+
-moz-border-radius-bottomright: 6px;
|
17
|
+
-moz-border-radius-bottomleft: 6px;
|
18
|
+
border-bottom-right-radius: 6px;
|
19
|
+
border-bottom-left-radius: 6px;
|
20
|
+
}
|
21
|
+
|
22
|
+
.floating-container-style {
|
23
|
+
background-color: #EEEEEE;
|
24
|
+
}
|
25
|
+
.floating-content-style {
|
26
|
+
background-color: #E0E0E0;
|
27
|
+
}
|
28
|
+
.floating-content-style > a {
|
29
|
+
text-decoration: none;
|
30
|
+
}
|
31
|
+
|
32
|
+
}
|
@@ -0,0 +1,64 @@
|
|
1
|
+
(function(window, $) {
|
2
|
+
|
3
|
+
var FloatingAction = function (options) {
|
4
|
+
this.options = options;
|
5
|
+
this.config = null;
|
6
|
+
};
|
7
|
+
|
8
|
+
var _this;
|
9
|
+
|
10
|
+
FloatingAction.prototype = {
|
11
|
+
defaults: {
|
12
|
+
containerClass: 'floating-container-style',
|
13
|
+
contentClass: 'floating-content-style',
|
14
|
+
direction: 'center',
|
15
|
+
debug: false
|
16
|
+
},
|
17
|
+
init: function () {
|
18
|
+
this.config = $.extend({}, this.defaults, this.options);
|
19
|
+
_this = this;
|
20
|
+
$(window).resize(function() {
|
21
|
+
var el = $('.floating-action-content:visible').closest('.floating-action-container');
|
22
|
+
_this.setPosition(el);
|
23
|
+
});
|
24
|
+
$(document).on('mouseover','.floating-action-container', function(){
|
25
|
+
_this.setPosition(this);
|
26
|
+
_this.addStyle(this);
|
27
|
+
});
|
28
|
+
$(document).on('mouseout','.floating-action-container', function(){
|
29
|
+
_this.setPosition(this);
|
30
|
+
_this.removeStyle(this);
|
31
|
+
});
|
32
|
+
},
|
33
|
+
setPosition: function(element) {
|
34
|
+
if (element==undefined) return;
|
35
|
+
var $element = $(element);
|
36
|
+
var $content = $element.find('.floating-action-content');
|
37
|
+
var $parent = $element.parent();
|
38
|
+
var top = ($element.position().top + $element.outerHeight());
|
39
|
+
$content.css({'left': '0px', 'top': top+'px'});
|
40
|
+
if (_this.config.direction=='left' || $parent.width() > $('body').innerWidth()) {
|
41
|
+
var left = $element.position().left;
|
42
|
+
} else {
|
43
|
+
if (_this.config.direction=='right') {
|
44
|
+
var left = ($parent.width() - $content.width());
|
45
|
+
} else {
|
46
|
+
var left = ($parent.outerWidth(true) / 2) - ($content.outerWidth(true) / 2);
|
47
|
+
}
|
48
|
+
}
|
49
|
+
$content.css({'left': left+'px'});
|
50
|
+
},
|
51
|
+
addStyle: function(element) {
|
52
|
+
$(element).addClass(_this.config.containerClass);
|
53
|
+
$(element).find('.floating-action-content').addClass(_this.config.contentClass);
|
54
|
+
},
|
55
|
+
removeStyle: function(element) {
|
56
|
+
$(element).removeClass(_this.config.containerClass);
|
57
|
+
$(element).find('.floating-action-content').removeClass(_this.config.contentClass);
|
58
|
+
}
|
59
|
+
}
|
60
|
+
FloatingAction.defaults = FloatingAction.prototype.defaults;
|
61
|
+
|
62
|
+
window.FloatingAction = FloatingAction;
|
63
|
+
|
64
|
+
})(window, jQuery);
|
metadata
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: floating_action
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bruno Porto
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-25 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Possibilita aplicar ações como barra flutuante anexa a um container
|
14
|
+
email:
|
15
|
+
- brunotporto@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- MIT-LICENSE
|
21
|
+
- README.md
|
22
|
+
- Rakefile
|
23
|
+
- app/assets/javascripts/floating_action/floating_action.css
|
24
|
+
- app/assets/stylesheets/floating_action/floating_action.js
|
25
|
+
- lib/floating_action.rb
|
26
|
+
- lib/floating_action/engine.rb
|
27
|
+
- lib/floating_action/version.rb
|
28
|
+
- lib/tasks/floating_action_tasks.rake
|
29
|
+
homepage: https://github.com/brunoporto/floating_action
|
30
|
+
licenses:
|
31
|
+
- MIT
|
32
|
+
metadata: {}
|
33
|
+
post_install_message:
|
34
|
+
rdoc_options: []
|
35
|
+
require_paths:
|
36
|
+
- lib
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
requirements: []
|
48
|
+
rubyforge_project:
|
49
|
+
rubygems_version: 2.5.1
|
50
|
+
signing_key:
|
51
|
+
specification_version: 4
|
52
|
+
summary: Possibilita aplicar ações como barra flutuante anexa a um container
|
53
|
+
test_files: []
|