sass-buttons 0.1.2 → 0.1.3
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 +4 -4
- data/README.md +4 -4
- data/javascripts/buttons.js +112 -0
- data/lib/sass-buttons/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec6f6f2b001719fae2a83636aafe6e9c50a23ca3
|
4
|
+
data.tar.gz: dc0bd64d2461a2921f133a5bdfee541f1f630f64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aee2ab35db46244bdbcd6d7dd3a06b01523d007c13f247191e764681dc51b6ebb1c9a43048e85f0db1df059180910a5e35fc3279710fb59a6b3390ecb36f198b
|
7
|
+
data.tar.gz: 0c41438786e6b4861405078e445427b47885330af108944cf93d3830e012cc9f35c1863629b9c5326146a8f549967229d7f805e9c217da711a3e018244cb6c8a
|
data/README.md
CHANGED
@@ -21,13 +21,13 @@ Install gem from the command line:
|
|
21
21
|
Installing Sass Buttons:
|
22
22
|
|
23
23
|
# Edit the project configuration file and add:
|
24
|
-
require '
|
24
|
+
require 'sass-buttons'
|
25
25
|
|
26
26
|
# From the command line:
|
27
|
-
compass install
|
27
|
+
compass install sass-buttons
|
28
28
|
|
29
|
-
#import
|
30
|
-
@import "
|
29
|
+
#import sass buttons partial into your sass/scss file
|
30
|
+
@import "sass-buttons"
|
31
31
|
|
32
32
|
|
33
33
|
|
@@ -0,0 +1,112 @@
|
|
1
|
+
/*! @license
|
2
|
+
* Project: Buttons
|
3
|
+
* Description: A highly customizable CSS button library built with Sass and Compass
|
4
|
+
* Author: Alex Wolfe
|
5
|
+
* License: Apache License v2.0
|
6
|
+
*/
|
7
|
+
|
8
|
+
// the semi-colon before function invocation is a safety net against concatenated
|
9
|
+
// scripts and/or other plugins which may not be closed properly.
|
10
|
+
;(function ( $, window, document, undefined ) {
|
11
|
+
'use strict';
|
12
|
+
|
13
|
+
// undefined is used here as the undefined global variable in ECMAScript 3 is
|
14
|
+
// mutable (ie. it can be changed by someone else). undefined isn't really being
|
15
|
+
// passed in so we can ensure the value of it is truly undefined. In ES5, undefined
|
16
|
+
// can no longer be modified.
|
17
|
+
|
18
|
+
// window and document are passed through as local variable rather than global
|
19
|
+
// as this (slightly) quickens the resolution process and can be more efficiently
|
20
|
+
// minified (especially when both are regularly referenced in your plugin).
|
21
|
+
|
22
|
+
// Create the defaults once
|
23
|
+
var pluginName = "menuButton";
|
24
|
+
var menuClass = ".button-dropdown";
|
25
|
+
var defaults = {
|
26
|
+
propertyName: "value"
|
27
|
+
};
|
28
|
+
|
29
|
+
// The actual plugin constructor
|
30
|
+
function Plugin( element, options ) {
|
31
|
+
|
32
|
+
//SET OPTIONS
|
33
|
+
this.options = $.extend( {}, defaults, options );
|
34
|
+
this._defaults = defaults;
|
35
|
+
this._name = pluginName;
|
36
|
+
|
37
|
+
//REGISTER ELEMENT
|
38
|
+
this.$element = $(element);
|
39
|
+
|
40
|
+
//INITIALIZE
|
41
|
+
this.init();
|
42
|
+
}
|
43
|
+
|
44
|
+
Plugin.prototype = {
|
45
|
+
constructor: Plugin,
|
46
|
+
|
47
|
+
init: function() {
|
48
|
+
// WE DON'T STOP PROPGATION SO CLICKS WILL AUTOMATICALLY
|
49
|
+
// TOGGLE AND REMOVE THE DROPDOWN
|
50
|
+
this.toggle();
|
51
|
+
},
|
52
|
+
|
53
|
+
toggle: function(el, options) {
|
54
|
+
if(this.$element.data('dropdown') === 'show') {
|
55
|
+
this.hideMenu();
|
56
|
+
}
|
57
|
+
else {
|
58
|
+
this.showMenu();
|
59
|
+
}
|
60
|
+
},
|
61
|
+
|
62
|
+
showMenu: function() {
|
63
|
+
this.$element.data('dropdown', 'show');
|
64
|
+
this.$element.find('ul').show();
|
65
|
+
},
|
66
|
+
|
67
|
+
hideMenu: function() {
|
68
|
+
this.$element.data('dropdown', 'hide');
|
69
|
+
this.$element.find('ul').hide();
|
70
|
+
}
|
71
|
+
};
|
72
|
+
|
73
|
+
// A really lightweight plugin wrapper around the constructor,
|
74
|
+
// preventing against multiple instantiations
|
75
|
+
$.fn[pluginName] = function ( options ) {
|
76
|
+
return this.each(function () {
|
77
|
+
|
78
|
+
// TOGGLE BUTTON IF IT EXISTS
|
79
|
+
if ($.data(this, "plugin_" + pluginName)) {
|
80
|
+
$.data(this, "plugin_" + pluginName).toggle();
|
81
|
+
}
|
82
|
+
// OTHERWISE CREATE A NEW INSTANCE
|
83
|
+
else {
|
84
|
+
$.data(this, "plugin_" + pluginName, new Plugin( this, options ));
|
85
|
+
}
|
86
|
+
});
|
87
|
+
};
|
88
|
+
|
89
|
+
//CLOSE OPEN DROPDOWN MENUS IF CLICKED SOMEWHERE ELSE
|
90
|
+
$(document).on('click', function(e) {
|
91
|
+
$.each($('[data-buttons=dropdown]'), function(i, value) {
|
92
|
+
if ($(e.target.offsetParent)[0] != $(this)[0]) {
|
93
|
+
if ($.data(this, "plugin_" + pluginName)) {
|
94
|
+
$.data(this, "plugin_" + pluginName).hideMenu();
|
95
|
+
$(this).find('ul').hide();
|
96
|
+
}
|
97
|
+
}
|
98
|
+
});
|
99
|
+
});
|
100
|
+
|
101
|
+
//DELEGATE CLICK EVENT FOR DROPDOWN MENUS
|
102
|
+
$(document).on('click', '[data-buttons=dropdown]', function(e) {
|
103
|
+
var $dropdown = $(e.currentTarget);
|
104
|
+
$dropdown.menuButton();
|
105
|
+
});
|
106
|
+
|
107
|
+
//IGNORE CLICK EVENTS FROM DISPLAY BUTTON IN DROPDOWN
|
108
|
+
$(document).on('click', '[data-buttons=dropdown] > a', function(e) {
|
109
|
+
e.preventDefault();
|
110
|
+
});
|
111
|
+
|
112
|
+
})( jQuery, window, document);
|
data/lib/sass-buttons/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sass-buttons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lester Zhao
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- LICENSE.txt
|
64
64
|
- README.md
|
65
65
|
- Rakefile
|
66
|
+
- javascripts/buttons.js
|
66
67
|
- lib/sass-buttons.rb
|
67
68
|
- lib/sass-buttons/version.rb
|
68
69
|
- sache.json
|
@@ -92,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
93
|
version: '0'
|
93
94
|
requirements: []
|
94
95
|
rubyforge_project:
|
95
|
-
rubygems_version: 2.2.
|
96
|
+
rubygems_version: 2.2.2
|
96
97
|
signing_key:
|
97
98
|
specification_version: 4
|
98
99
|
summary: Easily create Awesome CSS buttons
|