ixCB 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://gemcutter.org"
2
+
3
+ # Specify your gem's dependencies in ixCB.gemspec
4
+ gemspec
data/README ADDED
@@ -0,0 +1,8 @@
1
+ ixCB is just a wrapper for a fancy checkbox transition.
2
+ It uses jquery and rails3.1 asset pipeline.
3
+
4
+ Add <tt>gem 'ixCB'</tt> to your Gemfile as asset.
5
+ After strating the server ixCB adds necessary lines to your application.css and application.js in order to maintain asset pipeline requirements.
6
+
7
+ Now, you are ready to use it! When you add a checkbox use data-on and data-off attributes to label checkbox.
8
+ At one of the javascript file you have included type $("your-checkbox-identifier").ixCB({labels['sth-positive', 'sth-negative']})
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "ixCB/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "ixCB"
7
+ s.version = Ixcb::VERSION
8
+ s.authors = ["gungor"]
9
+ s.email = ["gngr.kck@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{Adds some fancy checkbox option using jquery, and rails 3.1 asset pipeline}
12
+ s.description = %q{Turns your checkboxes to some fancy stuff.}
13
+
14
+ s.rubyforge_project = "ixCB"
15
+
16
+ s.add_development_dependency "rails", "~> 3.1"
17
+ s.add_development_dependency "jquery-rails"
18
+ s.add_development_dependency "thor"
19
+
20
+ s.files = `git ls-files`.split("\n")
21
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
23
+ s.require_paths = ["lib"]
24
+
25
+ # specify any dependencies here; for example:
26
+ # s.add_development_dependency "rspec"
27
+ # s.add_runtime_dependency "rest-client"
28
+ end
@@ -0,0 +1,6 @@
1
+ require "ixCB/version"
2
+ require "ixCB/util"
3
+ require "ixCB/engine"
4
+
5
+
6
+
@@ -0,0 +1,12 @@
1
+ module Ixcb
2
+ class Engine < ::Rails::Engine
3
+ config.before_configuration do
4
+ inc = Util.new
5
+ inc.add_requirement "ixCB", "js"
6
+ inc.add_requirement "ixCB", "css"
7
+ end
8
+ end
9
+
10
+
11
+
12
+ end
@@ -0,0 +1,17 @@
1
+ module Ixcb
2
+ require 'thor/group'
3
+
4
+ class Util < Thor::Group
5
+ include Thor::Actions
6
+
7
+ def add_requirement(name, extension)
8
+ if name
9
+ if extension == "css"
10
+ inject_into_file "app/assets/stylesheets/application.css", " *= require #{name}\n", :after => " *= require_self\n"
11
+ elsif extension == "js"
12
+ inject_into_file "app/assets/javascripts/application.js", "//= require #{name}\n", :after => "//= require jquery\n"
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module Ixcb
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,39 @@
1
+ (($) ->
2
+ $.fn.ixCB = (options) ->
3
+ # default texts
4
+ options = $.extend({ labels: ['ON', 'OFF'] }, options)
5
+
6
+ this.each(
7
+ () ->
8
+ originalCB = $(this)
9
+ labels = []
10
+
11
+ # check if there is any data-on, off value
12
+ if originalCB.data('on')
13
+ labels[0] = originalCB.data('on')
14
+ labels[1] = originalCB.data('off')
15
+ else
16
+ labels = options.labels
17
+
18
+ cbMarkup = $(
19
+ '<span>'
20
+ {
21
+ class: "tzCheckBox #{ if this.checked then 'checked' else ''}"
22
+ html: "<span class=\"tzCBContent\">#{labels[if this.checked then 0 else 1]}</span><span class=\"tzCBPart\"></span>"
23
+ }
24
+ )
25
+ cbMarkup.insertAfter(originalCB.hide())
26
+ console.log( "::" + originalCB )
27
+ cbMarkup.click(
28
+ () ->
29
+ cbMarkup.toggleClass('checked')
30
+ isChecked = cbMarkup.hasClass('checked')
31
+
32
+ originalCB.attr('checked', isChecked)
33
+ cbMarkup.find('.tzCBContent').html(labels[if isChecked then 0 else 1])
34
+
35
+ )
36
+
37
+ originalCB.bind('change', () -> cbMarkup.click())
38
+ )
39
+ )(jQuery)
@@ -0,0 +1,42 @@
1
+ .tzCheckBox{
2
+ background: url('background.png') no-repeat right bottom;
3
+ display: inline-block;
4
+ min-width: 60px;
5
+ height: 33px;
6
+ white-space: nowrap;
7
+ position: relative;
8
+ cursor: pointer;
9
+ margin-left: 14px;
10
+ }
11
+
12
+ .tzCheckBox.checked{
13
+ background-position: top left;
14
+ margin: 0 14px 0 0;
15
+ }
16
+
17
+ .tzCheckBox .tzCBContent{
18
+ color: white;
19
+ line-height: 31px;
20
+ padding-right: 38px;
21
+ text-align: right;
22
+ }
23
+
24
+ .tzCheckBox.checked .tzCBContent{
25
+ padding: 0 0 0 38px;
26
+ text-align: left;
27
+ }
28
+
29
+ .tzCheckBox .tzCBPart{
30
+ background: url('background.png') no-repeat left bottom;
31
+ width: 14px;
32
+ position: absolute;
33
+ top: 0; left: -14px;
34
+ height: 33px;
35
+ overflow: hidden;
36
+ }
37
+
38
+
39
+ .tzCheckBox.checked .tzCBPart{
40
+ background-position: right top;
41
+ left: auto; right: -14px;
42
+ }
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ixCB
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - gungor
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-08-17 00:00:00.000000000 +03:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rails
17
+ requirement: &2153076740 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: '3.1'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: *2153076740
26
+ - !ruby/object:Gem::Dependency
27
+ name: jquery-rails
28
+ requirement: &2153076320 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: *2153076320
37
+ - !ruby/object:Gem::Dependency
38
+ name: thor
39
+ requirement: &2153075860 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *2153075860
48
+ description: Turns your checkboxes to some fancy stuff.
49
+ email:
50
+ - gngr.kck@gmail.com
51
+ executables: []
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - .gitignore
56
+ - Gemfile
57
+ - README
58
+ - Rakefile
59
+ - ixCB.gemspec
60
+ - lib/ixCB.rb
61
+ - lib/ixCB/engine.rb
62
+ - lib/ixCB/util.rb
63
+ - lib/ixCB/version.rb
64
+ - vendor/assets/images/background.png
65
+ - vendor/assets/javascripts/ixCB.js.coffee
66
+ - vendor/assets/stylesheets/ixCB.css.scss
67
+ has_rdoc: true
68
+ homepage: ''
69
+ licenses: []
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubyforge_project: ixCB
88
+ rubygems_version: 1.6.2
89
+ signing_key:
90
+ specification_version: 3
91
+ summary: Adds some fancy checkbox option using jquery, and rails 3.1 asset pipeline
92
+ test_files: []