epi_js 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Shuo Chen
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,66 @@
1
+ # EpiJS
2
+
3
+ Some jQuery based scripts, including:
4
+
5
+ * A simple AJAX lightbox using Twitter Bootstrap modal
6
+ * A simple Growl-like using Twitter Bootstrap alert
7
+ * A script to hide / show HTML elements based on user input
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'epi_js'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install epi_js
22
+
23
+ ## Usage
24
+
25
+ ### AJAX Modal
26
+ Add to your `app/assets/javascripts/application.js`
27
+
28
+ //= require ajax_modal
29
+ #### Via class
30
+ Add `ajax-modal` class to your link
31
+ #### Via JavaScript
32
+ $.ajaxModal(url);
33
+
34
+ ### Flash Message
35
+ Add to your `app/assets/javascripts/application.js`
36
+
37
+ //= require flash_message
38
+ And to your `app/assets/stylesheets/application.css`
39
+
40
+ *= require flash_message
41
+ #### For Rails flash fessage
42
+ Wrap your flash message in a div with `.flash_messages` class, e.g.
43
+
44
+ .flash-messages
45
+ - unless flash.blank?
46
+ - flash.each do |name, msg|
47
+ .alert.fade{ class: "alert-#{ name == :notice ? 'success' : 'error' }" }
48
+ %a.close{ data: { dismiss: :alert } } ×
49
+ = msg
50
+ #### Via JavaScript
51
+ $.flashAlert(message, alert_class);
52
+ `alert_class` is `alert-notice` etc.
53
+
54
+ ### Visibility Map
55
+ Add to your `app/assets/javascripts/application.js`
56
+
57
+ //= require visibility_map
58
+ #### Via data attributes
59
+ Set `data-visibility-map` of a select box or radio button group to a JSON string, e.g.
60
+
61
+ data-visibility-map='{"foo":"#foo","bar":"#bar"}'
62
+ Or for SimpleForm, use:
63
+
64
+ f.input :some_select, input_html: {data: {visibility_map: {foo: '#foo', bar: '#bar'}}}
65
+
66
+ When the value of the input element is `foo`, the element `#foo` will be visible and `#bar` will be hidden, and vice versa. The value of the JSON key value pair can be any jQuery selectors.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'epi_js/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "epi_js"
8
+ gem.version = EpiJs::VERSION
9
+ gem.authors = ["Shuo Chen"]
10
+ gem.email = ["s.chen@epigenesys.co.uk"]
11
+ gem.description = %q{jQuery scripts used in various projects}
12
+ gem.summary = %q{jQuery scripts used in various projects}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+
21
+ gem.add_dependency 'railties', '>= 3.0'
22
+ gem.add_dependency 'coffee-rails', '>= 3.2'
23
+ gem.add_dependency 'sass-rails', '>= 3.2'
24
+ gem.add_dependency 'bootstrap-sass'
25
+
26
+ gem.add_development_dependency 'bundler', '>= 1.0'
27
+ gem.add_development_dependency 'rails', '>= 3.0'
28
+ end
@@ -0,0 +1,11 @@
1
+ require "epi_js/version"
2
+
3
+ module EpiJs
4
+ module Rails
5
+ if ::Rails.version < '3.1'
6
+ require 'epi_js/railtie'
7
+ else
8
+ require 'epi_js/engine'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ module EpiJs
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module EpiJs
2
+ module Rails
3
+ class Railtie < ::Rails::Railtie
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module EpiJs
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,14 @@
1
+ (($) ->
2
+ $.ajaxModal = (url) ->
3
+ $.get url, (data) ->
4
+ $modal = if $('#modalWindow').size() > 0 then $('#modalWindow') else $('<div>').addClass('modal fade').attr('id', 'modalWindow')
5
+ $modal.html(data).modal().on 'hidden', ->
6
+ $(@).remove()
7
+ .on 'shown', ->
8
+ $(document).trigger('ajax-modal-shown')
9
+ ) jQuery
10
+
11
+ $ ->
12
+ $(document.body).on 'click', 'a.ajax-modal', (e) ->
13
+ e.preventDefault()
14
+ $.ajaxModal $(@).attr('href')
@@ -0,0 +1,16 @@
1
+ (($) ->
2
+ $.flashAlert = (message, type, timeout = 6000) ->
3
+ $alert = $('<div>').addClass("alert fade in #{type}").append($('<a>').data('dismiss', 'alert').addClass('close').html('&times;')).append(message)
4
+ if $('.flash-messages .alert').size() > 2
5
+ clearTimeout $('.flash-messages .alert:last').remove().data('timeout')
6
+ $('.flash-messages').prepend($alert)
7
+ $alert.data 'timeout', setTimeout(->
8
+ $alert.alert('close')
9
+ , timeout)
10
+ true
11
+ ) jQuery
12
+
13
+ $ ->
14
+ if $('.flash-messages .alert').size() > 0
15
+ $('.flash-messages .alert').addClass('in')
16
+ setTimeout("$('.flash-messages .alert').alert('close');", 6000)
@@ -0,0 +1,18 @@
1
+ (($) ->
2
+ $.fn.setVisibility = ->
3
+ @each ->
4
+ unless $(@).data('fieldList')?
5
+ $(@).data 'fieldList', $.unique $.map $(@).data('visibility-map'), (val) -> $(val).get()
6
+
7
+ $toShow = $($(@).data('visibility-map')[$(@).val()])
8
+ $toShow.show().find('input, select, textarea').prop 'disabled', false
9
+
10
+ $($(@).data('fieldList')).not($toShow).hide().find('input, select, textarea').prop 'disabled', true
11
+
12
+ ) jQuery
13
+
14
+ $ ->
15
+ $(document.body).on 'change', '[data-visibility-map]', ->
16
+ $(@).setVisibility()
17
+
18
+ $('input[data-visibility-map]:checked, select[data-visibility-map]').setVisibility()
@@ -0,0 +1,18 @@
1
+ @import 'bootstrap/variables'
2
+ @import 'bootstrap/mixins'
3
+
4
+ .flash-messages
5
+ position: fixed
6
+ margin-top: 60px
7
+ z-index: 1035
8
+ right: 5%
9
+ .alert
10
+ word-wrap: break-word
11
+ width: 200px
12
+ min-height: 30px
13
+ @include box-shadow(0 5px 10px rgba(0,0,0,.2))
14
+ @include buttonBackground(lighten($btnWarningBackground, 5%), lighten($btnWarningBackgroundHighlight, 5%))
15
+ &.alert-success
16
+ @include buttonBackground(lighten($btnSuccessBackground, 5%), lighten($btnSuccessBackgroundHighlight, 5%))
17
+ &.alert-error
18
+ @include buttonBackground(lighten($btnDangerBackground, 5%), lighten($btnDangerBackgroundHighlight, 5%))
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: epi_js
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Shuo Chen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: railties
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: coffee-rails
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '3.2'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '3.2'
46
+ - !ruby/object:Gem::Dependency
47
+ name: sass-rails
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '3.2'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '3.2'
62
+ - !ruby/object:Gem::Dependency
63
+ name: bootstrap-sass
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: bundler
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '1.0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '1.0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rails
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '3.0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '3.0'
110
+ description: jQuery scripts used in various projects
111
+ email:
112
+ - s.chen@epigenesys.co.uk
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - .gitignore
118
+ - Gemfile
119
+ - LICENSE.txt
120
+ - README.md
121
+ - Rakefile
122
+ - epi_js.gemspec
123
+ - lib/epi_js.rb
124
+ - lib/epi_js/engine.rb
125
+ - lib/epi_js/railtie.rb
126
+ - lib/epi_js/version.rb
127
+ - vendor/assets/javascripts/ajax_modal.coffee
128
+ - vendor/assets/javascripts/flash_message.coffee
129
+ - vendor/assets/javascripts/visibility_map.coffee
130
+ - vendor/assets/stylesheets/flash_message.sass
131
+ homepage: ''
132
+ licenses: []
133
+ post_install_message:
134
+ rdoc_options: []
135
+ require_paths:
136
+ - lib
137
+ required_ruby_version: !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ none: false
145
+ requirements:
146
+ - - ! '>='
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ requirements: []
150
+ rubyforge_project:
151
+ rubygems_version: 1.8.25
152
+ signing_key:
153
+ specification_version: 3
154
+ summary: jQuery scripts used in various projects
155
+ test_files: []