google-buttons-sass 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. data/LICENSE +14 -0
  2. data/README.md +91 -0
  3. data/lib/google-buttons-sass/compass_functions.rb +10 -0
  4. data/lib/google-buttons-sass/engine.rb +7 -0
  5. data/lib/google-buttons-sass/rails_functions.rb +14 -0
  6. data/lib/google-buttons-sass.rb +43 -0
  7. data/templates/project/manifest.rb +17 -0
  8. data/templates/project/styles.scss +3 -0
  9. data/vendor/assets/images/checkmark.png +0 -0
  10. data/vendor/assets/images/grey-disclosure-arrow-up-down.png +0 -0
  11. data/vendor/assets/javascripts/bootstrap-popover.js +98 -0
  12. data/vendor/assets/javascripts/google-buttons.js +3 -0
  13. data/vendor/assets/javascripts/google-select-dropdown.js +89 -0
  14. data/vendor/assets/javascripts/google-select.js +84 -0
  15. data/vendor/assets/stylesheets/alerts.scss +21 -0
  16. data/vendor/assets/stylesheets/bootstrap-mixins.scss +625 -0
  17. data/vendor/assets/stylesheets/breadcrumbs.scss +8 -0
  18. data/vendor/assets/stylesheets/button-groups.scss +124 -0
  19. data/vendor/assets/stylesheets/buttons.scss +396 -0
  20. data/vendor/assets/stylesheets/dropdowns.scss +95 -0
  21. data/vendor/assets/stylesheets/forms.scss +229 -0
  22. data/vendor/assets/stylesheets/google-buttons.scss +42 -0
  23. data/vendor/assets/stylesheets/mixins.scss +44 -0
  24. data/vendor/assets/stylesheets/navs.scss +76 -0
  25. data/vendor/assets/stylesheets/pager.scss +40 -0
  26. data/vendor/assets/stylesheets/pagination.scss +68 -0
  27. data/vendor/assets/stylesheets/popovers.scss +36 -0
  28. data/vendor/assets/stylesheets/progress-bars.scss +7 -0
  29. data/vendor/assets/stylesheets/scrollbars.scss +43 -0
  30. data/vendor/assets/stylesheets/sprites.scss +12 -0
  31. data/vendor/assets/stylesheets/tooltip.scss +10 -0
  32. data/vendor/assets/stylesheets/variables.scss +199 -0
  33. data/vendor/assets/stylesheets/wells.scss +17 -0
  34. metadata +127 -0
