jquery-benignware-rails 0.0.1 → 0.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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjA4MzA3YmE3MWFlODY4ZGU1Mjg0OTkwNTkxNjVkOWNjM2I2NGVhZg==
4
+ YjM2ZWMzYjM1NDVkOGJmZjE4NThiNTAxNTk4YmNmMzE0Nzk4NTg3ZA==
5
5
  data.tar.gz: !binary |-
6
- YTE1OTI1OGE4ZTQ3MTUxOTNmODEwZjE0Y2I0MWZjZDU1OWU4OTJjYg==
6
+ OThiNzcxZmJmMTQyY2E4Y2I0OWM0NGVlYjk5YjhmN2VlNGQ1NWNiNQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OGY0NGFkN2E3YTY4MWZmN2E1OTc5ZTBkNWNmMzk3YjRkNTZkMWViZTNkNmZk
10
- MzM5ZWMyNGZlMzkzNTA0MWUzNjhlZmRkNTk0NmU5Y2U2NWE4ODU5NTkxZjJl
11
- MTUwMzEzMDQzNWRkZjU4MDAwOTM4YjdjYjJlZTdmMmY0YzQ2NTQ=
9
+ MDQ1YzhmOGRkM2VhZjcxZWNjNzBkNDVlNWM5YTRlZGI4OGU2NzAyNmUzZmYz
10
+ ZjkyZmI5YmM2NTdiZjNjYTZkNGRmNWUwZGQ1YzAzMGQ5NjQ1ZjVkMzMzOWNk
11
+ Mzk3NGY0OTVjNDFlZjM1ZDBiNWVmMjM4Njc4NDdhZGI4MjMxNWI=
12
12
  data.tar.gz: !binary |-
13
- MGZmZTQzNmRhYTI5MmI4MmFlZDgzZDNmNGU3NjdiNzVjYzdhYzUyNmY5ZDgx
14
- Mjg1NDY3NDRjZTc3MTBkZDc3NTVkNWUzZjIyZTIyYWE2NDk4ZjgwMjI5Y2Nm
15
- MjZjZGVkMjEyMDFlZDVmNDE3NDcxNGM0ZTg2ZmUxOTk0MWFlYzE=
13
+ ZTc5ZGYxNjgzNWNmZTdkM2M2MmNkYWNlNjRlYjAyZDgwZmNhNDRiNTBiN2Fm
14
+ NTQwMTNlOTkyOGE0YTEzNzJjN2RhMjBlNjg4NWU5MWI4MjZlZWI2YWI2NWE2
15
+ N2U3ODJiMDI3ZGJlMjRkNzZhM2ExMWUxNjVhMjIyMjQyOWRhMmM=
data/.gitmodules CHANGED
@@ -1,3 +1,9 @@
1
1
  [submodule "submodules/jquery-checkview"]
2
2
  path = submodules/jquery-checkview
3
3
  url = https://github.com/benignware/jquery-checkview
4
+ [submodule "submodules/jquery-back-to-top"]
5
+ path = submodules/jquery-back-to-top
6
+ url = https://github.com/benignware/jquery-back-to-top
7
+ [submodule "submodules/jquery-responsive-text"]
8
+ path = submodules/jquery-responsive-text
9
+ url = https://github.com/benignware/jquery-responsive-text
data/Rakefile CHANGED
@@ -11,31 +11,42 @@ task :clean do
11
11
  end
12
12
 
13
13
  desc "Generate the JavaScript assets"
14
- task :assets => :update do
15
- target_dir = "vendor/assets/javascripts/benignware"
14
+ task :assets do
16
15
 
17
- mkdir_p target_dir
18
16
 
19
- Dir.glob("checkview/src/js/*.js").each do |path|
17
+ js_dir = "vendor/assets/javascripts/benignware"
18
+ mkdir_p js_dir
19
+
20
+ Dir.glob("submodules/*/src/js/*.js").each do |path|
21
+ basename = File.basename(path)
22
+ Rake.rake_output_message 'asset ' + basename
23
+ File.open("#{js_dir}/#{basename}", "w") do |out|
24
+ out.write("\n")
25
+ source_code = File.read(path)
26
+ out.write(source_code)
27
+ end
28
+ end
29
+
30
+ css_dir = "vendor/assets/stylesheets/benignware"
31
+ mkdir_p css_dir
32
+
33
+ Dir.glob("submodules/*/src/css/*.css").each do |path|
20
34
  basename = File.basename(path)
21
35
  Rake.rake_output_message 'asset ' + basename
22
- File.open("#{target_dir}/#{basename}", "w") do |out|
36
+ File.open("#{css_dir}/#{basename}", "w") do |out|
23
37
  out.write("\n")
