moode-haml-jqm 0.0.2 → 0.0.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.
- data/.gitignore +1 -0
- data/lib/moode-haml-jqm/_date_box.haml +2 -0
- data/lib/moode-haml-jqm/_email_box.haml +2 -0
- data/lib/moode-haml-jqm/_head_bar.haml +1 -1
- data/lib/moode-haml-jqm/_input_area.haml +2 -0
- data/lib/moode-haml-jqm/_input_box.haml +1 -1
- data/lib/moode-haml-jqm/_input_checkbox.haml +2 -0
- data/lib/moode-haml-jqm/_input_disabled.haml +0 -0
- data/lib/moode-haml-jqm/_input_hidden.haml +0 -0
- data/lib/moode-haml-jqm/_input_radio_button.haml +2 -0
- data/lib/moode-haml-jqm/_link_button.haml +1 -1
- data/lib/moode-haml-jqm/_nav_bar.haml +0 -0
- data/lib/moode-haml-jqm/_number_box.haml +2 -0
- data/lib/moode-haml-jqm/_survey_input.haml +3 -0
- data/lib/moode-haml-jqm/_survey_type.haml +15 -0
- data/lib/moode-haml-jqm/load_template.rb +2 -1
- data/lib/moode-haml-jqm/version.rb +1 -1
- data/lib/moode-haml-jqm.rb +65 -4
- metadata +11 -3
data/.gitignore
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
%label(for="#{id}") #{label}
|
2
|
-
%input@{id}(type="
|
2
|
+
%input@{id}(type="#{type}" name="#{name}" @{raw_property})
|
File without changes
|
File without changes
|
@@ -1 +1 @@
|
|
1
|
-
%a(href
|
1
|
+
%a(href=@href data-role="button" @{handle} @{raw_property}) #{label}
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
%div.survey_type_select_container(data-role="fieldcontain")
|
2
|
+
%fieldset.survey_type_select_fieldset(data-role="controlgroup" data-type="horizontal" data-mini="true")
|
3
|
+
=input_radio_button :id => "#{for_survey}_yn_type", :name => "#{for_survey}_survey_type", :clazz => "survey_type", :value => "yn_type", :checked => "checked", :label => "Y/N调查"
|
4
|
+
=input_radio_button :id => "#{for_survey}_single_choice_type", :name => "#{for_survey}_survey_type", :clazz => "survey_type", :value => "single_choice_type", :label => "单选调查"
|
5
|
+
=input_radio_button :id => "#{for_survey}_notify_type", :name => "#{for_survey}_survey_type", :clazz => "survey_type", :value => "notify_type", :label => "Notify"
|
6
|
+
.survey_appendix_container(style="display:none")
|
7
|
+
%ul.survey_appendix_list(data-role="listview" data-inset="true")
|
8
|
+
%li(data-role="fieldcontain")
|
9
|
+
=input_box :id => "#{for_survey}_appendix_a_choice", :name => "choice", :label => "A", :raw_property => "tag='a' data-mini='true'"
|
10
|
+
%li(data-role="fieldcontain")
|
11
|
+
=input_box :id => "#{for_survey}_appendix_b_choice", :name => "choice", :label => "B", :raw_property => "tag='b' data-mini='true'"
|
12
|
+
%li(data-role="fieldcontain")
|
13
|
+
=input_box :id => "#{for_survey}_appendix_c_choice", :name => "choice", :label => "C", :raw_property => "tag='c' data-mini='true'"
|
14
|
+
%li(data-role="fieldcontain")
|
15
|
+
=input_box :id => "#{for_survey}_appendix_d_choice", :name => "choice", :label => "D", :raw_property => "tag='d' data-mini='true'"
|
@@ -1,10 +1,11 @@
|
|
1
1
|
|
2
2
|
def load_component_template(component_name)
|
3
|
-
template_path = File.expand_path('../', __FILE__)
|
4
3
|
file_name = "_#{component_name}.haml"
|
5
4
|
file_relative_path = "component/#{file_name}"
|
6
5
|
if File.exist? file_relative_path
|
7
6
|
return File.read(file_relative_path)
|
8
7
|
end
|
8
|
+
|
9
|
+
template_path = File.expand_path('../', __FILE__)
|
9
10
|
return File.read("#{template_path}/#{file_name}")
|
10
11
|
end
|
data/lib/moode-haml-jqm.rb
CHANGED
@@ -3,16 +3,19 @@ require "moode-haml-jqm/load_template"
|
|
3
3
|
|
4
4
|
require 'haml'
|
5
5
|
|
6
|
+
def load_component_template(component_name)
|
7
|
+
return File.read("component/_#{component_name}.haml")
|
8
|
+
end
|
6
9
|
|
7
10
|
def link_button(args)
|
8
11
|
template = load_component_template(:link_button)
|
9
12
|
if(!args[:handle])
|
10
|
-
args[:handle]="
|
13
|
+
args[:handle]=""
|
11
14
|
else
|
12
15
|
args[:handle]="onclick=\"#{args[:handle]}\""
|
13
16
|
end
|
14
17
|
template = template.gsub("@{handle}", args[:handle])
|
15
|
-
|
18
|
+
template = template.gsub("@href", ( args[:href] ? "\"" + args[:href] + "\"" : "\"javascript:void(0)\"" ) )
|
16
19
|
if(!args[:raw_property])
|
17
20
|
args[:raw_property]=''
|
18
21
|
end
|
@@ -22,7 +25,10 @@ def link_button(args)
|
|
22
25
|
end
|
23
26
|
|
24
27
|
def head_bar(args)
|
28
|
+
args[:back] = "Back" unless args[:back]
|
29
|
+
args[:href] = "\"javascript:void(0)\"" unless args[:href]
|
25
30
|
template = load_component_template(:head_bar).gsub("@{title_id}", args[:title_id]?("#"+args[:title_id]):"")
|
31
|
+
template = template.gsub("@handler", ( args[:handler] ? "onclick=\"" + args[:handler] + "\"" : "" ) )
|
26
32
|
template = template.gsub("@{position}", args[:position]?("data-position=\"#{args[:position]}\""):"")
|
27
33
|
Haml::Engine.new(template).render Object.new, args
|
28
34
|
end
|
@@ -31,7 +37,35 @@ def input_box(args)
|
|
31
37
|
if(!args[:id])
|
32
38
|
args[:id] = args[:name]
|
33
39
|
end
|
40
|
+
if(!args[:raw_property])
|
41
|
+
args[:raw_property]=''
|
42
|
+
end
|
43
|
+
args[:type] = "text" unless args[:type]
|
34
44
|
template = load_component_template(:input_box).gsub("@{id}", "#"+args[:id])
|
45
|
+
template = template.gsub("@{raw_property}", args[:raw_property])
|
46
|
+
Haml::Engine.new(template).render Object.new, args
|
47
|
+
end
|
48
|
+
|
49
|
+
def input_area(args)
|
50
|
+
if(!args[:id])
|
51
|
+
args[:id] = args[:name]
|
52
|
+
end
|
53
|
+
template = load_component_template(:input_area).gsub("@{id}", "#"+args[:id])
|
54
|
+
Haml::Engine.new(template).render Object.new, args
|
55
|
+
end
|
56
|
+
|
57
|
+
def input_checkbox(args)
|
58
|
+
if(!args[:id])
|
59
|
+
args[:id] = args[:name]
|
60
|
+
end
|
61
|
+
if(args[:handle])
|
62
|
+
args[:handle]="onchange=\"#{args[:handle]}\""
|
63
|
+
else
|
64
|
+
args[:handle] = ""
|
65
|
+
end
|
66
|
+
template = load_component_template(:input_checkbox).gsub("@{id}", "#"+args[:id])
|
67
|
+
template = template.gsub("@{handle}", args[:handle])
|
68
|
+
template = template.gsub("@{checked}", ( args[:checked] ? args[:checked] : "") )
|
35
69
|
Haml::Engine.new(template).render Object.new, args
|
36
70
|
end
|
37
71
|
|
@@ -51,10 +85,20 @@ def input_hidden(args)
|
|
51
85
|
Haml::Engine.new(template).render Object.new, args
|
52
86
|
end
|
53
87
|
|
88
|
+
def survey_input(args)
|
89
|
+
template = load_component_template(:survey_input)
|
90
|
+
Haml::Engine.new(template).render Object.new, args
|
91
|
+
end
|
92
|
+
|
93
|
+
def survey_type(args)
|
94
|
+
template = load_component_template(:survey_type)
|
95
|
+
Haml::Engine.new(template).render Object.new, args
|
96
|
+
end
|
97
|
+
|
54
98
|
def nav_bar(args)
|
55
99
|
args[:model].each do |name, mod|
|
56
|
-
|
57
|
-
args[:model][name][:href] = "
|
100
|
+
unless mod[:href]
|
101
|
+
args[:model][name][:href] = "#" + name.to_s + "_page"
|
58
102
|
end
|
59
103
|
if (mod[:selected])
|
60
104
|
args[:model][name][:raw_property] = 'class="ui-btn-active ui-state-persist"'
|
@@ -67,3 +111,20 @@ def nav_bar(args)
|
|
67
111
|
Haml::Engine.new(template).render Object.new, args
|
68
112
|
end
|
69
113
|
|
114
|
+
def input_radio_button(args)
|
115
|
+
args[:id] = args[:name] unless args[:id]
|
116
|
+
if args[:handle]
|
117
|
+
args[:handle] = "onchange=\"#{args[:handle]}\""
|
118
|
+
else
|
119
|
+
args[:handle] = ""
|
120
|
+
end
|
121
|
+
args[:checked] = "" unless args[:checked]
|
122
|
+
|
123
|
+
template = load_component_template(:input_radio_button)
|
124
|
+
template.gsub!("@{id}", "#" + args[:id])
|
125
|
+
template.gsub!("@{class}", "." + args[:clazz]) if args[:clazz]
|
126
|
+
template.gsub!("@{handle}", args[:handle])
|
127
|
+
template.gsub!("@{checked}", args[:checked])
|
128
|
+
Haml::Engine.new(template).render Object.new, args
|
129
|
+
end
|
130
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moode-haml-jqm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-25 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: jquery mobile based haml component
|
15
15
|
email:
|
@@ -24,12 +24,20 @@ files:
|
|
24
24
|
- README.md
|
25
25
|
- Rakefile
|
26
26
|
- lib/moode-haml-jqm.rb
|
27
|
+
- lib/moode-haml-jqm/_date_box.haml
|
28
|
+
- lib/moode-haml-jqm/_email_box.haml
|
27
29
|
- lib/moode-haml-jqm/_head_bar.haml
|
30
|
+
- lib/moode-haml-jqm/_input_area.haml
|
28
31
|
- lib/moode-haml-jqm/_input_box.haml
|
32
|
+
- lib/moode-haml-jqm/_input_checkbox.haml
|
29
33
|
- lib/moode-haml-jqm/_input_disabled.haml
|
30
34
|
- lib/moode-haml-jqm/_input_hidden.haml
|
35
|
+
- lib/moode-haml-jqm/_input_radio_button.haml
|
31
36
|
- lib/moode-haml-jqm/_link_button.haml
|
32
37
|
- lib/moode-haml-jqm/_nav_bar.haml
|
38
|
+
- lib/moode-haml-jqm/_number_box.haml
|
39
|
+
- lib/moode-haml-jqm/_survey_input.haml
|
40
|
+
- lib/moode-haml-jqm/_survey_type.haml
|
33
41
|
- lib/moode-haml-jqm/load_template.rb
|
34
42
|
- lib/moode-haml-jqm/version.rb
|
35
43
|
- moode-haml-jqm.gemspec
|
@@ -53,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
61
|
version: '0'
|
54
62
|
requirements: []
|
55
63
|
rubyforge_project:
|
56
|
-
rubygems_version: 1.8.
|
64
|
+
rubygems_version: 1.8.23
|
57
65
|
signing_key:
|
58
66
|
specification_version: 3
|
59
67
|
summary: jquery mobile based haml component
|