data/LICENSE ADDED
@@ -0,0 +1,14 @@
1
+ Copyright 2011 Twitter, Inc.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+
data/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # Google Buttons for Sass
2
+ ## Based on [Thomas McDonald's Bootstrap-sass](https://github.com/thomas-mcdonald/bootstrap-sass) and [CSS3 Google Buttons by Tim O'Donnell](https://github.com/todc/css3-google-buttons)
3
+
4
+ `google-buttons-sass` is an Sass-powered version of [CSS3 Google Buttons by Tim O'Donnell](https://github.com/todc/css3-google-buttons), ready to drop right into your Sass powered applications.
5
+
6
+ This project requires [Twitter Bootstra](http://twitter.github.com/bootstrap), which can be installed via gem `bootstrap-sass`
7
+
8
+ Enjoy.
9
+
10
+ ## Usage
11
+
12
+ ### Rails
13
+
14
+ In your Gemfile:
15
+
16
+ gem 'sass-rails', '~> 3.1'
17
+ gem 'bootstrap-sass', '~> 2.0.4.0'
18
+ gem 'google-butons-sass', '~> 1.0'
19
+
20
+ #### CSS
21
+
22
+ Import "google-buttons" in your SCSS file of choice to get all of the styles, mixins and variables! We recommend against using `//= require` directives, since none of your other stylesheets will be [able to use](https://github.com/thomas-mcdonald/bootstrap-sass/issues/79#issuecomment-4428595) the awesome mixins that Bootstrap has defined.
23
+
24
+ @import "google-buttons";
25
+
26
+ #### Javascripts
27
+
28
+ You can include the javascript through two methods. In this case, Sprocket's `//= require` directives are useful, since there is no better alternative.
29
+
30
+ We have a helper that includes all available javascripts:
31
+
32
+ //= require google-buttons
33
+
34
+ You can also load individual modules, provided you sort out any related dependencies.
35
+
36
+ //= require bootstrap-popover (overrides Twitter Bootstrap's popover)
37
+ //= require google-select-dropdown
38
+ //= require google-select
39
+
40
+ ### Compass
41
+
42
+ `google-buttons-sass`, thanks to Thomas's work on bootstrap-sass, comes with support for Compass, meaning projects that don't use Rails can get in on the fun Bootstrap web.
43
+
44
+ #### New project
45
+
46
+ Install the gem and create a new project using the gem.
47
+
48
+ gem install google-buttons-sass
49
+ compass create compass-test -r google-buttons-sass --using google-buttons
50
+
51
+ This will sort a few things out:
52
+
53
+ * You'll get a starting `styles.scss` ready for your alterations
54
+ * You'll get a compiled stylesheet compiled & ready to drop into your application
55
+ * We'll also copy the javascripts & images into their respective folders for you, absolutely free of charge! How cool is that?
56
+
57
+ #### Existing project
58
+
59
+ Install the gem, add the require statement to the top of your configuration file, and install the extension.
60
+
61
+ gem install google-buttons-sass
62
+
63
+ # In config.rb
64
+ require 'google-buttons-sass'
65
+
66
+ compass install google-buttons
67
+
68
+ You'll get the same benefits as those starting from scratch. Radical.
69
+
70
+ ## Configuration
71
+ Need to configure a variable or two? Simply define the value of the variable you want to change *before* importing Google Buttons. Sass will respect your existing definition rather than overwriting it with the Bootstrap defaults. A list of customisable variables can be found in the [Bootstrap documentation](http://twitter.github.com/bootstrap/less.html#variables).
72
+
73
+ $btnPrimaryBackground: #f00;
74
+ @import "google-buttons";
75
+
76
+ **Note**: It's important that the file you are importing is not named `google-buttons`, since this will cause an import loop. As a general rule, errors are something you should try to avoid.
77
+
78
+ ### Passing multiple values to mixins
79
+
80
+ Some CSS3 properties take multiple values, such as `box-shadow` or `text-shadow`. To pass multiple values to the Bootstrap mixins, you must escape the values or else the Sass parser will choke on the commas. Here's how to escape the values in Sass:
81
+
82
+ .selector {
83
+ @include box-shadow(#{0 2px 5px rgba(0,0,0,.25) inset, 0 -2px 5px rgba(0,0,0,.25) inset});
84
+ }
85
+
86
+ ### Bundler?
87
+
88
+ gem 'google-buttons-sass', '~> 1'
89
+
90
+ ## Who
91
+ bootstrap-sass is a project by [Thomas McDonald](https://twitter.com/#!/thomasmcdonald_), with support from [other awesome people](https://github.com/thomas-mcdonald/bootstrap-sass/graphs/contributors).
@@ -0,0 +1,10 @@
1
+ # This contains functions for use with a project *only* using Compass.
2
+
3
+ module Sass::Script::Functions
4
+ # Define asset_url for Compass to allow use of sprites.
5
+ def asset_url(asset, type)
6
+ asset_sans_quotes = asset.value.gsub('"', '')
7
+ path = Sass::Script::String.new("/#{type}s/#{asset_sans_quotes}", :string)
8
+ Sass::Script::String.new("url(#{path})")
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ module Bootstrap
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ # Rails, will you please look in our vendor? kthx
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,14 @@
1
+ require 'sass'
2
+
3
+ module Sass::Script::Functions
4
+ # LARS: Snatched from compass - 2011-11-29 - used for gradients in IE6-9
5
+ # returns an IE hex string for a color with an alpha channel
6
+ # suitable for passing to IE filters.
7
+ def ie_hex_str(color)
8
+ assert_type color, :Color
9
+ alpha = (color.alpha * 255).round
10
+ alphastr = alpha.to_s(16).rjust(2, '0')
11
+ Sass::Script::String.new("##{alphastr}#{color.send(:hex_str)[1..-1]}".upcase)
12
+ end
13
+ declare :ie_hex_str, [:color]
14
+ end
@@ -0,0 +1,43 @@
1
+ module Bootstrap
2
+ class FrameworkNotFound < StandardError; end
3
+
4
+ # Inspired by Kaminari
5
+ def self.load!
6
+ if compass? && asset_pipeline?
7
+ register_compass_extension
8
+ register_rails_engine
9
+ elsif compass?
10
+ # Only require compass extension if a standalone project
11
+ require 'google-buttons-sass/compass_functions'
12
+ register_compass_extension
13
+ elsif asset_pipeline?
14
+ require 'sass-rails' # See: https://github.com/thomas-mcdonald/bootstrap-sass/pull/4
15
+ register_rails_engine
16
+ require 'google-buttons-sass/rails_functions'
17
+ else
18
+ raise Bootstrap::FrameworkNotFound, "google-button-sass requires either Rails > 3.1 or Compass, neither of which are loaded"
19
+ end
20
+ end
21
+
22
+ private
23
+ def self.asset_pipeline?
24
+ defined?(::Rails) && ::Rails.version >= '3.1.0'
25
+ end
26
+
27
+ def self.compass?
28
+ defined?(::Compass)
29
+ end
30
+
31
+ def self.register_compass_extension
32
+ base = File.join(File.dirname(__FILE__), '..')
33
+ styles = File.join(base, 'vendor', 'assets', 'stylesheets')
34
+ templates = File.join(base, 'templates')
35
+ ::Compass::Frameworks.register('google-buttons', :stylesheets_directory => styles, :templates_directory => templates)
36
+ end
37
+
38
+ def self.register_rails_engine
39
+ require 'google-buttons-sass/engine'
40
+ end
41
+ end
42
+
43
+ Bootstrap.load!
@@ -0,0 +1,17 @@
1
+ description "Google Buttons for Sass"
2
+
3
+ # Stylesheet importing Google Buttons
4
+ stylesheet 'styles.scss'
5
+
6
+ # Other Google Button assets
7
+ basedir = '../../vendor/assets'
8
+
9
+ # Images
10
+ %w(checkmark.png grey-disclosure-arrow-up-down.png).each do |file|
11
+ image "#{basedir}/images/#{file}.png", :to => "#{file}.png"
12
+ end
13
+
14
+ # Javascripts
15
+ %w(bootstrap-popover google-select-dropdown.js google-select.js).each do |file|
16
+ javascript "#{basedir}/javascripts/#{file}.js", :to => "#{file}.js"
17
+ end
@@ -0,0 +1,3 @@
1
+ // Use this instead of application.css, asset pipeline can be finicky
2
+ @import "google-buttons";
3
+
Binary file
@@ -0,0 +1,98 @@
1
+ /* ===========================================================
2
+ * bootstrap-popover.js v2.0.4
3
+ * http://twitter.github.com/bootstrap/javascript.html#popovers
4
+ * ===========================================================
5
+ * Copyright 2012 Twitter, Inc.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ * =========================================================== */
19
+
20
+
21
+ !function ($) {
22
+
23
+ "use strict"; // jshint ;_;
24
+
25
+
26
+ /* POPOVER PUBLIC CLASS DEFINITION
27
+ * =============================== */
28
+
29
+ var Popover = function ( element, options ) {
30
+ this.init('popover', element, options)
31
+ }
32
+
33
+
34
+ /* NOTE: POPOVER EXTENDS BOOTSTRAP-TOOLTIP.js
35
+ ========================================== */
36
+
37
+ Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, {
38
+
39
+ constructor: Popover
40
+
41
+ , setContent: function () {
42
+ var $tip = this.tip()
43
+ , title = this.getTitle()
44
+ , content = this.getContent()
45
+
46
+ $tip.find('.popover-title')[this.isHTML(title) ? 'html' : 'text'](title)
47
+ $tip.find('.popover-content > *')[this.isHTML(content) ? 'html' : 'text'](content)
48
+
49
+ $tip.removeClass('fade top bottom left right in')
50
+ }
51
+
52
+ , hasContent: function () {
53
+ return this.getTitle() || this.getContent()
54
+ }
55
+
56
+ , getContent: function () {
57
+ var content
58
+ , $e = this.$element
59
+ , o = this.options
60
+
61
+ content = $e.attr('data-content')
62
+ || (typeof o.content == 'function' ? o.content.call($e[0]) : o.content)
63
+
64
+ return content
65
+ }
66
+
67
+ , tip: function () {
68
+ if (!this.$tip) {
69
+ this.$tip = $(this.options.template)
70
+ }
71
+ return this.$tip
72
+ }
73
+
74
+ })
75
+
76
+
77
+ /* POPOVER PLUGIN DEFINITION
78
+ * ======================= */
79
+
80
+ $.fn.popover = function (option) {
81
+ return this.each(function () {
82
+ var $this = $(this)
83
+ , data = $this.data('popover')
84
+ , options = typeof option == 'object' && option
85
+ if (!data) $this.data('popover', (data = new Popover(this, options)))
86
+ if (typeof option == 'string') data[option]()
87
+ })
88
+ }
89
+
90
+ $.fn.popover.Constructor = Popover
91
+
92
+ $.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, {
93
+ placement: 'right'
94
+ , content: ''
95
+ , template: '<div class="popover"><div class="arrowbefore"></div><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'
96
+ })
97
+
98
+ }(window.jQuery);
@@ -0,0 +1,3 @@
1
+ //= require bootstrap-popover
2
+ //= require google-select-dropdown
3
+ //= require google-select
@@ -0,0 +1,89 @@
1
+ /* ============================================================
2
+ * google-select-dropdown.js v1.0.0
3
+ * ============================================================
4
+ * This is currently the same as bootstrap-dropdown.js but I'm
5
+ * using a separate definition because I suspect it'll need to
6
+ * change.
7
+ * ============================================================ */
8
+
9
+
10
+ !function ($) {
11
+
12
+ "use strict"; // jshint ;_;
13
+
14
+
15
+ /* DROPDOWN CLASS DEFINITION
16
+ * ========================= */
17
+
18
+ var toggle = '[data-toggle="g-select-dropdown"]'
19
+ , GSelectDropdown = function (element) {
20
+ var $el = $(element).on('click.g-select-dropdown.data-api', this.toggle)
21
+ $('html').on('click.g-select-dropdown.data-api', function () {
22
+ $el.parent().removeClass('open')
23
+ })
24
+ }
25
+
26
+ GSelectDropdown.prototype = {
27
+
28
+ constructor: GSelectDropdown
29
+
30
+ , toggle: function (e) {
31
+ var $this = $(this)
32
+ , $parent
33
+ , selector
34
+ , isActive
35
+
36
+ if ($this.is('.disabled, :disabled')) return
37
+
38
+ selector = $this.attr('data-target')
39
+
40
+ if (!selector) {
41
+ selector = $this.attr('href')
42
+ selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
43
+ }
44
+
45
+ $parent = $(selector)
46
+ $parent.length || ($parent = $this.parent())
47
+
48
+ isActive = $parent.hasClass('open')
49
+
50
+ clearMenus()
51
+
52
+ if (!isActive) $parent.toggleClass('open')
53
+
54
+ return false
55
+ }
56
+
57
+ }
58
+
59
+ function clearMenus() {
60
+ $(toggle).parent().removeClass('open')
61
+ }
62
+
63
+
64
+ /* DROPDOWN PLUGIN DEFINITION
65
+ * ========================== */
66
+
67
+ $.fn.gSelectDropdown = function (option) {
68
+ return this.each(function () {
69
+ var $this = $(this)
70
+ , data = $this.data('g-select-dropdown')
71
+ if (!data) $this.data('g-select-dropdown', (data = new GSelectDropdown(this)))
72
+ if (typeof option == 'string') data[option].call($this)
73
+ })
74
+ }
75
+
76
+ $.fn.gSelectDropdown.Constructor = GSelectDropdown
77
+
78
+
79
+ /* APPLY TO STANDARD DROPDOWN ELEMENTS
80
+ * =================================== */
81
+
82
+ $(function () {
83
+ $('html').on('click.g-select-dropdown.data-api', clearMenus)
84
+ $('body')
85
+ .on('click.g-select-dropdown', '.g-select-dropdown form', function (e) { e.stopPropagation() })
86
+ .on('click.g-select-dropdown.data-api', toggle, GSelectDropdown.prototype.toggle)
87
+ })
88
+
89
+ }(window.jQuery);
@@ -0,0 +1,84 @@
1
+ /* ===========================================================
2
+ * google-select.js v1.0.0
3
+ * http://todc.github.com/google-bootstrap
4
+ * =========================================================== */
5
+
6
+
7
+ !function ($) {
8
+
9
+ "use strict"; // jshint ;_;
10
+
11
+
12
+ /* CLASS DEFINITION
13
+ * ================ */
14
+
15
+ var GSelect = function (element) {
16
+ var $el = $(element);
17
+ $el.hide();
18
+
19
+ var $container = $('<div>').addClass('btn-group');
20
+ var $btn = $('<a>', { text: 'Select...'}).addClass('btn g-select');
21
+ var $menu = $('<ul>').addClass('g-select-dropdown scrollable');
22
+
23
+ $btn.addClass($el.attr('class'));
24
+
25
+ $.each(element.options, function(i, opt) {
26
+ var $menuItem = $('<li>', { text: opt.text });
27
+
28
+ $menuItem.data('val', opt.value ? opt.value : opt.text);
29
+
30
+ $menu.append( $menuItem );
31
+ });
32
+
33
+ $el.after($container);
34
+ $container.append($btn);
35
+ $btn.after($menu);
36
+
37
+ $.each($menu.children(), function(i, menuItem) {
38
+ $(menuItem).click(function() {
39
+ $btn.text($(this).text());
40
+ $el.val($(this).data('val')).change();
41
+ })
42
+ })
43
+
44
+ $btn.gSelectDropdown();
45
+ }
46
+
47
+ GSelect.prototype = {
48
+
49
+ constructor: GSelect
50
+
51
+ , toggle: function (e) {
52
+
53
+ }
54
+
55
+ }
56
+
57
+
58
+ /* DROPDOWN PLUGIN DEFINITION
59
+ * ========================== */
60
+
61
+ $.fn.gSelect = function (option) {
62
+ return this.each(function () {
63
+ var $this = $(this)
64
+ , data = $this.data('gSelect')
65
+ if (!data) $this.data('gSelect', (data = new GSelect(this)))
66
+ if (typeof option == 'string') data[option].call($this)
67
+ })
68
+ }
69
+
70
+ $.fn.gSelect.Constructor = GSelect
71
+
72
+
73
+ /* APPLY TO STANDARD DROPDOWN ELEMENTS
74
+ * =================================== */
75
+ /*
76
+ $(function () {
77
+ $('html').on('click.dropdown.data-api', clearMenus)
78
+ $('body')
79
+ .on('click.dropdown', '.dropdown form', function (e) { e.stopPropagation() })
80
+ .on('click.dropdown.data-api', toggle, Dropdown.prototype.toggle)
81
+ })
82
+ */
83
+
84
+ }(window.jQuery);
@@ -0,0 +1,21 @@
1
+ // ALERTS
2
+ // -----------
3
+
4
+ .alert {
5
+ padding: 8px 35px 8px 10px;
6
+ text-shadow: none;
7
+ @include border-radius(2px);
8
+ @include box-shadow(0 2px 4px rgba(0,0,0,0.2));
9
+ }
10
+
11
+ .alert-success,
12
+ .alert-danger,
13
+ .alert-error,
14
+ .alert-info {
15
+ text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
16
+ }
17
+ .alert-danger,
18
+ .alert-error {
19
+ border-color: darken($errorBackground, 20%);
20
+ color: #b94a48;
21
+ }