switchbox 0.0.1 → 1.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59ce04ff9e76e8174b44622b35215e67e6d164a8
4
- data.tar.gz: 023db749cdfcd2077e5089ced6948a427dcdda8a
3
+ metadata.gz: 013764ba5d65fcf36037f67bd0266ef418a698af
4
+ data.tar.gz: 6cd598a63516966df93ef7757135ae32012ba725
5
5
  SHA512:
6
- metadata.gz: d25cf643b468c666a31e1db1a330b8aa3bb589d19f904a632ead2f595d3d438ab242083860a6edf6ca736d97276082a27b635a000bf2f260399128da06c49aee
7
- data.tar.gz: 00f937c3e1986ab831034b857cb34a0a0213290a5417fa32f9b94db84063729ac49aa6d529d88615c67d5697b2ccd71f681f94a797df428bc92f190dff9ea119
6
+ metadata.gz: b68206b3e6639e06840335001bf4677c0440f8c768a4348e5b051e1b82304f2644599cc37aba406ac6a21808d01045982395dbe4549c86bd9b0691df7792bba4
7
+ data.tar.gz: ce96aed6de8f6420dee169a09b9f21b40ca92a98fb0ff3307c33669c294c93618db7903fc16f1267275c7e5276137cfdf3c6ebfa146d0520df31b3e451cbc12e
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Switchbox
2
2
 
3
- TODO: Write a gem description
3
+ An awesome plugin that extends Rails FormBuilder making the boolean fields looks like an awesome animated switch.
4
+ It's switchable, It's draggable, It's switchbox.
4
5
 
5
6
  ## Installation
6
7
 
@@ -16,9 +17,37 @@ Or install it yourself as:
16
17
 
17
18
  $ gem install switchbox
18
19
 
20
+ Add this to application.js
21
+
22
+ //= require switch_rails
23
+
24
+ And add this to application.css
25
+
26
+ *= require switch_rails
27
+
19
28
  ## Usage
20
29
 
21
- TODO: Write usage instructions here
30
+ Instead of:
31
+
32
+ <%= f.check_box :boolean_field %>
33
+
34
+ Use:
35
+
36
+ <%= f.switch_box :boolean_field %>
37
+
38
+ ##customization
39
+
40
+ To override your switch use:
41
+
42
+ outterSwitch' class to modify the outer container
43
+
44
+ 'innerSwitch class to modify the inner switch
45
+
46
+ The first div with 'content' class will be the left option, and the seccond will be the right option.
47
+
48
+ #known bugs
49
+
50
+ You cannot edit the width of the switch yet or the texts inside the 'content' divs. Ill release this fix really soon.
22
51
 
23
52
  ## Contributing
24
53
 
@@ -2,9 +2,10 @@
2
2
 
3
3
  function inicialSetCheckboxesState(checkbox) {
4
4
  var id = checkbox.prop('id');
5
- console.log(checkbox);
6
5
  if (checkbox.prop('value') == 1) {
7
- $('.outterSwitch[data-id=' + id + '] div.innerSwitch').css({left: parseInt($('.outterSwitch[data-id=' + id + '] div.innerSwitch').parent().css('width'),10)/2 });
6
+ var outterWidth = parseInt($('.outterSwitch[data-id=' + id + '] div.innerSwitch').parent().css('width'),10);
7
+ var innerWidth = parseInt($('.outterSwitch[data-id=' + id + '] div.innerSwitch').css('width'),10);
8
+ $('.outterSwitch[data-id=' + id + '] div.innerSwitch').css({left: outterWidth-innerWidth });
8
9
  $('.outterSwitch[data-id=' + id + '] .content[data-onoff=on]').css({ opacity: 1 });
9
10
  $('.outterSwitch[data-id=' + id + '] .content[data-onoff=off]').css({ opacity: 0 });
10
11
  $('.outterSwitch[data-id=' + id + ']').css('background-color', 'red');
@@ -18,11 +19,13 @@ function inicialSetCheckboxesState(checkbox) {
18
19
 
19
20
  function setCheckBoxState(checkbox, state) {
20
21
  var id = checkbox.prop('id');
22
+ var outterWidth = parseInt($('.outterSwitch[data-id=' + id + '] div.innerSwitch').parent().css('width'),10);
23
+ var innerWidth = parseInt($('.outterSwitch[data-id=' + id + '] div.innerSwitch').css('width'),10);
21
24
  if (state == true) {
22
25
  checkbox.prop('checked', true);
23
26
  checkbox.val(1);
24
27
  $('input[name="' + checkbox.prop('name') + '"][type=hidden]').val(1);
25
- $('.outterSwitch[data-id=' + id + '] div.innerSwitch').animate({left: parseInt($('.outterSwitch[data-id=' + id + '] div.innerSwitch').parent().css('width'),10)/2 }, 300);
28
+ $('.outterSwitch[data-id=' + id + '] div.innerSwitch').animate({left: outterWidth-innerWidth }, 300);
26
29
  $('.outterSwitch[data-id=' + id + '] .content[data-onoff=on]').animate({ opacity: 1 }, 300);
27
30
  $('.outterSwitch[data-id=' + id + '] .content[data-onoff=off]').animate({ opacity: 0 }, 300);
28
31
  $('.outterSwitch[data-id=' + id + ']').css('background-color', 'red');
@@ -21,7 +21,7 @@
21
21
  transition: background-color .3s ease;
22
22
  }
23
23
 
24
- .innerSwitch {
24
+ .outterSwitch .innerSwitch {
25
25
  position: relative;
26
26
  left: 0px;
27
27
  width: 25px;
@@ -34,7 +34,7 @@
34
34
  box-shadow: inset 0px 1px 6px 0px rgba(0,0,0,0.45);
35
35
 
36
36
  }
37
- .content {
37
+ .outterSwitch .content {
38
38
  font-family: Arial, Helvetica, sans-serif;
39
39
  font-size: 9px;
40
40
  float: left;
@@ -44,7 +44,7 @@
44
44
  width: 50%;
45
45
  height: 100%;
46
46
  }
47
- .content p {
47
+ .outterSwitch .content p {
48
48
  position: relative;
49
49
  text-align: center;
50
50
  }
@@ -1,3 +1,3 @@
1
1
  module Switchbox
2
- VERSION = "0.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: switchbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Hamdan
@@ -66,7 +66,8 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description: Create switches to boolean fields
69
+ description: An awesome plugin that extends Rails FormBuilder making the boolean fields
70
+ looks like an awesome animated switch
70
71
  email:
71
72
  - ghamdan.eng@gmail.com
72
73
  executables: []
@@ -81,7 +82,7 @@ files:
81
82
  - LICENSE.txt
82
83
  - Rakefile
83
84
  - README.md
84
- homepage: ''
85
+ homepage: https://github.com/Hamdan85/switchbox
85
86
  licenses:
86
87
  - MIT
87
88
  metadata: {}
@@ -104,5 +105,6 @@ rubyforge_project:
104
105
  rubygems_version: 2.1.11
105
106
  signing_key:
106
107
  specification_version: 4
107
- summary: Create switches to boolean fields
108
+ summary: An awesome plugin that extends Rails FormBuilder making the boolean fields
109
+ looks like an awesome animated switch
108
110
  test_files: []