gumby-framework 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,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gumby-framework.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Jorge Coca
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,71 @@
1
+ # Gumby2 Front End Frameword - Rails Gem
2
+
3
+ This is a Rails gem that will install the [Gumby Front End Framework](http://gumbyframework.com/) in your application.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'gumby-framework'
10
+
11
+ And then execute:
12
+
13
+ $ bundle install
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install gumby-framework
18
+
19
+ ## Usage
20
+
21
+ You will need to add also the <code>modernizr-rails</code> gem to your gemfile:
22
+
23
+ # Gemifile
24
+
25
+ gem "modernizr-rails"
26
+ gem "gumby-framework"
27
+
28
+ Then run <code>bundle install</code>.
29
+
30
+ You will need to add also this tag to your HTML head tag:
31
+
32
+ <%= javascript_include_tag :modernizr %>
33
+
34
+ #### CSS
35
+
36
+ Add this line at the end of your application.css
37
+
38
+ *= require gumby
39
+
40
+ #### Javascript
41
+
42
+
43
+ You will need to add first the global Gumby object in your application.js:
44
+
45
+ //= require gumby
46
+
47
+ After this line, you can add the Gumby JS plugins like this:
48
+
49
+ //= require ui/gumby.checkbox
50
+ //= require ui/gumby.radiobtn
51
+
52
+ You have available the following plugins:
53
+
54
+ //= require ui/gumby.checkbox
55
+ //= require ui/gumby.fixed
56
+ //= require ui/gumby.radiobtn
57
+ //= require ui/gumby.retina
58
+ //= require ui/gumby.skiplink
59
+ //= require ui/gumby.tabs
60
+ //= require ui/gumby.toggleswitch
61
+ //= require ui/jquery.validation
62
+
63
+
64
+
65
+ ## Contributing
66
+
67
+ 1. Fork it
68
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
69
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
70
+ 4. Push to the branch (`git push origin my-new-feature`)
71
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gumby-framework/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "gumby-framework"
8
+ gem.version = Gumby::Framework::VERSION
9
+ gem.authors = ["Jorge Coca"]
10
+ gem.email = ["jcoca@redpointtech.com"]
11
+ gem.description = %q{Grumby Framework Gem for Ruby on Rails}
12
+ gem.summary = %q{Grumby Framework - Front End}
13
+ gem.homepage = "http://www.jorgecoca.com"
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
+ gem.add_dependency "jquery-rails"
21
+ gem.add_dependency "modernizr-rails"
22
+ end
@@ -0,0 +1,8 @@
1
+ require "gumby-framework/version"
2
+
3
+ module Gumby
4
+ module Framework
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ module Gumby
2
+ module Framework
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,47 @@
1
+ /* TEAM */
2
+
3
+ Digital Surgeons
4
+ Twitter: @digitalsurgeons
5
+ Twitter: @gumbycss
6
+ Web: www.digitalsurgeons.com
7
+ Web: www.gumbyframework.com
8
+
9
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
10
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
11
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
12
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,:~~~====~,,,,,,,,,,,,,
13
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,=================+,,,,,,,,,,,,,
14
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,:==================,,,,,,,,,,,,,
15
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,+=================:,,,,,,,,,,,,
16
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,==================:,,,,,,,,,,,,
17
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,~=================~,,,,,,,,,,,,
18
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,~=================~,,,,,,,,,,,,
19
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,=================~,,,,,,,,,,,,
20
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,==================,,,,,,,,,,,,
21
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,==================,,,,,,,,,,,,
22
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,==================,,,,,,,,,,,,
23
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,==================,,,,,,,,,,,,
24
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,==================,,,,,,,,,,,,
25
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,~==============:,,,,,,,,,,,,,,
26
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,==========:,,,,,,,,,,,,,,,,,,,
27
+ ,,,,,,,,,,,,,,,,,,,,,,,,:~=========:,,,,,,,,,,,,,,,,,,,,,,,,
28
+ ,,,,,,,,,,,,,,,,,:================,,,,,,,,,,,,,,,,,,,,,,,,,,
29
+ ,,,,,,,,,,,,:=====================,,,,,,,,,,,,,,,,,,,,,,,,,,
30
+ ,,,,,,,,,,,=======================,,,,,,,,,,,,,,,,,,,,,,,,,,
31
+ ,,,,,,,,,,,=======================:,,,,,,,,,,,,,,,,,,,,,,,,,
32
+ ,,,,,,,,,,,=======================~,,,,,,,,,,,,,,,,,,,,,,,,,
33
+ ,,,,,,,,,,,,=~====================~,,,,,,,,,,,,,,,,,,,,,,,,,
34
+ ,,,,,,,,,,,,=~~~~~~~~~~~~~~~~~~~~~=,,,,,,,,,,,,,,,,,,,,,,,,,
35
+ ,,,,,,,,,,,,~~==~~~~~~~~~~~~~~=====,,,,,,,,,,,,,,,,,,,,,,,,,
36
+ ,,,,,,,,,,,,,=~~~~~~~~~~~~~~~~~~~~~,,,,,,,,,,,,,,,,,,,,,,,,,
37
+ ,,,,,,,,,,,,,=~~~~~~~~~~~~~~~~~~~~~,,,,,,,,,,,,,,,,,,,,,,,,,
38
+ ,,,,,,,,,,,,,,~~~~~~~~~~~~~~~~~~~~,,,,,,,,,,,,,,,,,,,,,,,,,,
39
+ ,,,,,,,,,,,,,,~~~~~~~~~~~~~~~~:,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
40
+ ,,,,,,,,,,,,,,~~~~~~~~~~~~~:,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
41
+ ,,,,,,,,,,,,,,,~~~~~~~~,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
42
+ ,,,,,,,,,,,,,,,~~~~:,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
43
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
44
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,..
45
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,....
46
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.....
47
+
@@ -0,0 +1,171 @@
1
+ /**
2
+ * Gumby Framework
3
+ * ---------------
4
+ *
5
+ * Follow @gumbycss on twitter and spread the love.
6
+ * We worked super hard on making this awesome and released it to the web.
7
+ * All we ask is you leave this intact. #gumbyisawesome
8
+ *
9
+ * Gumby Framework
10
+ * http://gumbyframework.com
11
+ *
12
+ * Built with love by your friends @digitalsurgeons
13
+ * http://www.digitalsurgeons.com
14
+ *
15
+ * Free to use under the MIT license.
16
+ * http://www.opensource.org/licenses/mit-license.php
17
+ */
18
+ !function() {
19
+
20
+ 'use strict';
21
+
22
+ function Gumby() {
23
+ this.$dom = $(document);
24
+ this.isOldie = !!this.$dom.find('html').hasClass('oldie');
25
+ this.click = this.detectClickEvent();
26
+ this.uiModules = {};
27
+ this.inits = {};
28
+ this.onReady = false;
29
+ this.onOldie = false;
30
+
31
+ var scope = this;
32
+
33
+ // when document is ready init
34
+ this.$dom.ready(function() {
35
+
36
+ // call oldie callback if available
37
+ if(scope.isOldie && scope.onOldie) {
38
+ scope.onOldie();
39
+ }
40
+
41
+ // init UI modules
42
+ scope.initUIModules();
43
+
44
+ // call ready callback if available
45
+ if(scope.onReady) {
46
+ scope.onReady();
47
+ }
48
+ });
49
+ }
50
+
51
+ // public helper - return debuggin object including uiModules object
52
+ Gumby.prototype.debug = function() {
53
+ return {
54
+ $dom: this.$dom,
55
+ isOldie: this.isOldie,
56
+ uiModules: this.uiModules
57
+ };
58
+ };
59
+
60
+ // public helper - set Gumby ready callback
61
+ Gumby.prototype.ready = function(code) {
62
+ if(code && typeof code === 'function') {
63
+ this.onReady = code;
64
+ }
65
+ };
66
+
67
+ // public helper - set oldie callback
68
+ Gumby.prototype.oldie = function(code) {
69
+ if(code && typeof code === 'function') {
70
+ this.onOldie = code;
71
+ }
72
+ };
73
+
74
+ // grab attribute value, testing data- gumby- and no prefix
75
+ Gumby.prototype.selectAttr = function() {
76
+ var i = 0;
77
+
78
+ // any number of attributes can be passed
79
+ for(; i < arguments.length; i++) {
80
+ // various formats
81
+ var attr = arguments[i],
82
+ dataAttr = 'data-'+arguments[i],
83
+ gumbyAttr = 'gumby-'+arguments[i];
84
+
85
+ // first test for data-attr
86
+ if(this.attr(dataAttr)) {
87
+ return this.attr(dataAttr);
88
+
89
+ // next test for gumby-attr
90
+ } else if(this.attr(gumbyAttr)) {
91
+ return this.attr(gumbyAttr);
92
+
93
+ // finally no prefix
94
+ } else if(this.attr(attr)) {
95
+ return this.attr(attr);
96
+ }
97
+ }
98
+
99
+ // none found
100
+ return false;
101
+ };
102
+
103
+ // add an initialisation method
104
+ Gumby.prototype.addInitalisation = function(ref, code) {
105
+ this.inits[ref] = code;
106
+ };
107
+
108
+ // initialize a uiModule
109
+ Gumby.prototype.initialize = function(ref) {
110
+ if(this.inits[ref] && typeof this.inits[ref] === 'function') {
111
+ this.inits[ref]();
112
+ }
113
+ };
114
+
115
+ // store a UI module
116
+ Gumby.prototype.UIModule = function(data) {
117
+ var module = data.module;
118
+ this.uiModules[module] = data;
119
+ };
120
+
121
+ // loop round and init all UI modules
122
+ Gumby.prototype.initUIModules = function() {
123
+ var x;
124
+ for(x in this.uiModules) {
125
+ this.uiModules[x].init();
126
+ }
127
+ };
128
+
129
+ // use touchy events if available otherwise click
130
+ Gumby.prototype.detectClickEvent = function() {
131
+ if(Modernizr.touch) {
132
+ this.setupTapEvent();
133
+ return 'gumbyTap';
134
+ } else {
135
+ return 'click';
136
+ }
137
+ };
138
+
139
+ // set up gumbyTap jQuery.specialEvent
140
+ Gumby.prototype.setupTapEvent = function() {
141
+ $.event.special.gumbyTap = {
142
+ setup: function(data) {
143
+ $(this).bind('touchstart touchend touchmove', $.event.special.gumbyTap.handler);
144
+ },
145
+
146
+ teardown: function() {
147
+ $(this).unbind('touchstart touchend touchmove', $.event.special.gumbyTap.handler);
148
+ },
149
+
150
+ handler: function(event) {
151
+ var $this = $(this);
152
+ // touch start event so store ref to tap event starting
153
+ if(event.type === 'touchstart') {
154
+ $this.data('gumbyTouchStart', true);
155
+ // touchmove event so cancel tap event
156
+ } else if(event.type === 'touchmove') {
157
+ $this.data('gumbyTouchStart', false);
158
+ // touchend event so if tap event ref still present, we have a tap!
159
+ } else if($this.data('gumbyTouchStart')) {
160
+ $this.data('gumbyTouchStart', false);
161
+ event.type = "gumbyTap";
162
+ $this.click(function(e) { e.stopImmediatePropagation(); });
163
+ $.event.handle.apply(this, arguments);
164
+ }
165
+ }
166
+ };
167
+ };
168
+
169
+ window.Gumby = new Gumby();
170
+
171
+ }();
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Gumby Checkbox
3
+ */
4
+ !function() {
5
+
6
+ 'use strict';
7
+
8
+ function Checkbox($el) {
9
+
10
+ this.$el = $el;
11
+ var scope = this;
12
+
13
+ // listen for click event and custom gumby check/uncheck events
14
+ this.$el.on(Gumby.click, function(e) {
15
+ scope.click(e);
16
+ }).on('gumby.check', function() {
17
+ scope.update(true);
18
+ }).on('gumby.uncheck', function() {
19
+ scope.update(false);
20
+ });
21
+
22
+ // update any .checked checkboxes on load
23
+ if(scope.$el.hasClass('checked')) {
24
+ scope.update(true);
25
+ }
26
+ }
27
+
28
+ // handle checkbox click event
29
+ Checkbox.prototype.click = function(e) {
30
+
31
+ // element responsible for event trigger
32
+ var $target = $(e.target);
33
+
34
+ // prevent propagation
35
+ e.stopPropagation();
36
+
37
+ // prevent checkbox checking, we'll do that manually
38
+ e.preventDefault();
39
+
40
+ // check/uncheck
41
+ if(this.$el.hasClass('checked')) {
42
+ this.update(false);
43
+ } else {
44
+ this.update(true);
45
+ }
46
+ };
47
+
48
+ // update checkbox, check equals true/false to sepcify check/uncheck
49
+ Checkbox.prototype.update = function(check) {
50
+ // check checkbox - check input, add checked class, append <i>
51
+ if(check) {
52
+ this.$el.find('input').attr('checked', true).end()
53
+ .addClass('checked').append('<i class="icon-check" />')
54
+ .trigger('gumby.onCheck').trigger('gumby.onChange');
55
+
56
+ // uncheck checkbox - uncheck input, remove checked class, remove <i>
57
+ } else {
58
+ this.$el.find('input').attr('checked', false).end()
59
+ .find('i').remove().end()
60
+ .removeClass('checked').trigger('gumby.onUncheck').trigger('gumby.onChange');
61
+ }
62
+ };
63
+
64
+ // add initialisation
65
+ Gumby.addInitalisation('checkboxes', function() {
66
+ $('.checkbox').each(function() {
67
+ var $this = $(this);
68
+ // this element has already been initialized
69
+ if($this.data('isCheckbox')) {
70
+ return true;
71
+ }
72
+ // mark element as initialized
73
+ $this.data('isCheckbox', true);
74
+ new Checkbox($this);
75
+ });
76
+ });
77
+
78
+ // register UI module
79
+ Gumby.UIModule({
80
+ module: 'checkbox',
81
+ events: ['onCheck', 'onUncheck', 'onChange', 'check', 'uncheck'],
82
+ init: function() {
83
+ Gumby.initialize('checkboxes');
84
+ }
85
+ });
86
+ }();