gumby 0.0.1
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.
- data/.gitignore +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +73 -0
- data/Rakefile +1 -0
- data/gumby.gemspec +20 -0
- data/lib/gumby.rb +8 -0
- data/lib/gumby/version.rb +5 -0
- data/vendor/assets/fonts/icons/entypo.eot +0 -0
- data/vendor/assets/fonts/icons/entypo.ttf +0 -0
- data/vendor/assets/fonts/icons/entypo.woff +0 -0
- data/vendor/assets/javascripts/gumby.js +150 -0
- data/vendor/assets/javascripts/gumby.min.js +1 -0
- data/vendor/assets/javascripts/ui/gumby.checkbox.js +84 -0
- data/vendor/assets/javascripts/ui/gumby.fittext.js +107 -0
- data/vendor/assets/javascripts/ui/gumby.fixed.js +206 -0
- data/vendor/assets/javascripts/ui/gumby.navbar.js +115 -0
- data/vendor/assets/javascripts/ui/gumby.radiobtn.js +74 -0
- data/vendor/assets/javascripts/ui/gumby.retina.js +74 -0
- data/vendor/assets/javascripts/ui/gumby.skiplink.js +145 -0
- data/vendor/assets/javascripts/ui/gumby.tabs.js +71 -0
- data/vendor/assets/javascripts/ui/gumby.toggleswitch.js +203 -0
- data/vendor/assets/javascripts/ui/jquery.validation.js +138 -0
- data/vendor/assets/stylesheets/gumby.css +1876 -0
- metadata +101 -0
data/.gitignore
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Francesco Serra
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# Gumby Framework - RoR gem
|
2
|
+
|
3
|
+
[Gumby Framework](http://gumbyframework.com/) gem for Rails asset pipeline. Based on Gumby Framework 2.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem "gumby"
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle install
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install gumby
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
You will need to add also the <code>jquery-rails</code> and <code>modernizr-rails</code> gem to your gemfile:
|
22
|
+
|
23
|
+
# Gemfile
|
24
|
+
|
25
|
+
gem "jquery-rails"
|
26
|
+
gem "modernizr-rails"
|
27
|
+
gem "gumby"
|
28
|
+
|
29
|
+
Then run <code>bundle install</code>.
|
30
|
+
|
31
|
+
You will need to add also this tag to your HTML head tag:
|
32
|
+
|
33
|
+
<%= javascript_include_tag :modernizr %>
|
34
|
+
|
35
|
+
#### CSS
|
36
|
+
|
37
|
+
Add this line at the end of your application.css
|
38
|
+
|
39
|
+
*= require gumby
|
40
|
+
|
41
|
+
#### Javascript
|
42
|
+
|
43
|
+
You will need to add jquery and modernizr and global Gumby object in your application.js:
|
44
|
+
|
45
|
+
//= require jquery
|
46
|
+
//= require jquery_ujs
|
47
|
+
//= require modernizr
|
48
|
+
//= require gumby
|
49
|
+
|
50
|
+
or
|
51
|
+
|
52
|
+
//= require gumby.min
|
53
|
+
|
54
|
+
After this line, you can add the Gumby JS plugins; you have available the following plugins:
|
55
|
+
|
56
|
+
//= require ui/gumby.checkbox
|
57
|
+
//= require ui/gumby.fittext
|
58
|
+
//= require ui/gumby.fixed
|
59
|
+
//= require ui/gumby.navbar
|
60
|
+
//= require ui/gumby.radiobtn
|
61
|
+
//= require ui/gumby.retina
|
62
|
+
//= require ui/gumby.skiplink
|
63
|
+
//= require ui/gumby.tabs
|
64
|
+
//= require ui/gumby.toggleswitch
|
65
|
+
//= require ui/jquery.validation
|
66
|
+
|
67
|
+
## Contributing
|
68
|
+
|
69
|
+
1. Fork it
|
70
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
71
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
72
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
73
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/gumby.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "gumby/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "gumby"
|
8
|
+
gem.version = Gumby::Rails::VERSION
|
9
|
+
gem.authors = ["Francesco Serra"]
|
10
|
+
gem.email = ["afnecors@gmail.com"]
|
11
|
+
gem.description = %q{Gumby Framework for Rails}
|
12
|
+
gem.summary = %q{Gumby Framework for Rails}
|
13
|
+
gem.homepage = "http://rubygems.org/gems/gumby"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.require_paths = ["lib"]
|
17
|
+
|
18
|
+
gem.add_dependency "jquery-rails"
|
19
|
+
gem.add_dependency "modernizr-rails"
|
20
|
+
end
|
data/lib/gumby.rb
ADDED
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,150 @@
|
|
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 = 'click';
|
26
|
+
this.onReady = this.onOldie = this.onTouch = false;
|
27
|
+
this.uiModules = {};
|
28
|
+
this.inits = {};
|
29
|
+
|
30
|
+
// check and set path with js/libs default
|
31
|
+
this.path = $('script[gumby-path]').attr('gumby-path') || 'js/libs';
|
32
|
+
|
33
|
+
// check and set breakpoint with 1024 default
|
34
|
+
this.breakpoint = Number($('script[gumby-breakpoint]').attr('gumby-breakpoint')) || 1024;
|
35
|
+
}
|
36
|
+
|
37
|
+
// initialize Gumby
|
38
|
+
Gumby.prototype.init = function() {
|
39
|
+
var scope = this;
|
40
|
+
|
41
|
+
// call ready() code when dom is ready
|
42
|
+
this.$dom.ready(function() {
|
43
|
+
// init UI modules
|
44
|
+
scope.initUIModules();
|
45
|
+
|
46
|
+
if(scope.onReady) {
|
47
|
+
scope.onReady();
|
48
|
+
}
|
49
|
+
|
50
|
+
// call oldie() callback if applicable
|
51
|
+
if(scope.isOldie && scope.onOldie) {
|
52
|
+
scope.onOldie();
|
53
|
+
}
|
54
|
+
|
55
|
+
// call touch() callback if applicable
|
56
|
+
if(Modernizr.touch && scope.onTouch) {
|
57
|
+
scope.onTouch();
|
58
|
+
}
|
59
|
+
});
|
60
|
+
};
|
61
|
+
|
62
|
+
// public helper - set Gumby ready callback
|
63
|
+
Gumby.prototype.ready = function(code) {
|
64
|
+
if(code && typeof code === 'function') {
|
65
|
+
this.onReady = code;
|
66
|
+
}
|
67
|
+
};
|
68
|
+
|
69
|
+
// public helper - set oldie callback
|
70
|
+
Gumby.prototype.oldie = function(code) {
|
71
|
+
if(code && typeof code === 'function') {
|
72
|
+
this.onOldie = code;
|
73
|
+
}
|
74
|
+
};
|
75
|
+
|
76
|
+
// public helper - set touch callback
|
77
|
+
Gumby.prototype.touch = function(code) {
|
78
|
+
if(code && typeof code === 'function') {
|
79
|
+
this.onTouch = code;
|
80
|
+
}
|
81
|
+
};
|
82
|
+
|
83
|
+
// public helper - return debuggin object including uiModules object
|
84
|
+
Gumby.prototype.debug = function() {
|
85
|
+
return {
|
86
|
+
$dom: this.$dom,
|
87
|
+
isOldie: this.isOldie,
|
88
|
+
uiModules: this.uiModules,
|
89
|
+
click: this.click
|
90
|
+
};
|
91
|
+
};
|
92
|
+
|
93
|
+
// grab attribute value, testing data- gumby- and no prefix
|
94
|
+
Gumby.prototype.selectAttr = function() {
|
95
|
+
var i = 0;
|
96
|
+
|
97
|
+
// any number of attributes can be passed
|
98
|
+
for(; i < arguments.length; i++) {
|
99
|
+
// various formats
|
100
|
+
var attr = arguments[i],
|
101
|
+
dataAttr = 'data-'+arguments[i],
|
102
|
+
gumbyAttr = 'gumby-'+arguments[i];
|
103
|
+
|
104
|
+
// first test for data-attr
|
105
|
+
if(this.is('['+dataAttr+']')) {
|
106
|
+
return this.attr(dataAttr) ? this.attr(dataAttr) : true;
|
107
|
+
|
108
|
+
// next test for gumby-attr
|
109
|
+
} else if(this.is('['+gumbyAttr+']')) {
|
110
|
+
return this.attr(gumbyAttr) ? this.attr(gumbyAttr) : true;
|
111
|
+
|
112
|
+
// finally no prefix
|
113
|
+
} else if(this.is('['+attr+']')) {
|
114
|
+
return this.attr(attr) ? this.attr(attr) : true;
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
// none found
|
119
|
+
return false;
|
120
|
+
};
|
121
|
+
|
122
|
+
// add an initialisation method
|
123
|
+
Gumby.prototype.addInitalisation = function(ref, code) {
|
124
|
+
this.inits[ref] = code;
|
125
|
+
};
|
126
|
+
|
127
|
+
// initialize a uiModule
|
128
|
+
Gumby.prototype.initialize = function(ref, all) {
|
129
|
+
if(this.inits[ref] && typeof this.inits[ref] === 'function') {
|
130
|
+
this.inits[ref](all);
|
131
|
+
}
|
132
|
+
};
|
133
|
+
|
134
|
+
// store a UI module
|
135
|
+
Gumby.prototype.UIModule = function(data) {
|
136
|
+
var module = data.module;
|
137
|
+
this.uiModules[module] = data;
|
138
|
+
};
|
139
|
+
|
140
|
+
// loop round and init all UI modules
|
141
|
+
Gumby.prototype.initUIModules = function() {
|
142
|
+
var x;
|
143
|
+
for(x in this.uiModules) {
|
144
|
+
this.uiModules[x].init();
|
145
|
+
}
|
146
|
+
};
|
147
|
+
|
148
|
+
window.Gumby = new Gumby();
|
149
|
+
|
150
|
+
}();
|
@@ -0,0 +1 @@
|
|
1
|
+
!function(){"use strict";function t(){this.$dom=$(document),this.isOldie=!!this.$dom.find("html").hasClass("oldie"),this.click="click",this.onReady=this.onOldie=this.onTouch=!1,this.uiModules={},this.inits={},this.path=$("script[gumby-path]").attr("gumby-path")||"js/libs",this.breakpoint=Number($("script[gumby-breakpoint]").attr("gumby-breakpoint"))||1024}t.prototype.init=function(){var t=this;this.$dom.ready(function(){t.initUIModules(),t.onReady&&t.onReady(),t.isOldie&&t.onOldie&&t.onOldie(),Modernizr.touch&&t.onTouch&&t.onTouch()})},t.prototype.ready=function(t){t&&"function"==typeof t&&(this.onReady=t)},t.prototype.oldie=function(t){t&&"function"==typeof t&&(this.onOldie=t)},t.prototype.touch=function(t){t&&"function"==typeof t&&(this.onTouch=t)},t.prototype.debug=function(){return{$dom:this.$dom,isOldie:this.isOldie,uiModules:this.uiModules,click:this.click}},t.prototype.selectAttr=function(){for(var t=0;t<arguments.length;t++){var i=arguments[t],e="data-"+arguments[t],s="gumby-"+arguments[t];if(this.is("["+e+"]"))return this.attr(e)?this.attr(e):!0;if(this.is("["+s+"]"))return this.attr(s)?this.attr(s):!0;if(this.is("["+i+"]"))return this.attr(i)?this.attr(i):!0}return!1},t.prototype.addInitalisation=function(t,i){this.inits[t]=i},t.prototype.initialize=function(t,i){this.inits[t]&&"function"==typeof this.inits[t]&&this.inits[t](i)},t.prototype.UIModule=function(t){var i=t.module;this.uiModules[i]=t},t.prototype.initUIModules=function(){var t;for(t in this.uiModules)this.uiModules[t].init()},window.Gumby=new t}(),!function(){"use strict";function t(t){this.$el=t;var i=this;this.$el.on(Gumby.click,function(t){t.stopImmediatePropagation(),t.preventDefault(),i.$el.hasClass("checked")?i.update(!1):i.update(!0)}).on("gumby.check",function(){i.update(!0)}).on("gumby.uncheck",function(){i.update(!1)}),i.$el.hasClass("checked")&&i.update(!0)}t.prototype.update=function(t){var i=this.$el.find("input"),e=this.$el.find("span");t?(e.append('<i class="icon-check" />'),i.prop("checked",!0).end().addClass("checked").trigger("gumby.onCheck").trigger("gumby.onChange")):i.prop("checked",!1).end().find("i").remove().end().removeClass("checked").trigger("gumby.onUncheck").trigger("gumby.onChange")},Gumby.addInitalisation("checkboxes",function(){$(".checkbox").each(function(){var i=$(this);return i.data("isCheckbox")?!0:(i.data("isCheckbox",!0),new t(i),void 0)})}),Gumby.UIModule({module:"checkbox",events:["onCheck","onUncheck","onChange","check","uncheck"],init:function(){Gumby.initialize("checkboxes")}})}(),!function(){"use strict";function t(t){this.$el=t,this.rate=0,this.fontSizes={},this.setup();var i=this;this.$el.on("gumby.initialize",function(){i.setup()}),$(window).on("load resize orientationchange",function(){i.resize()})}t.prototype.setup=function(){this.rate=Number(Gumby.selectAttr.apply(this.$el,["rate"]))||1,this.fontSizes=this.parseSizes(Gumby.selectAttr.apply(this.$el,["sizes"]))},t.prototype.resize=function(){this.$el.css("font-size",this.calculateSize())},t.prototype.calculateSize=function(){return Math.max(Math.min(this.$el.width()/(10*this.rate),parseFloat(this.fontSizes.max)),parseFloat(this.fontSizes.min))},t.prototype.parseSizes=function(t){var i={min:Number.NEGATIVE_INFINITY,max:Number.POSITIVE_INFINITY};return t?(t.indexOf("|")>-1&&(t=t.split("|"),i.min=Number(t[0])||i.min,i.max=Number(t[1])||i.max),i.min=Number(t)||i.min,i):i},Gumby.addInitalisation("fittext",function(i){$(".fittext").each(function(){var e=$(this);return e.data("isFittext")&&!i?!0:e.data("isFittext")&&i?(e.trigger("gumby.initialize"),!0):(e.data("isFittext",!0),new t(e),void 0)})}),Gumby.UIModule({module:"fittext",events:[],init:function(){Gumby.initialize("fittext")}})}(),!function(){"use strict";function t(t){this.$el=t,this.fixedPoint="",this.pinPoint=!1,this.offset=0,this.pinOffset=0,this.top=0,this.constrainEl=!0,this.state=!1,this.measurements={left:0,width:0},this.setup();var i=this;$(window).on("scroll load",function(){i.monitorScroll()}),this.$el.on("gumby.initialize",function(){i.setup()})}t.prototype.setup=function(){var t=this;this.fixedPoint=this.parseAttrValue(Gumby.selectAttr.apply(this.$el,["fixed"])),this.pinPoint=Gumby.selectAttr.apply(this.$el,["pin"])||!1,this.offset=Number(Gumby.selectAttr.apply(this.$el,["offset"]))||0,this.pinOffset=Number(Gumby.selectAttr.apply(this.$el,["pinoffset"]))||0,this.top=Number(Gumby.selectAttr.apply(this.$el,["top"]))||0,this.constrainEl=Gumby.selectAttr.apply(this.$el,["constrain"])||!0,"false"===this.constrainEl&&(this.constrainEl=!1),this.$parent=this.$el.parents(".columns, .column, .row"),this.$parent=this.$parent.length?this.$parent.first():!1,this.parentRow=this.$parent?!!this.$parent.hasClass("row"):!1,this.pinPoint&&(this.pinPoint=this.parseAttrValue(this.pinPoint)),this.$parent&&this.constrainEl&&(this.measure(),$(window).resize(function(){t.state&&(t.measure(),t.constrain())}))},t.prototype.monitorScroll=function(){var t=$(window).scrollTop(),i=this.fixedPoint instanceof jQuery?this.fixedPoint.offset().top:this.fixedPoint,e=!1;this.pinPoint&&(e=this.pinPoint instanceof jQuery?this.pinPoint.offset().top:this.pinPoint),this.offset&&(i-=this.offset),this.pinOffset&&(e-=this.pinOffset),t>=i&&"fixed"!==this.state?(!e||e>t)&&this.fix():i>t&&"fixed"===this.state?this.unfix():e&&t>=e&&"pinned"!==this.state&&this.pin()},t.prototype.fix=function(){this.state="fixed",this.$el.css({top:0+this.top}).addClass("fixed").removeClass("unfixed pinned").trigger("gumby.onFixed"),this.$parent&&this.constrain()},t.prototype.unfix=function(){this.state="unfixed",this.$el.addClass("unfixed").removeClass("fixed pinned").trigger("gumby.onUnfixed")},t.prototype.pin=function(){this.state="pinned",this.$el.css({top:this.$el.offset().top}).addClass("pinned fixed").removeClass("unfixed").trigger("gumby.onPinned")},t.prototype.constrain=function(){this.$el.css({left:this.measurements.left,width:this.measurements.width})},t.prototype.measure=function(){var t,i=this.$parent.offset();this.measurements.left=i.left,this.measurements.width=this.$parent.width(),this.parentRow&&(t=Number(this.$parent.css("paddingLeft").replace(/px/,"")),t&&(this.measurements.left+=t))},t.prototype.parseAttrValue=function(t){if($.isNumeric(t))return Number(t);if("top"===t)return this.$el.offset().top;var i=$(t);return i},Gumby.addInitalisation("fixed",function(){$("[data-fixed],[gumby-fixed],[fixed]").each(function(){var i=$(this);return i.data("isFixed")?!0:(i.data("isFixed",!0),new t(i),void 0)})}),Gumby.UIModule({module:"fixed",events:["onFixed","onUnfixed"],init:function(){Gumby.initialize("fixed")}})}(),!function(){"use strict";function t(t){this.$el=t,this.$dropDowns=this.$el.find("li:has(.dropdown)");var i=this;this.$dropDowns.on("tap",this.toggleDropdown).on("swiperight",this.openLink),"#"!==this.$dropDowns.children("a").attr("href")&&this.$dropDowns.children("a").append('<i class="icon-popup"></i>').children("i").on("tap",this.openLink),$(window).on("mousemove touchstart",function(t){t.stopImmediatePropagation(),"mousemove"===t.type&&i.$dropDowns.on("mouseover mouseout",i.toggleDropdown)})}var i=Gumby.$dom.find("html");return!Modernizr.touch||$(window).width()>Gumby.breakpoint?(i.addClass("gumby-no-touch"),void 0):(i.addClass("gumby-touch"),t.prototype.toggleDropdown=function(t){t.stopImmediatePropagation(),t.preventDefault();var i=$(this);i.hasClass("active")?i.removeClass("active"):i.addClass("active")},t.prototype.openLink=function(t){t.stopImmediatePropagation(),t.preventDefault();var i,e,s=$(this);s.is("i")?i=s.parent("a"):s.is("li")&&(i=s.children("a")),e=i.attr("href"),"blank"==i.attr("target")?window.open(e):window.location=e},Gumby.addInitalisation("navbars",function(){$(".navbar").each(function(){var i=$(this);return i.data("isNavbar")?!0:(i.data("isNavbar",!0),new t(i),void 0)})}),Gumby.UIModule({module:"navbar",events:[],init:function(){Gumby.initialize("navbars")}}),void 0)}(),!function(){"use strict";function t(t){this.$el=t;var i=this;this.$el.on(Gumby.click,function(t){t.stopImmediatePropagation(),t.preventDefault(),i.update()}).on("gumby.check",function(){i.update()}),i.$el.hasClass("checked")&&i.update()}t.prototype.update=function(){var t=this.$el.find("input[type=radio]"),i=this.$el.find("span"),e='input[name="'+t.attr("name")+'"]';$(".radio").has(e).removeClass("checked").find("input").prop("checked",!1).end().find("i").remove(),t.prop("checked",!0),i.append('<i class="icon-dot" />'),this.$el.addClass("checked").trigger("gumby.onChange")},Gumby.addInitalisation("radiobtns",function(){$(".radio").each(function(){var i=$(this);return i.data("isRadioBtn")?!0:(i.data("isRadioBtn",!0),new t(i),void 0)})}),Gumby.UIModule({module:"radiobtn",events:["onChange","check"],init:function(){Gumby.initialize("radiobtns")}})}(),!function(){"use strict";function t(t){this.$el=t,this.imageSrc=this.$el.attr("src"),this.retinaSrc=this.fetchRetinaImage(),this.$retinaImg=$(new Image);var i=this;return this.retinaSrc?(this.$retinaImg.attr("src",this.retinaSrc).load(function(){i.retinaImageLoaded()}),void 0):!1}t.prototype.fetchRetinaImage=function(){var t=this.imageSrc,i=this.imageSrc.search(/(\.|\/)(gif|jpe?g|png)$/i);return 0>i?!1:t.substr(0,i)+"@2x"+t.substr(i,t.length)},t.prototype.retinaImageLoaded=function(){this.$el.attr("src",this.$retinaImg.attr("src")).trigger("gumby.onRetina")},Gumby.addInitalisation("retina",function(){!window.devicePixelRatio||window.devicePixelRatio<=1||$("img[data-retina],img[gumby-retina],img[retina]").each(function(){var i=$(this);return i.data("isRetina")?!0:(i.data("isRetina",!0),new t(i),void 0)})}),Gumby.UIModule({module:"retina",events:["onRetina"],init:function(){Gumby.initialize("retina")}})}(),!function(){"use strict";function t(t){this.$el=t,this.targetPos=0,this.duration=0,this.offset=!1,this.easing="",this.update=!1,this.setup();var i=this;this.$el.on(Gumby.click+" gumby.skip",function(t){t.stopImmediatePropagation(),t.preventDefault(),i.update?i.calculateTarget(i.skipTo):i.skipTo()}).on("gumby.initialize",function(){i.setup()})}t.prototype.setup=function(){this.duration=Number(Gumby.selectAttr.apply(this.$el,["duration"]))||200,this.offset=Gumby.selectAttr.apply(this.$el,["offset"])||!1,this.easing=Gumby.selectAttr.apply(this.$el,["easing"])||"swing",this.update=Gumby.selectAttr.apply(this.$el,["update"])?!0:!1,this.calculateTarget()},t.prototype.calculateTarget=function(t){var i,e=Gumby.selectAttr.apply(this.$el,["goto"]);if("top"==e)this.targetPos=0;else if($.isNumeric(e))this.targetPos=Number(e);else{if(i=$(e),!i)return!1;this.targetPos=i.offset().top}t&&t.apply(this)},t.prototype.skipTo=function(){var t=this;$("html,body").animate({scrollTop:this.calculateOffset()},this.duration,this.easing).promise().done(function(){t.$el.trigger("gumby.onComplete")})},t.prototype.calculateOffset=function(){if(!this.offset)return this.targetPos;var t=this.offset.substr(0,1),i=Number(this.offset.substr(1,this.offset.length));return"-"===t?this.targetPos-i:"+"===t?this.targetPos+i:void 0},Gumby.addInitalisation("skiplinks",function(i){$(".skiplink > a, .skip").each(function(){var e=$(this);return e.data("isSkipLink")&&!i?!0:e.data("isSkipLink")&&i?(e.trigger("gumby.initialize"),!0):(e.data("isSkipLink",!0),new t(e),void 0)})}),Gumby.UIModule({module:"skiplink",events:["onComplete","skip"],init:function(){Gumby.initialize("skiplinks")}})}(),!function(){"use strict";function t(t){this.$el=t,this.$nav=this.$el.find("ul.tab-nav > li"),this.$content=this.$el.find(".tab-content");var i=this;this.$nav.children("a").on(Gumby.click,function(t){t.stopImmediatePropagation(),t.preventDefault(),i.click($(this))}),this.$el.on("gumby.set",function(t,e){i.set(t,e)})}t.prototype.click=function(t){var i=t.parent().index();this.$nav.add(this.$content).removeClass("active"),this.$nav.eq(i).add(this.$content.eq(i)).addClass("active"),this.$el.trigger("gumby.onChange",i)},t.prototype.set=function(t,i){this.$nav.eq(i).find("a").trigger(Gumby.click)},Gumby.addInitalisation("tabs",function(){$(".tabs").each(function(){var i=$(this);return i.data("isTabs")?!0:(i.data("isTabs",!0),new t(i),void 0)})}),Gumby.UIModule({module:"tabs",events:["onChange","set"],init:function(){Gumby.initialize("tabs")}})}(),!function(){"use strict";function t(t){this.$el=$(t),this.targets=[],this.on="",this.$el.length&&this.init()}function i(t){this.$el=$(t),this.targets=[],this.on="",this.$el.length&&this.init()}t.prototype.init=function(){var t=this;this.setup(),this.$el.on(this.on,function(i){i.stopImmediatePropagation(),"A"===$(this).prop("tagName")&&i.preventDefault(),t.trigger(t.triggered)}).on("gumby.trigger",function(){t.trigger(t.triggered)}).on("gumby.initialize",function(){t.setup()})},t.prototype.setup=function(){this.targets=this.parseTargets(),this.on=Gumby.selectAttr.apply(this.$el,["on"])||Gumby.click,this.className=Gumby.selectAttr.apply(this.$el,["classname"])||"active"},t.prototype.parseTargets=function(){var t=Gumby.selectAttr.apply(this.$el,["trigger"]),i=0,e=[];return t?(i=t.indexOf("|"),-1===i?[$(t)]:(e=t.split("|"),e.length>1?[$(e[0]),$(e[1])]:[$(e[0])])):!1},t.prototype.triggered=function(){this.$el.trigger("gumby.onTrigger",[this.$el.hasClass(this.className)])},i.prototype=new t,t.prototype.trigger=function(t){this.targets?1==this.targets.length?this.$el.add(this.targets[0]).toggleClass(this.className):this.targets.length>1&&(this.targets[0].hasClass(this.className)?(this.$el.add(this.targets[0]).removeClass(this.className),this.targets[1].addClass(this.className)):(this.targets[1].removeClass(this.className),this.$el.add(this.targets[0]).addClass(this.className))):this.$el.toggleClass(this.className),t&&"function"==typeof t&&t.apply(this)},i.prototype.trigger=function(t){this.targets?1==this.targets.length?this.$el.add(this.targets[0]).addClass(this.className):this.targets.length>1&&(this.$el.add(this.targets[0]).addClass(this.className),this.targets[1].removeClass(this.className)):this.$el.addClass(this.className),t&&"function"==typeof t&&t.apply(this)},Gumby.addInitalisation("toggles",function(i){$(".toggle").each(function(){var e=$(this);return e.data("isToggle")&&!i?!0:(e.data("isToggle")&&i&&e.trigger("gumby.initialize"),e.data("isToggle",!0),new t(e),void 0)})}),Gumby.addInitalisation("switches",function(t){$(".switch").each(function(){var e=$(this);return e.data("isSwitch")&&!t?!0:e.data("isSwitch")&&t?(e.trigger("gumby.initialize"),!0):(e.data("isSwitch",!0),new i(e),void 0)})}),Gumby.UIModule({module:"toggleswitch",events:["trigger","onTrigger"],init:function(){Gumby.initialize("switches"),Gumby.initialize("toggles")}})}(),!function(t){"use strict";function i(t,i){this.$this=t,this.$field=this.$this.parents(".field"),this.req=i||function(){return!!this.$this.val().length};var e=this;this.$this.is("[type=checkbox], [type=radio]")?(this.$field=this.$this.parent("label"),this.$field.on("gumby.onChange",function(){e.validate()})):this.$this.is("select")?(this.$field=this.$this.parents(".picker"),this.$field.on("change",function(){e.validate()})):this.$this.on("blur",function(t){9!==t.which&&e.validate()})}i.prototype.validate=function(){var t=this.req(this.$this);return t?this.$field.removeClass("danger").addClass("success"):this.$field.removeClass("success").addClass("danger"),t},t.fn.validation=function(e){var s=t.extend({submit:!1,fail:!1,required:[]},e),n=[];return this.each(function(){if(!s.required.length)return!1;var e,a=t(this),o=s.required.length;for(e=0;o>e;e++)n.push(new i(a.find('[name="'+s.required[e].name+'"]'),s.required[e].validate||!1));a.on("submit",function(t){var i=!1;if(!a.data("passed")){t.preventDefault();var e,o=n.length;for(e=0;o>e;e++)n[e].validate()||(i=!0);if(i){if(s.fail&&"function"==typeof s.fail)return s.fail(),void 0}else{if(s.submit&&"function"==typeof s.submit)return s.submit(a.serializeArray()),void 0;a.data("passed",!0).submit()}}})})}}(jQuery),Modernizr.load({test:Modernizr.touch,yep:Gumby.path+"/jquery.mobile.custom.min.js",callback:function(){$.mobile&&(window.Gumby.click+=" tap")},complete:function(){window.Gumby.init(),"function"==typeof define&&define.amd&&define(window.Gumby)}});
|
@@ -0,0 +1,84 @@
|
|
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
|
+
// prevent propagation
|
16
|
+
e.stopImmediatePropagation();
|
17
|
+
|
18
|
+
// prevent checkbox checking, we'll do that manually
|
19
|
+
e.preventDefault();
|
20
|
+
|
21
|
+
// check/uncheck
|
22
|
+
if(scope.$el.hasClass('checked')) {
|
23
|
+
scope.update(false);
|
24
|
+
} else {
|
25
|
+
scope.update(true);
|
26
|
+
}
|
27
|
+
}).on('gumby.check', function() {
|
28
|
+
scope.update(true);
|
29
|
+
}).on('gumby.uncheck', function() {
|
30
|
+
scope.update(false);
|
31
|
+
});
|
32
|
+
|
33
|
+
// update any .checked checkboxes on load
|
34
|
+
if(scope.$el.hasClass('checked')) {
|
35
|
+
scope.update(true);
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
// update checkbox, check equals true/false to sepcify check/uncheck
|
40
|
+
Checkbox.prototype.update = function(check) {
|
41
|
+
|
42
|
+
var $input = this.$el.find('input'),
|
43
|
+
$span = this.$el.find('span');
|
44
|
+
|
45
|
+
// check checkbox - check input, add checked class, append <i>
|
46
|
+
if(check) {
|
47
|
+
|
48
|
+
$span.append('<i class="icon-check" />');
|
49
|
+
|
50
|
+
$input.prop('checked', true).end()
|
51
|
+
.addClass('checked')
|
52
|
+
.trigger('gumby.onCheck').trigger('gumby.onChange');
|
53
|
+
|
54
|
+
// uncheck checkbox - uncheck input, remove checked class, remove <i>
|
55
|
+
} else {
|
56
|
+
$input.prop('checked', false).end()
|
57
|
+
.find('i').remove().end()
|
58
|
+
.removeClass('checked').trigger('gumby.onUncheck').trigger('gumby.onChange');
|
59
|
+
}
|
60
|
+
};
|
61
|
+
|
62
|
+
// add initialisation
|
63
|
+
Gumby.addInitalisation('checkboxes', function() {
|
64
|
+
$('.checkbox').each(function() {
|
65
|
+
var $this = $(this);
|
66
|
+
// this element has already been initialized
|
67
|
+
if($this.data('isCheckbox')) {
|
68
|
+
return true;
|
69
|
+
}
|
70
|
+
// mark element as initialized
|
71
|
+
$this.data('isCheckbox', true);
|
72
|
+
new Checkbox($this);
|
73
|
+
});
|
74
|
+
});
|
75
|
+
|
76
|
+
// register UI module
|
77
|
+
Gumby.UIModule({
|
78
|
+
module: 'checkbox',
|
79
|
+
events: ['onCheck', 'onUncheck', 'onChange', 'check', 'uncheck'],
|
80
|
+
init: function() {
|
81
|
+
Gumby.initialize('checkboxes');
|
82
|
+
}
|
83
|
+
});
|
84
|
+
}();
|
@@ -0,0 +1,107 @@
|
|
1
|
+
/**
|
2
|
+
* Gumby FitText
|
3
|
+
*
|
4
|
+
* Adapted from the awesome FitText jQuery plugin
|
5
|
+
* brought to you by Paravel - http://paravelinc.com/
|
6
|
+
*/
|
7
|
+
!function() {
|
8
|
+
|
9
|
+
'use strict';
|
10
|
+
|
11
|
+
function FitText($el) {
|
12
|
+
this.$el = $el;
|
13
|
+
|
14
|
+
this.rate = 0;
|
15
|
+
this.fontSizes = {};
|
16
|
+
|
17
|
+
// set up module based on attributes
|
18
|
+
this.setup();
|
19
|
+
|
20
|
+
var scope = this;
|
21
|
+
|
22
|
+
// re-initialize module
|
23
|
+
this.$el.on('gumby.initialize', function() {
|
24
|
+
scope.setup();
|
25
|
+
});
|
26
|
+
|
27
|
+
// lets go
|
28
|
+
$(window).on('load resize orientationchange', function() {
|
29
|
+
scope.resize();
|
30
|
+
});
|
31
|
+
}
|
32
|
+
|
33
|
+
// set up module based on attributes
|
34
|
+
FitText.prototype.setup = function() {
|
35
|
+
// optional compressor rate
|
36
|
+
this.rate = Number(Gumby.selectAttr.apply(this.$el, ['rate'])) || 1;
|
37
|
+
// optional font sizes (min|max)
|
38
|
+
this.fontSizes = this.parseSizes(Gumby.selectAttr.apply(this.$el, ['sizes']));
|
39
|
+
};
|
40
|
+
|
41
|
+
// apply the resizing
|
42
|
+
FitText.prototype.resize = function() {
|
43
|
+
this.$el.css('font-size', this.calculateSize());
|
44
|
+
};
|
45
|
+
|
46
|
+
// calculate the font size
|
47
|
+
FitText.prototype.calculateSize = function() {
|
48
|
+
return Math.max(Math.min(this.$el.width() / (this.rate*10), parseFloat(this.fontSizes.max)), parseFloat(this.fontSizes.min));
|
49
|
+
};
|
50
|
+
|
51
|
+
// parse size attributes with min|max syntax
|
52
|
+
FitText.prototype.parseSizes = function(attrStr) {
|
53
|
+
var sizes = {
|
54
|
+
min: Number.NEGATIVE_INFINITY,
|
55
|
+
max: Number.POSITIVE_INFINITY
|
56
|
+
};
|
57
|
+
|
58
|
+
// attribute is optional
|
59
|
+
if(!attrStr) { return sizes; }
|
60
|
+
|
61
|
+
// min and/or max specified
|
62
|
+
if(attrStr.indexOf('|') > -1) {
|
63
|
+
attrStr = attrStr.split('|');
|
64
|
+
|
65
|
+
// both are optional
|
66
|
+
sizes.min = Number(attrStr[0]) || sizes.min;
|
67
|
+
sizes.max = Number(attrStr[1]) || sizes.max;
|
68
|
+
}
|
69
|
+
|
70
|
+
// only one value specific without | so use as min
|
71
|
+
sizes.min = Number(attrStr) || sizes.min;
|
72
|
+
|
73
|
+
return sizes;
|
74
|
+
};
|
75
|
+
|
76
|
+
// add initialisation
|
77
|
+
Gumby.addInitalisation('fittext', function(all) {
|
78
|
+
$('.fittext').each(function() {
|
79
|
+
var $this = $(this);
|
80
|
+
|
81
|
+
// this element has already been initialized
|
82
|
+
// and we're only initializing new modules
|
83
|
+
if($this.data('isFittext') && !all) {
|
84
|
+
return true;
|
85
|
+
|
86
|
+
// this element has already been initialized
|
87
|
+
// and we need to reinitialize it
|
88
|
+
} else if($this.data('isFittext') && all) {
|
89
|
+
$this.trigger('gumby.initialize');
|
90
|
+
return true;
|
91
|
+
}
|
92
|
+
|
93
|
+
// mark element as initialized
|
94
|
+
$this.data('isFittext', true);
|
95
|
+
new FitText($this);
|
96
|
+
});
|
97
|
+
});
|
98
|
+
|
99
|
+
// register UI module
|
100
|
+
Gumby.UIModule({
|
101
|
+
module: 'fittext',
|
102
|
+
events: [],
|
103
|
+
init: function() {
|
104
|
+
Gumby.initialize('fittext');
|
105
|
+
}
|
106
|
+
});
|
107
|
+
}();
|