form_slider 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: edd640a533865dad7c7bca0a51fb440b33be5bce
4
+ data.tar.gz: 83fa9c67c19373c4cc01855a370761b24ae7e53b
5
+ SHA512:
6
+ metadata.gz: 9014dfc425b654c8eb6265e3dd5fe017e1c15904e2cedf7764dc79a3424f20cd2bfc64e5cf6f46fa3e7107cab4501a24be9b1a0c8ef33b5c6c1f686ca94019bf
7
+ data.tar.gz: aed73188dc5140b92a2bc157a2f5768f2c6d4fcedd96cae98450cfeed01e4786e4c73b657dc09a4054d07a8f79ebbd3bdc3a4894e0eac29d971e0ddd6f69f004
@@ -0,0 +1,20 @@
1
+ Copyright 2013 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.
@@ -0,0 +1,3 @@
1
+ = FormSlider
2
+
3
+ This project rocks and uses MIT-LICENSE.
@@ -0,0 +1,23 @@
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 = 'FormSlider'
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("../spec/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+
22
+ Bundler::GemHelper.install_tasks
23
+
@@ -0,0 +1,48 @@
1
+ $.fn.applyGradient = (position) ->
2
+ position = parseInt(position) - 1
3
+ gradientStyle = ""
4
+ browserVariations = ["-moz-linear-gradient", "linear-gradient", "-o-linear-gradient", "-webkit-linear-gradient", "-ms-linear-gradient"]
5
+ for browser in browserVariations
6
+ gradientStyle += 'background-image: '+browser+'(left, '+@.data('color')+' '+position+'px, white 0%);'
7
+ @.attr('style', gradientStyle)
8
+
9
+ window.sliderInput =
10
+ load: ->
11
+ self = @
12
+ sliders = $('.form-slider')
13
+ sliders.each ->
14
+ currentSlider = $(@)
15
+ currentSliderContainer = currentSlider.parents('.slider-container')
16
+ inputField = currentSliderContainer.find('input[type="text"]')
17
+ sliderValue = self.findDisplayValue(currentSlider, currentSliderContainer)
18
+ currentSlider.slider
19
+ min: currentSlider.data('min'),
20
+ max: currentSlider.data('max'),
21
+ step: currentSlider.data('step'),
22
+ value: inputField.attr('value'),
23
+ create: ->
24
+ currentSliderContainer.find('label').append(currentSlider.data('append'))
25
+ sliderValue.text(inputField.attr('value'))
26
+ currentSlider.applyGradient(currentSlider.find('.ui-slider-handle').css('left'))
27
+ inputField.hide()
28
+ change: ( event, ui ) ->
29
+ inputField.val(ui.value).parents('.slider-container')
30
+ sliderValue.text(ui.value)
31
+ currentSlider.applyGradient(currentSlider.find('.ui-slider-handle').css('left'))
32
+ slide: ( event, ui ) ->
33
+ inputField.val(ui.value).parents('.slider-container')
34
+ sliderValue.text(ui.value)
35
+
36
+ findDisplayValue: (currentSlider, currentSliderContainer)->
37
+ if currentSlider.data('value-display')
38
+ $( currentSlider.data('value-display') )
39
+ else
40
+ currentSliderContainer.find('.val')
41
+
42
+
43
+ $(document).ready ->
44
+ $(document).on "page:load", ->
45
+ sliderInput.load()
46
+ $(document).on "page:festch", ->
47
+ sliderInput.load()
48
+ sliderInput.load()
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,4 @@
1
+ module FormSlider
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module FormSlider
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>FormSlider</title>
5
+ <%= stylesheet_link_tag "form_slider/application", media: "all" %>
6
+ <%= javascript_include_tag "form_slider/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,8 @@
1
+ <%
2
+ rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
3
+ rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
4
+ std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
5
+ %>
6
+ default: <%= std_opts %> features
7
+ wip: --tags @wip:3 --wip features
8
+ rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
@@ -0,0 +1,2 @@
1
+ FormSlider::Engine.routes.draw do
2
+ end
@@ -0,0 +1,5 @@
1
+ require "form_slider/application_helper_additions"
2
+ require "form_slider/engine"
3
+
4
+ module FormSlider
5
+ end
@@ -0,0 +1,16 @@
1
+ require 'form_slider/slider_form_builder'
2
+ require 'form_slider/slider_field_tag'
3
+
4
+ module FormSlider
5
+ module ApplicationHelperAdditions
6
+
7
+ include FormSlider::SliderFormBuilder
8
+ include FormSlider::SliderFieldTag
9
+
10
+ def slider_form_for(object, options = {}, &block)
11
+ options[:builder] = SliderFormForBuilder
12
+ form_for(object, options, &block)
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,11 @@
1
+ module FormSlider
2
+ class Engine < ::Rails::Engine
3
+ initializer 'form_slider.initialize' do
4
+ config.to_prepare do
5
+ ActiveSupport.on_load(:action_view) do
6
+ include FormSlider::ApplicationHelperAdditions
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,25 @@
1
+ module FormSlider
2
+ module Helper
3
+ def slider_label(name, args)
4
+ return '' if args[:label] == false
5
+ name = args[:label][:name] if args[:label] && args[:label][:name]
6
+ name = name.to_s.humanize unless name.instance_of?(String)
7
+ output = ""
8
+ content_tag :label do
9
+ output << concat(name + ' ')
10
+ output << concat(content_tag(:span, '', class: 'val'))
11
+ end
12
+ end
13
+
14
+ def slider_options(name, args)
15
+ options = { class: "form-slider #{name.to_s}" }
16
+ options['data-append'] = args[:label] && args[:label][:append] ? args[:label][:append] : ''
17
+ options['data-min'] = args[:min] || 1
18
+ options['data-max'] = args[:max] || 10
19
+ options['data-step'] = args[:step] || 1
20
+ options['data-color'] = args[:color] || 'white'
21
+ options['data-value-display'] = args[:value_display]
22
+ options
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,18 @@
1
+ require 'form_slider/helper'
2
+
3
+ module FormSlider
4
+ module SliderFieldTag
5
+ include FormSlider::Helper
6
+
7
+ def slider_field_tag(name, value=nil, *args)
8
+ args = args.any? ? args.first : {}
9
+ value = args[:min] if value.blank?
10
+ output = ""
11
+ content_tag :div, class: 'slider-container' do
12
+ output << concat( slider_label(name, args) )
13
+ output << concat( content_tag :div, '', slider_options(name, args) )
14
+ output << concat( text_field_tag(name, value) )
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,22 @@
1
+ require 'form_slider/helper'
2
+
3
+ module FormSlider
4
+ module SliderFormBuilder
5
+ class SliderFormForBuilder < ActionView::Helpers::FormBuilder
6
+ include FormSlider::Helper
7
+
8
+ delegate :content_tag, :tag, :concat, :logger, to: :@template
9
+
10
+ def slider_field(name, *args)
11
+ args = args.any? ? args.first : {}
12
+ value = object.try(name) || args[:min]
13
+ output = ""
14
+ content_tag :div, class: 'slider-container' do
15
+ output << concat( slider_label(name, args) )
16
+ output << concat( content_tag :div, '', slider_options(name, args) )
17
+ output << concat( text_field(name, value: value) )
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ module FormSlider
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,65 @@
1
+ # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
+ # It is recommended to regenerate this file in the future when you upgrade to a
3
+ # newer version of cucumber-rails. Consider adding your own code to a new file
4
+ # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
+ # files.
6
+
7
+
8
+ unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
9
+
10
+ vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
11
+ $LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
12
+
13
+ begin
14
+ require 'cucumber/rake/task'
15
+
16
+ namespace :cucumber do
17
+ Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
18
+ t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
19
+ t.fork = true # You may get faster startup if you set this to false
20
+ t.profile = 'default'
21
+ end
22
+
23
+ Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
24
+ t.binary = vendored_cucumber_bin
25
+ t.fork = true # You may get faster startup if you set this to false
26
+ t.profile = 'wip'
27
+ end
28
+
29
+ Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
30
+ t.binary = vendored_cucumber_bin
31
+ t.fork = true # You may get faster startup if you set this to false
32
+ t.profile = 'rerun'
33
+ end
34
+
35
+ desc 'Run all features'
36
+ task :all => [:ok, :wip]
37
+
38
+ task :statsetup do
39
+ require 'rails/code_statistics'
40
+ ::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features')
41
+ ::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features')
42
+ end
43
+ end
44
+ desc 'Alias for cucumber:ok'
45
+ task :cucumber => 'cucumber:ok'
46
+
47
+ task :default => :cucumber
48
+
49
+ task :features => :cucumber do
50
+ STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
51
+ end
52
+
53
+ # In case we don't have ActiveRecord, append a no-op task that we can depend upon.
54
+ task 'db:test:prepare' do
55
+ end
56
+
57
+ task :stats => 'cucumber:statsetup'
58
+ rescue LoadError
59
+ desc 'cucumber rake task not available (cucumber not installed)'
60
+ task :cucumber do
61
+ abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
62
+ end
63
+ end
64
+
65
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :form_slider do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,218 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: form_slider
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Izhar Gavish
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-07-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 4.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 4.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: coffee-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 4.0.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 4.0.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: jquery-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: jquery-ui-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: capybara-webkit
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: nokogiri
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: cucumber-rails
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: database_cleaner
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: pry
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: sqlite3
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '>='
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '>='
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ description: form_slider enables easy integration of jQuery UI Slider within Rails
168
+ forms, by adding special form helpers
169
+ email:
170
+ - izharg@gmail.com
171
+ executables: []
172
+ extensions: []
173
+ extra_rdoc_files: []
174
+ files:
175
+ - app/assets/javascripts/form_slider/application.js
176
+ - app/assets/javascripts/form_slider.js.coffee
177
+ - app/assets/stylesheets/form_slider/application.css
178
+ - app/controllers/form_slider/application_controller.rb
179
+ - app/helpers/form_slider/application_helper.rb
180
+ - app/views/layouts/form_slider/application.html.erb
181
+ - config/cucumber.yml
182
+ - config/routes.rb
183
+ - lib/form_slider/application_helper_additions.rb
184
+ - lib/form_slider/engine.rb
185
+ - lib/form_slider/helper.rb
186
+ - lib/form_slider/slider_field_tag.rb
187
+ - lib/form_slider/slider_form_builder.rb
188
+ - lib/form_slider/version.rb
189
+ - lib/form_slider.rb
190
+ - lib/tasks/cucumber.rake
191
+ - lib/tasks/form_slider_tasks.rake
192
+ - MIT-LICENSE
193
+ - Rakefile
194
+ - README.rdoc
195
+ homepage: https://github.com/Yud/form_slider
196
+ licenses: []
197
+ metadata: {}
198
+ post_install_message:
199
+ rdoc_options: []
200
+ require_paths:
201
+ - lib
202
+ required_ruby_version: !ruby/object:Gem::Requirement
203
+ requirements:
204
+ - - '>='
205
+ - !ruby/object:Gem::Version
206
+ version: '0'
207
+ required_rubygems_version: !ruby/object:Gem::Requirement
208
+ requirements:
209
+ - - '>='
210
+ - !ruby/object:Gem::Version
211
+ version: '0'
212
+ requirements: []
213
+ rubyforge_project:
214
+ rubygems_version: 2.0.3
215
+ signing_key:
216
+ specification_version: 4
217
+ summary: jQuery UI Slider + Ruby on Rails Forms
218
+ test_files: []