24
38
  source_code = File.read(path)
25
39
  out.write(source_code)
26
40
  end
27
41
  end
42
+
28
43
  end
29
44
 
30
45
 
31
46
  desc 'Builds the gem'
32
- task :build => [:clean, :assets] do
47
+ task :build => [:update, :clean, :assets] do
33
48
  sh "gem build jquery-benignware-rails.gemspec"
34
49
  end
35
50
 
36
- desc 'Tags version, pushes to remote, and pushes gem'
37
- task :release => :build do
38
- sh "gem push jquery-benignware-rails-#{Jquery::Benignware::Rails::VERSION}.gem"
39
- end
40
51
 
41
52
  task :default => :build
@@ -1,7 +1,7 @@
1
1
  module Jquery
2
2
  module Benignware
3
3
  module Rails
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
6
6
  end
7
- end
7
+ end
@@ -0,0 +1,87 @@
1
+
2
+ // Ensure private scope + aliases
3
+ (function ( $, window) {
4
+
5
+ function getDocHeight(){
6
+ var doc = document;
7
+ return Math.max(Math.max(doc.body.scrollHeight, doc.documentElement.scrollHeight), Math.max(doc.body.offsetHeight, doc.documentElement.offsetHeight), Math.max(doc.body.clientHeight, doc.documentElement.clientHeight));
8
+ };
9
+
10
+
11
+ /**
12
+ * jQuery-Plugin: BackToTop
13
+ *
14
+ * simple "scroll to top"-link
15
+ *
16
+ */
17
+
18
+ var pluginName = 'backToTop';
19
+
20
+ var defaults = {
21
+ duration: 500,
22
+ easing: 'swing',
23
+ autoHide: true
24
+ };
25
+
26
+ var pluginClass = function BackToTop(element, options) {
27
+
28
+ var scrollToTop = this;
29
+
30
+ var $element = $(element);
31
+ var $window = $(window);
32
+
33
+ function resize() {
34
+
35
+ if (options.autoHide) {
36
+ $element.css('display', '');
37
+ var dh = getDocHeight();
38
+ var vh = $window.height();
39
+ if (vh >= dh) {
40
+ $element.css('display', 'none');
41
+ }
42
+
43
+ }
44
+ }
45
+
46
+ function init() {
47
+ $element.css('cursor', 'pointer');
48
+ $element.bind('click', function() {
49
+ $('html,body').animate({
50
+ scrollTop: 0
51
+ }, {
52
+ duration: options.duration,
53
+ easing: options.easing
54
+ });
55
+ });
56
+
57
+ $window.bind('resize', resize);
58
+ }
59
+
60
+ resize();
61
+
62
+ init.call(this);
63
+
64
+ };
65
+
66
+
67
+ // bootstrap plugin
68
+
69
+ $.fn[pluginName] = function(options) {
70
+
71
+ options = $.extend({}, defaults, options);
72
+
73
+ return this.each(function() {
74
+
75
+ if (!$(this).data(pluginName)) {
76
+
77
+ $(this).data(pluginName, new pluginClass(this, options));
78
+
79
+ }
80
+
81
+ return $(this);
82
+
83
+ });
84
+
85
+ };
86
+
87
+ })( jQuery, window );
@@ -0,0 +1,200 @@
1
+
2
+ (function ( $, window) {
3
+
4
+ console.info ('init checkview plugin');
5
+
6
+ var pluginName = 'checkView';
7
+
8
+ var defaults = {
9
+ 'containerClass': 'checkview',
10
+ 'iconClass': 'icon-ok',
11
+ 'autoSubmit': true
12
+ };
13
+
14
+ // TODO: replace with jquery has
15
+ function isChildOf(child, parent) {
16
+ if (parent == child) return false;
17
+ var c = child;
18
+ try {
19
+ while (c) {
20
+ if (child.ownerDocument != null && c == child.ownerDocument.documentElement) return false;
21
+ if (c.parentNode == parent) return true;
22
+ if (c.parentNode == null) return false;
23
+ c = c.parentNode;
24
+ }
25
+ } catch (e) {
26
+ //console.error(e);
27
+ }
28
+ return false;
29
+ }
30
+
31
+ var pluginClass = function CheckView(element, options) {
32
+
33
+ var eventType = 'click';
34
+
35
+ var checkboxView = this;
36
+
37
+ var doc = element.ownerDocument;
38
+
39
+ var $elem = $(element);
40
+ element.tabIndex = "-1";
41
+
42
+ element.style.position = 'absolute';
43
+ element.style.width = '0';
44
+ element.style.height = '0';
45
+
46
+ var nextElement = $(element).next();
47
+ var previousElement = $(element).prev();
48
+ var valueElement = nextElement && nextElement.tagName == "input" && nextElement.type == "hidden" ? nextElement
49
+ : previousElement && previousElement.tagName == "input" && previousElement.type == "hidden" ? previousElement
50
+ : null;
51
+
52
+ var containerView = $(element).parents("." + options.containerClass)[0];
53
+ if (!containerView) {
54
+ containerView = doc.createElement('span');
55
+ element.parentNode.insertBefore(containerView, element);
56
+ }
57
+
58
+ containerView.tabIndex = "0";
59
+ containerView.className = options.containerClass;
60
+ containerView.style.display = 'inline-block';
61
+ containerView.style.lineHeight = "0";
62
+ containerView.style.cursor = "pointer";
63
+
64
+ var checkmarkIcon = doc.createElement('i');
65
+ checkmarkIcon.style.margin = "0";
66
+ checkmarkIcon.className = options.iconClass;
67
+ containerView.appendChild(checkmarkIcon);
68
+
69
+ // private methods
70
+
71
+ function toggleCheckbox() {
72
+ element.checked = !element.checked;
73
+ checkboxView.invalidate();
74
+ }
75
+
76
+ function init() {
77
+
78
+ if (!element.value) {
79
+ element.value = "on";
80
+ }
81
+
82
+ element.style.visibility = "hidden";
83
+ containerView.appendChild(element);
84
+ checkmarkIcon.style.verticalAlign = "top";
85
+
86
+ var $label;
87
+
88
+ $(containerView).bind('keypress', function(event) {
89
+
90
+ if (event.which == 32) {
91
+ element.checked = !element.checked;
92
+ checkboxView.invalidate();
93
+ }
94
+
95
+ if (event.which == 13 && options.autoSubmit) {
96
+ if (element.form) {
97
+ element.form.submit();
98
+ }
99
+ }
100
+
101
+ });
102
+
103
+
104
+ $(element).bind('change', function(event) {
105
+ checkboxView.invalidate();
106
+ window.clearTimeout(toggleClickTimeoutId);
107
+ });
108
+
109
+ $(containerView).parents('label').bind("click", function(event) {
110
+ if (event.target != element && event.target != containerView && !isChildOf(event.target, containerView)) {
111
+ event.stopImmediatePropagation();
112
+ $(containerView).trigger('click');
113
+ }
114
+ });
115
+
116
+ var toggleClickTimeoutId = null;
117
+
118
+ function toggleClick() {
119
+ element.checked = !element.checked;
120
+ $(element).trigger('change');
121
+ }
122
+
123
+ $(containerView).bind("click", function(event) {
124
+ if (event.target != element) {
125
+ window.clearTimeout(toggleClickTimeoutId);
126
+ toggleClickTimeoutId = window.setTimeout(function() {
127
+ toggleClick();
128
+ }, 100);
129
+ event.preventDefault();
130
+ };
131
+ });
132
+
133
+ $(window).bind('resize', function() {
134
+ checkboxView.invalidate();
135
+ });
136
+
137
+ this.invalidate();
138
+
139
+ };
140
+
141
+ function layout() {
142
+ if (element.checked) {
143
+ $(containerView).addClass('checked');
144
+ } else {
145
+ $(containerView).removeClass('checked');
146
+ }
147
+ checkmarkIcon.style.visibility = element.checked ? '' : 'hidden';
148
+ checkmarkIcon.style.position = 'relative';
149
+ checkmarkIcon.style.left = (($(containerView).width() - $(checkmarkIcon).width()) / 2) + 'px';
150
+ checkmarkIcon.style.top = (($(containerView).height() - $(checkmarkIcon).height()) / 2) + 'px';
151
+ };
152
+
153
+ // public methods
154
+
155
+ this.setChecked = function(bool) {
156
+ element.checked = bool;
157
+ if (bool) {
158
+ $(element).attr('checked', 'checked');
159
+ } else {
160
+ $(element).removeAttr('checked');
161
+ }
162
+ this.invalidate();
163
+ };
164
+
165
+ this.isChecked = function() {
166
+ return $(element).is(":checked");
167
+ };
168
+
169
+ this.invalidate = function() {
170
+ layout.call(this);
171
+ };
172
+
173
+ init.call(this);
174
+
175
+ };
176
+
177
+
178
+
179
+
180
+ // bootstrap plugin
181
+
182
+ $.fn[pluginName] = function(options) {
183
+
184
+ options = $.extend({}, defaults, options);
185
+
186
+ return this.each(function() {
187
+
188
+ if (!$(this).data(pluginName)) {
189
+
190
+ $(this).data(pluginName, new pluginClass(this, options));
191
+
192
+ }
193
+
194
+ return $(this);
195
+
196
+ });
197
+
198
+ };
199
+
200
+ })( jQuery, window );
@@ -0,0 +1,106 @@
1
+
2
+ // Ensure private scope + aliases
3
+ (function ( $, window) {
4
+
5
+
6
+ /**
7
+ * jQuery-Plugin for viewport based font-sizing
8
+ *
9
+ * viewport-based font-scaling
10
+ *
11
+ */
12
+
13
+ var pluginName = 'responsiveText';
14
+
15
+ var defaults = {
16
+ 'fontSize': '',
17
+ 'minFontSize': '12px',
18
+ 'maxFontSize': '',
19
+ 'bindResize': true
20
+ };
21
+
22
+ var pluginClass = function ResponsiveText(element, options) {
23
+
24
+ var responsiveText = this;
25
+
26
+
27
+ // private methods
28
+
29
+ /* returns font-size in pixels */
30
+ function parseFontSize(string) {
31
+ if (!string) {
32
+ return 0;
33
+ }
34
+ var fontSize = 0;
35
+
36
+ var matches = string.match(/^(\d+(?:\.\d+)?)(.*)$/);
37
+
38
+ var value = matches ? matches[1] : "";
39
+ var unit = matches ? matches[2] : "";
40
+
41
+ switch (unit) {
42
+
43
+ case 'vw':
44
+ fontSize = $(window).innerWidth() / 100 * value;
45
+ break;
46
+
47
+ case 'vh':
48
+ fontSize = $(window).innerHeight() / 100 * value;
49
+ break;
50
+
51
+ default:
52
+ $(element).css('fontSize', value + unit);
53
+ fontSize = parseFloat($(element).css('fontSize'));
54
+ }
55
+
56
+ return !isNaN(fontSize) ? fontSize : 0;
57
+ }
58
+
59
+ function init() {
60
+
61
+ if (options.bindResize) {
62
+ $(window).bind('resize', function() {
63
+ responsiveText.invalidate();
64
+ });
65
+ }
66
+
67
+ this.invalidate();
68
+ }
69
+
70
+ // public methods
71
+
72
+ this.invalidate = function() {
73
+ var fontSize = parseFontSize(options.fontSize);
74
+ var minFontSize = parseFontSize(options.minFontSize);
75
+ var maxFontSize = parseFontSize(options.maxFontSize);
76
+ fontSize = minFontSize ? Math.max(fontSize, minFontSize) : fontSize;
77
+ fontSize = maxFontSize ? Math.min(fontSize, maxFontSize) : fontSize;
78
+ $(element).css('fontSize', fontSize + "px");
79
+ };
80
+
81
+ init.call(this);
82
+
83
+ };
84
+
85
+
86
+ // bootstrap plugin
87
+
88
+ $.fn[pluginName] = function(options) {
89
+
90
+ options = $.extend({}, defaults, options);
91
+
92
+ return this.each(function() {
93
+
94
+ if (!$(this).data(pluginName)) {
95
+
96
+ $(this).data(pluginName, new pluginClass(this, options));
97
+
98
+ }
99
+
100
+ return $(this);
101
+
102
+ });
103
+
104
+ };
105
+
106
+ })( jQuery, window );
@@ -0,0 +1,18 @@
1
+
2
+ .checkview {
3
+ background-color: #FFFFFF;
4
+ border: 1px solid #CCCCCC;
5
+ box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
6
+ transition: border 0.2s linear 0s, box-shadow 0.2s linear 0s;
7
+ border-radius: 4px;
8
+ color: #555555;
9
+ font-size: 14px;
10
+ padding: 4px;
11
+ vertical-align: middle;
12
+ }
13
+
14
+ .checkview:focus {
15
+ border-color: rgba(82, 168, 236, 0.8);
16
+ box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset, 0 0 8px rgba(82, 168, 236, 0.6);
17
+ outline: 0 none;
18
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jquery-benignware-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - rexblack
@@ -46,6 +46,10 @@ files:
46
46
  - jquery-benignware-rails.gemspec
47
47
  - lib/jquery-benignware-rails.rb
48
48
  - lib/jquery-benignware-rails/version.rb
49
+ - vendor/assets/javascripts/benignware/jquery.backToTop.js
50
+ - vendor/assets/javascripts/benignware/jquery.checkView.js
51
+ - vendor/assets/javascripts/benignware/jquery.responsiveText.js
52
+ - vendor/assets/stylesheets/benignware/bootstrap.checkView.css
49
53
  homepage: ''
50
54
  licenses: []
51
55
  metadata: {}