Skip to content

Commit

Permalink
added new component: button-set
Browse files Browse the repository at this point in the history
  • Loading branch information
olton committed Oct 5, 2012
1 parent 26ce43c commit b4dabae
Show file tree
Hide file tree
Showing 7 changed files with 175 additions and 1 deletion.
23 changes: 23 additions & 0 deletions css/modern.css
Original file line number Diff line number Diff line change
Expand Up @@ -1524,6 +1524,29 @@ button:focus,
.command-button.default > small {
color: #ccc;
}
.tool-button {
min-width: 32px;
min-height: 32px;
width: 32px;
height: 32px;
padding-top: 3px;
}
.tool-button img {
width: 16px;
height: 16px;
margin: 0;
padding: 0;
display: inline;
float: none;
clear: both;
}
.button-set button {
margin-right: 0;
}
.button-set button.active {
background-color: #008287;
color: #fff;
}
/*
* Metro UI CSS v 0.1.1
* Copyright 2012 Sergey Pimenov
Expand Down
34 changes: 34 additions & 0 deletions javascript/buttonset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
(function($){
$.fn.ButtonSet = function( options ){
var defaults = {
};

var $this = $(this)
, $buttons = $this.find("button")
;

var initButtons = function(buttons){
buttons.on('click', function(e){
e.preventDefault();
var $a = $(this);
if ( $a.hasClass('active') ) return false;
$buttons.removeClass("active");
$(this).addClass("active");
});
}

return this.each(function(){
if ( options ) {
$.extend(defaults, options)
}

initButtons($buttons);
});
}

$(function () {
$('[data-role="button-set"]').each(function () {
$(this).ButtonSet();
})
})
})(window.jQuery);
28 changes: 28 additions & 0 deletions less/buttons.less
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,31 @@ button, .button {
}
}
}

.tool-button {
min-width: 32px;
min-height: 32px;
width: 32px;
height: 32px;
padding-top: 3px;

img {
width: 16px;
height: 16px;
margin: 0;
padding: 0;
display: inline;
float: none;
clear: both;
}
}

.button-set {
button {
margin-right: 0;
}
button.active {
background-color: #008287;
color: #fff;
}
}
2 changes: 1 addition & 1 deletion less/tiles.less
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
margin-bottom: 5px;
margin-left: 15px;
.tertiary-text;

font-family: @baseFontUI;
color: @white;
&:hover {
Expand Down
32 changes: 32 additions & 0 deletions public/buttons.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<script src="js/google-analytics.js"></script>
<script src="js/github.info.js"></script>
<script src="js/google-code-prettify/prettify.js"></script>
<script src="js/buttonset.js"></script>

<title>Modern UI CSS</title>
</head>
Expand Down Expand Up @@ -81,8 +82,39 @@

</div>
</div>

<div class="row">
<div class="span10">
<h2>Button set</h2>
<div class="button-set place-left" data-role="button-set">
<button class="active">button 1</button>
<button>button 2</button>
<button>button 3</button>
</div>
<div class="button-set" data-role="button-set">
<button class="tool-button active"><img src="images/bage-playing.png" /></button>
<button class="tool-button"><img src="images/bage-paused.png" /></button>
<button class="tool-button"><img src="images/bage-busy.png" /></button>
</div>
<pre class="prettyprint linenums">
&lt;div class="button-set" data-role="button-set"&gt;
&lt;button class="active"&gt; ... &lt;/button&gt;
&lt;button&gt; ... &lt;/button&gt;
&lt;/div&gt;
------------
&lt;div class="button-set" data-role="button-set"&gt;
&lt;button class="tool-button active"&gt; ... &lt;/button&gt;
&lt;button class="tool-button"&gt; ... &lt;/button&gt;
&lt;/div&gt;
</pre>
<h3>Javascript</h3>
<p>To activate button set include in head <code>buttonset.js</code></p>
</div>
</div>
</div>



<div class="grid">
<div class="row">
<? include("adsense.php")?>
Expand Down
23 changes: 23 additions & 0 deletions public/css/modern.css
Original file line number Diff line number Diff line change
Expand Up @@ -1524,6 +1524,29 @@ button:focus,
.command-button.default > small {
color: #ccc;
}
.tool-button {
min-width: 32px;
min-height: 32px;
width: 32px;
height: 32px;
padding-top: 3px;
}
.tool-button img {
width: 16px;
height: 16px;
margin: 0;
padding: 0;
display: inline;
float: none;
clear: both;
}
.button-set button {
margin-right: 0;
}
.button-set button.active {
background-color: #008287;
color: #fff;
}
/*
* Metro UI CSS v 0.1.1
* Copyright 2012 Sergey Pimenov
Expand Down
34 changes: 34 additions & 0 deletions public/js/buttonset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
(function($){
$.fn.ButtonSet = function( options ){
var defaults = {
};

var $this = $(this)
, $buttons = $this.find("button")
;

var initButtons = function(buttons){
buttons.on('click', function(e){
e.preventDefault();
var $a = $(this);
if ( $a.hasClass('active') ) return false;
$buttons.removeClass("active");
$(this).addClass("active");
});
}

return this.each(function(){
if ( options ) {
$.extend(defaults, options)
}

initButtons($buttons);
});
}

$(function () {
$('[data-role="button-set"]').each(function () {
$(this).ButtonSet();
})
})
})(window.jQuery);

0 comments on commit b4dabae

Please sign in to comment.