Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
onyxblade committed Mar 17, 2015
1 parent 2aa7c63 commit 4bbf6fb
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 13 deletions.
6 changes: 3 additions & 3 deletions example/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
form title: 'test' do
button('open file').onclick { @text.text = ShenmeGUI::FileDialog.get_open_file_name; @i.src="file:///#{@text.text}" }
@sel = select %w{1 2 3}
flow do
radio %w{option1 option2 option3}
end

radio %w{option1 option2 option3}, arrange: 'horizontal'

radio %w{option7 option8 option9}, checked: 'option9'

button('alert').onclick { alert 'test message'}
Expand Down
4 changes: 2 additions & 2 deletions lib/shenmegui/controls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class Image < Base
end

class Checkbox < Base
property :options, :checked
property :options, :checked, :arrange
shortcut :options
end

Expand All @@ -159,7 +159,7 @@ def validate(params)
end

class Radio < Base
property :options, :checked
property :options, :checked, :arrange
shortcut :options
end

Expand Down
2 changes: 1 addition & 1 deletion shenmegui.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'shenmegui'
s.version = '0.1.1'
s.version = '0.2'
s.date = '2015-03-11'
s.summary = "什么鬼!"
s.description = "a simple HTML GUI for Ruby"
Expand Down
8 changes: 7 additions & 1 deletion static/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ var syncHandlers = {
}),

form: (function(target, data){
target.getElementsByClassName('title').getElementsByTagName('span')[0].innerText = data.title;
target.getElementsByClassName('title')[0].getElementsByTagName('span')[0].innerText = data.title;
}),

button: (function(target, data){
Expand Down Expand Up @@ -131,10 +131,13 @@ var syncHandlers = {
}),

checkbox: (function(target, data){
if(data.arrange=='horizontal') target.className = 'flow';
if(data.arrange=='vertical') target.className = 'stack';
var options = target.children;
for(var i=0;i<options.length;) target.removeChild(options[i]);
for(var i=0;i<data.options.length;i++){
var option = document.createElement('div');
option.className = "option";
var input = document.createElement('input');
var label = document.createElement('label');
input.type = 'checkbox';
Expand All @@ -153,10 +156,13 @@ var syncHandlers = {
}),

radio: (function(target, data){
if(data.arrange=='horizontal') target.className = 'flow';
if(data.arrange=='vertical') target.className = 'stack';
var options = target.children;
for(var i=0;i<options.length;) target.removeChild(options[i]);
for(var i=0;i<data.options.length;i++){
var option = document.createElement('div');
option.className = "option";
var input = document.createElement('input');
var label = document.createElement('label');
input.type="radio";
Expand Down
6 changes: 3 additions & 3 deletions static/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions static/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ body {
}
}

.stack * {
.stack>* {
display: block !important;
}

.flow * {
.flow>* {
display: inline !important;
}

Expand Down Expand Up @@ -144,7 +144,7 @@ input[type="radio"]:checked + label:before {
height: 18px;
}

.radio>div, .checkbox>div {
.option {
margin-right: 1em;
}

Expand Down

0 comments on commit 4bbf6fb

Please sign in to comment.