rmobio 1.1.11 → 1.1.12
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/lib/rmobio/config_manager.rb +29 -19
- data/lib/rmobio/rxml/base_transformer.rb +82 -42
- data/lib/rmobio/rxml/xforms_transformer.rb +406 -8
- data/lib/rmobio/utils.rb +1 -1
- metadata +2 -2
@@ -23,7 +23,7 @@
|
|
23
23
|
# config_manager, perform the following steps:
|
24
24
|
#
|
25
25
|
# 1. In environment.rb, add the following two lines to the bottom of the file
|
26
|
-
#
|
26
|
+
# (we want to load the configuration statically):
|
27
27
|
#
|
28
28
|
# <pre>require 'rmobio/config_manager'</pre>
|
29
29
|
#
|
@@ -32,7 +32,7 @@
|
|
32
32
|
# <pre>rake rmobio:setup</pre>
|
33
33
|
#
|
34
34
|
# 3. Edit config/rmobio.yml and add your properties (here we set a property
|
35
|
-
#
|
35
|
+
# called "ad_network" with a value of "ad_sense")
|
36
36
|
#
|
37
37
|
# <pre>
|
38
38
|
# development:
|
@@ -40,11 +40,13 @@
|
|
40
40
|
# </pre>
|
41
41
|
#
|
42
42
|
# 4. To use a property, reference the hash accordingly. e.g. @adnetwork =
|
43
|
-
#
|
43
|
+
# MOBIO_CONFIG['ad_network']
|
44
44
|
#
|
45
45
|
module Rmobio
|
46
46
|
module ConfigManager
|
47
47
|
|
48
|
+
EXTERNAL_CONTEXT_PROP = '_external_context' unless defined? EXTERNAL_CONTEXT_PROP
|
49
|
+
|
48
50
|
if defined? RAILS_DEFAULT_LOGGER
|
49
51
|
logger = RAILS_DEFAULT_LOGGER
|
50
52
|
else
|
@@ -65,27 +67,31 @@ module Rmobio
|
|
65
67
|
# Replace all properties containing @somekey@ with the value of
|
66
68
|
# "somekey"
|
67
69
|
MOBIO_CONFIG.each do |key, value|
|
70
|
+
|
71
|
+
# Run the value filter process
|
68
72
|
filter_value = value.to_s.strip
|
69
73
|
filter_key = /@(.*)@/.match(filter_value).to_s.strip
|
70
|
-
if
|
74
|
+
if filter_key and filter_key != ''
|
71
75
|
filter_key = filter_key.gsub(/@/,'')
|
72
|
-
if
|
76
|
+
if filter_key and filter_value and filter_key != ''
|
73
77
|
filter_value = filter_value.gsub(/@.*@/, MOBIO_CONFIG[filter_key.strip])
|
74
|
-
logger.debug('filtered key: ' + key + ' filtered value: ' +
|
78
|
+
logger.debug('filtered key: ' + key + ' filtered value: ' +
|
79
|
+
filter_value) unless logger.nil?
|
75
80
|
MOBIO_CONFIG[key] = filter_value
|
76
|
-
end
|
81
|
+
end
|
77
82
|
end
|
78
83
|
end
|
79
84
|
else
|
80
|
-
raise StandardError, "config/rmobio.yml exists, but doesn't
|
85
|
+
raise StandardError, "config/rmobio.yml exists, but doesn't" +
|
86
|
+
"have a configuration for RAILS_ENV=#{RAILS_ENV}."
|
81
87
|
end
|
82
88
|
else
|
83
89
|
raise StandardError, "config/rmobio.yml does not exist."
|
84
90
|
end
|
85
91
|
|
86
92
|
# get_request_context This method checks for the existence of a
|
87
|
-
# "mobio-context" header. If the header exists, then the method returns
|
88
|
-
#
|
93
|
+
# "mobio-context" header. If the header exists, then the method returns the
|
94
|
+
# filtered value for the MOBIO_CONFIG array with the key "url."
|
89
95
|
#
|
90
96
|
# Below is the flow:
|
91
97
|
#
|
@@ -96,20 +102,24 @@ module Rmobio
|
|
96
102
|
#
|
97
103
|
# "/mycustomcontext/news"
|
98
104
|
#
|
99
|
-
# If no header exists, the method returns the value of the property,
|
105
|
+
# If no header exists, the method returns the value of the property,
|
106
|
+
# unfiltered
|
100
107
|
#
|
101
108
|
def get_external_context(url=nil)
|
102
|
-
external_context_prop = "_external_context"
|
103
109
|
|
104
110
|
context = request.env['HTTP_MOBIO_CONTEXT']
|
105
111
|
|
106
|
-
if
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
112
|
+
if url
|
113
|
+
if context and context != ''
|
114
|
+
external_context = MOBIO_CONFIG[url].gsub(EXTERNAL_CONTEXT_PROP, context)
|
115
|
+
RAILS_DEFAULT_LOGGER.debug 'Utils: Setting the uri to: "' +
|
116
|
+
external_context + '" for the current request.' unless not defined? RAILS_DEFAULT_LOGGER
|
117
|
+
return external_context
|
118
|
+
else
|
119
|
+
return MOBIO_CONFIG[url].gsub('/' + EXTERNAL_CONTEXT_PROP, '')
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
113
123
|
end
|
114
124
|
end
|
115
125
|
# Now we want to initialize the MOBIO_CONFIG constant
|
@@ -71,47 +71,47 @@ The above code generates the following xhtml in Firefox:
|
|
71
71
|
@model_buffer = ""
|
72
72
|
super
|
73
73
|
end
|
74
|
-
#
|
75
|
-
# def cattr_reader(*syms)
|
76
|
-
# syms.flatten.each do |sym|
|
77
|
-
# class_eval(<<-EOS, __FILE__, __LINE__)
|
78
|
-
# unless defined? @@#{sym}
|
79
|
-
# @@#{sym} = nil
|
80
|
-
# end
|
81
|
-
#
|
82
|
-
# def self.#{sym}
|
83
|
-
# @@#{sym}
|
84
|
-
# end
|
85
|
-
#
|
86
|
-
# def #{sym}
|
87
|
-
# @@#{sym}
|
88
|
-
# end
|
89
|
-
# EOS
|
90
|
-
# end
|
91
|
-
# end
|
92
|
-
#
|
93
|
-
# def cattr_writer(*syms)
|
94
|
-
# syms.flatten.each do |sym|
|
95
|
-
# class_eval(<<-EOS, __FILE__, __LINE__)
|
96
|
-
# unless defined? @@#{sym}
|
97
|
-
# @@#{sym} = nil
|
98
|
-
# end
|
99
|
-
#
|
100
|
-
# def self.#{sym}=(obj)
|
101
|
-
# @@#{sym} = obj
|
102
|
-
# end
|
103
|
-
#
|
104
|
-
# def #{sym}=(obj)
|
105
|
-
# @@#{sym} = obj
|
106
|
-
# end
|
107
|
-
# EOS
|
108
|
-
# end
|
109
|
-
# end
|
110
|
-
#
|
111
|
-
# def cattr_accessor(*syms)
|
112
|
-
# cattr_reader(*syms)
|
113
|
-
# cattr_writer(*syms)
|
114
|
-
# end
|
74
|
+
#
|
75
|
+
# def cattr_reader(*syms)
|
76
|
+
# syms.flatten.each do |sym|
|
77
|
+
# class_eval(<<-EOS, __FILE__, __LINE__)
|
78
|
+
# unless defined? @@#{sym}
|
79
|
+
# @@#{sym} = nil
|
80
|
+
# end
|
81
|
+
#
|
82
|
+
# def self.#{sym}
|
83
|
+
# @@#{sym}
|
84
|
+
# end
|
85
|
+
#
|
86
|
+
# def #{sym}
|
87
|
+
# @@#{sym}
|
88
|
+
# end
|
89
|
+
# EOS
|
90
|
+
# end
|
91
|
+
# end
|
92
|
+
#
|
93
|
+
# def cattr_writer(*syms)
|
94
|
+
# syms.flatten.each do |sym|
|
95
|
+
# class_eval(<<-EOS, __FILE__, __LINE__)
|
96
|
+
# unless defined? @@#{sym}
|
97
|
+
# @@#{sym} = nil
|
98
|
+
# end
|
99
|
+
#
|
100
|
+
# def self.#{sym}=(obj)
|
101
|
+
# @@#{sym} = obj
|
102
|
+
# end
|
103
|
+
#
|
104
|
+
# def #{sym}=(obj)
|
105
|
+
# @@#{sym} = obj
|
106
|
+
# end
|
107
|
+
# EOS
|
108
|
+
# end
|
109
|
+
# end
|
110
|
+
#
|
111
|
+
# def cattr_accessor(*syms)
|
112
|
+
# cattr_reader(*syms)
|
113
|
+
# cattr_writer(*syms)
|
114
|
+
# end
|
115
115
|
|
116
116
|
# To be implemented.
|
117
117
|
def transform(xml, client=nil)
|
@@ -222,6 +222,11 @@ The above code generates the following xhtml in Firefox:
|
|
222
222
|
#1. id: name of the form
|
223
223
|
#2. action: the action url that is invoked
|
224
224
|
#3. method: http 'get' or 'post'
|
225
|
+
#==== Examples
|
226
|
+
# @xml.form(@doc, "f1", "login", "post") {}
|
227
|
+
#generates the following xhtml:
|
228
|
+
# <form method="post" action="login" id="f1" >
|
229
|
+
# </form>
|
225
230
|
def form(doc, id, action, method)
|
226
231
|
doc << "\n<form method=\"" << method.downcase << "\" action=\"" << action <<
|
227
232
|
"\" id=\"#{id}\" #{options[:style]}>"
|
@@ -234,6 +239,11 @@ The above code generates the following xhtml in Firefox:
|
|
234
239
|
#2. txt: text displayed in the link
|
235
240
|
#==== Options
|
236
241
|
#* <tt>:style</tt> -- specifies html, xhtml style attributes as a string
|
242
|
+
#==== Examples
|
243
|
+
# args= {:xstyle=>'height="1ex" width="20em"', :style=>'class="btm-menu"'}
|
244
|
+
# @xml.link(@doc, "index", "Friends", args)
|
245
|
+
#generates the following xhtml:
|
246
|
+
# <a href="index" class="btm-menu">Friends</a>
|
237
247
|
def link(doc, href, txt="", options={}, &block)
|
238
248
|
doc << "\n<a href=\"#{href}\" #{options[:style]}"
|
239
249
|
doc << ">" << txt << '</a>'
|
@@ -256,13 +266,20 @@ The above code generates the following xhtml in Firefox:
|
|
256
266
|
#==== Options
|
257
267
|
#* <tt>:style</tt> -- specifies html, xhtml style attributes as a string
|
258
268
|
#* <tt>:alt</tt> -- html alt attribute
|
269
|
+
#==== Examples
|
270
|
+
# img = {:alt=>"Rails", :xstyle=>'height="5ex" width="100%"'}
|
271
|
+
# @xml.image(body, "img1", 'http://homer.qa.mobiolabs.com/cms/images/default/glp/bn/til/top-wcric.png', img)
|
272
|
+
#generates the following xhtml:
|
273
|
+
# <img id="img1"
|
274
|
+
# src="http://homer.qa.mobiolabs.com/cms/images/default/glp/bn/til/top-wcric.png"
|
275
|
+
# alt="Rails"/>
|
259
276
|
def image(doc, id, src, options={})
|
260
277
|
doc << "\n<img id=\"#{id}\" src=\"" << src << "\" #{options[:style]}"
|
261
278
|
doc << " alt=\"" << options[:alt] << "\"" if options[:alt]
|
262
279
|
doc << '/>'
|
263
280
|
end
|
264
281
|
#Not implemented for html client
|
265
|
-
def instance_tag(doc, id)
|
282
|
+
def instance_tag(doc, id, src=nil, &block)
|
266
283
|
# do nothing, only implemented in xforms
|
267
284
|
end
|
268
285
|
#Create table tag
|
@@ -284,6 +301,29 @@ The above code generates the following xhtml in Firefox:
|
|
284
301
|
yield doc
|
285
302
|
doc << '</td>'
|
286
303
|
end
|
304
|
+
|
305
|
+
# The following tags are only supported by xforms client
|
306
|
+
def tab(doc, options={})
|
307
|
+
end
|
308
|
+
def switch(doc)
|
309
|
+
yield
|
310
|
+
end
|
311
|
+
def xcase(doc, options={})
|
312
|
+
yield
|
313
|
+
end
|
314
|
+
def softkey(doc, position="1", label="", refid=nil)
|
315
|
+
yield doc
|
316
|
+
end
|
317
|
+
def menus(doc, id, label="Options")
|
318
|
+
yield doc
|
319
|
+
end
|
320
|
+
def menu(doc, label, accesskey=nil, &block)
|
321
|
+
if block
|
322
|
+
yield doc
|
323
|
+
end
|
324
|
+
end
|
325
|
+
def load_tag(doc, resource)
|
326
|
+
end
|
287
327
|
end
|
288
328
|
end
|
289
329
|
end
|
@@ -75,7 +75,8 @@ A rails icon and some text will be displayed on Mobio runner when you load the r
|
|
75
75
|
|
76
76
|
@model_buffer = '<head>'
|
77
77
|
@model_buffer << "\n<model>"
|
78
|
-
|
78
|
+
|
79
|
+
basic_styles
|
79
80
|
yield xml
|
80
81
|
|
81
82
|
@model_buffer << "</model></head>\n"
|
@@ -427,7 +428,7 @@ A rails icon and some text will be displayed on Mobio runner when you load the r
|
|
427
428
|
def link(doc, href, txt="", options={}, &block)
|
428
429
|
@view_buffer << "\n<m:button"
|
429
430
|
if options[:xstyle]
|
430
|
-
@view_buffer << ' ' << options[:
|
431
|
+
@view_buffer << ' ' << options[:xstyle]
|
431
432
|
else
|
432
433
|
@view_buffer << " height=\"1ex\""
|
433
434
|
end
|
@@ -467,6 +468,8 @@ A rails icon and some text will be displayed on Mobio runner when you load the r
|
|
467
468
|
#etc. as string.
|
468
469
|
#* <tt>:widget</tt> -- specifies the widget to use, "icon" or "image". Default\
|
469
470
|
#is <image>.
|
471
|
+
#* <tt>:xpath</tt> -- specifies the xpath for the instance data that contains \
|
472
|
+
#the image url. It's only used when id attribute is specified.
|
470
473
|
#
|
471
474
|
#==== Examples (
|
472
475
|
#* Create a simple image control\
|
@@ -513,6 +516,8 @@ A rails icon and some text will be displayed on Mobio runner when you load the r
|
|
513
516
|
|
514
517
|
#Create an instance in the model
|
515
518
|
#1. id: the name of the instance that will be created
|
519
|
+
#2. src: the src of the instance data. If src is specified, the call block
|
520
|
+
#will not be executed.
|
516
521
|
#==== Examples
|
517
522
|
#* Create a blank instance:
|
518
523
|
# @xml.instance_tag(body, "foo")
|
@@ -533,12 +538,36 @@ A rails icon and some text will be displayed on Mobio runner when you load the r
|
|
533
538
|
# <info phone="415-1111111" zip="95014">Basic</info>
|
534
539
|
# </data>
|
535
540
|
# </xf:instance>
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
541
|
+
#
|
542
|
+
#* Create an instance from a src url. The src url should return the instance \
|
543
|
+
#data with HTTP content-type set to 'application/xml'. The instance data is \
|
544
|
+
#RELOADED every time the page is requested no matter it's cached or not. \
|
545
|
+
#This is useful when you want the whole xforms UI cached but a small \
|
546
|
+
#set of instance data be refreshed every time user reloads the page.
|
547
|
+
#
|
548
|
+
# @xml.instance_tag(body, "", "get_data")
|
549
|
+
#
|
550
|
+
#The rxml generates the following xforms in the model:
|
551
|
+
# <xf:instance id="emails" src="get_data"/>
|
552
|
+
#
|
553
|
+
#and the template for url "get_data" returns this: (note the content-type header)
|
554
|
+
# <% headers['Content-Type']='application/xml' %>
|
555
|
+
# <data xmlns="">
|
556
|
+
# <email id ="1" date="4/3" read="0" check="" from="richard H.">Lunch?</email>
|
557
|
+
# <email id ="2" date="4/2" read="0" check="" from="admin@foo.com">Meeting reminder</email>
|
558
|
+
# <email id ="3" date="4/2" read="1" check="" from="customerservice@amazon.com">Your account activities</email>
|
559
|
+
# </data>
|
560
|
+
#
|
561
|
+
def instance_tag(doc, id, src=nil, &block)
|
562
|
+
if src.nil?
|
563
|
+
@model_buffer << "\n<xf:instance id=\"#{id}\"><data xmlns=\"\">"
|
564
|
+
if block
|
565
|
+
yield doc
|
566
|
+
end
|
567
|
+
@model_buffer << '</data></xf:instance>'
|
568
|
+
else
|
569
|
+
@model_buffer << "\n<xf:instance src=\"#{src}\"/>"
|
540
570
|
end
|
541
|
-
@model_buffer << '</data></xf:instance>'
|
542
571
|
end
|
543
572
|
|
544
573
|
#Create grid control, similar to table in html
|
@@ -559,7 +588,244 @@ A rails icon and some text will be displayed on Mobio runner when you load the r
|
|
559
588
|
yield doc
|
560
589
|
@view_buffer << '</m:item>'
|
561
590
|
end
|
562
|
-
|
591
|
+
|
592
|
+
#Create a Tab control
|
593
|
+
#1. xstyle: the xforms style string. If xstyle is not specified, the default\
|
594
|
+
# value 'height="100% width="100% style="tabbody"' will be used. You need to \
|
595
|
+
# define a style class "tabbody" if you want to style the widget. \
|
596
|
+
# The tag is always followed by several xcase tags to create a complete UI \
|
597
|
+
# for Tabs.
|
598
|
+
#
|
599
|
+
#==== Examples
|
600
|
+
#Create a tab control that contains 2 case in the tab body and header:
|
601
|
+
#
|
602
|
+
# @xml.tab(body) do |tab|
|
603
|
+
# @xml.xcase(tab, "first", "Current Match", 'style="tab"') do |xcase|
|
604
|
+
# @xml.text(body, "hello world!")
|
605
|
+
# end
|
606
|
+
# @xml.xcase(tab, "2nd", "future", 'style="tab"') do |xcase|
|
607
|
+
# @xml.text(body, "hello world!")
|
608
|
+
# end
|
609
|
+
# end
|
610
|
+
#generates the following xforms in the view:
|
611
|
+
# <m:tab width="100%" height="100%" style="tabbody">
|
612
|
+
# <m:case id="first" label="Current Match" >
|
613
|
+
# <m:output height="1ex">hello world!</m:output>
|
614
|
+
# </m:case>
|
615
|
+
# <m:case id="2nd" label="future" style="tab">
|
616
|
+
# <m:output height="1ex">Second Page</m:output>
|
617
|
+
# </m:case>
|
618
|
+
# </m:tab>
|
619
|
+
#
|
620
|
+
def tab(doc, xstyle='width="100%" height="100%" style="tabbody"')
|
621
|
+
@view_buffer << "<m:tab #{xstyle}>"
|
622
|
+
yield doc
|
623
|
+
@view_buffer << '</m:tab>'
|
624
|
+
# <case id="second" label="Price"
|
625
|
+
# style="tab">
|
626
|
+
end
|
627
|
+
|
628
|
+
#Create swtich case control, similar to Tab control but without the tab UI.
|
629
|
+
#This tag and xcase tag can create muliple switch
|
630
|
+
#case for xforms client to provide multiple UIs in a form that can be toggled
|
631
|
+
#back and forth using the xf:toggle command. Refer to client user manual
|
632
|
+
#for the usage.
|
633
|
+
#
|
634
|
+
#==== Examples
|
635
|
+
# @xml.switch(body) do |tab|
|
636
|
+
# @xml.xcase(tab, "b") do |c1|
|
637
|
+
# @xml.text(c1, "hello world!")
|
638
|
+
# end
|
639
|
+
# @xml.xcase(tab, "a") do |xcase|
|
640
|
+
# @xml.text(body, "hello world!")
|
641
|
+
# end
|
642
|
+
# end
|
643
|
+
#generates the following:
|
644
|
+
# <m:switch>
|
645
|
+
# <m:case id="b" label="" >
|
646
|
+
# <m:output height="1ex">hello world!</m:output>
|
647
|
+
# </m:case>
|
648
|
+
# <m:case id="a" label="" >
|
649
|
+
# <m:output height="1ex">hello world!</m:output>
|
650
|
+
# </m:case>
|
651
|
+
# </m:switch>
|
652
|
+
def switch(doc)
|
653
|
+
@view_buffer << "<m:switch>"
|
654
|
+
yield doc
|
655
|
+
@view_buffer << '</m:switch>'
|
656
|
+
end
|
657
|
+
|
658
|
+
#Create a case control. This tag cannot act along. It has to be wrapped in
|
659
|
+
#either a "switch" tag or a "tab" tag.
|
660
|
+
#See the document and examples in tab and switch tag.
|
661
|
+
#1. id: the case reference id
|
662
|
+
#2. label: what is displayed in the tab header (only needed in tab case)
|
663
|
+
#3. xstyle: the xforms style string for the case (only needed in tab case)
|
664
|
+
#
|
665
|
+
def xcase(doc, id, label=nil, xstyle=nil)
|
666
|
+
@view_buffer << "<m:case id=\"#{id}\" label=\"#{label}\" #{xstyle}>"
|
667
|
+
yield doc
|
668
|
+
@view_buffer << '</m:case>'
|
669
|
+
end
|
670
|
+
|
671
|
+
#Create a softkey menu.
|
672
|
+
#1. position: "1" for left softkey and "3" for right softkey
|
673
|
+
#2. label: what is displayed in the tab header (only needed in tab case)
|
674
|
+
#3. xstyle: the xforms style string for the case (only needed in tab case)
|
675
|
+
#
|
676
|
+
#==== Examples
|
677
|
+
#* Softkey with a load action. The left softkey is created with label "GO" \
|
678
|
+
#and will load page foo2.xml when the softkey is pressed.
|
679
|
+
# @xml.softkey(body, "1", "GO") do |soft1|
|
680
|
+
# @xml.load_tag(soft1, "foo2.xml")
|
681
|
+
# end
|
682
|
+
#generates the following:
|
683
|
+
# <m:softkey position="1">
|
684
|
+
# <m:label>GO</m:label>
|
685
|
+
# <xf:load resource="foo2.xml" ev:event="DOMActivate"/>
|
686
|
+
# </m:softkey>
|
687
|
+
#
|
688
|
+
#* Softkey that pops up an Options menu. When right softkey is pressed, a popup\
|
689
|
+
#menu "Options" will display 4 menu items. The first 3 menu items are assigned\
|
690
|
+
#a default accesskey. The last menu item defines its own access key "0" \
|
691
|
+
#which is reserved for exit action.
|
692
|
+
# @xml.softkey(body, "3", "Options", "menu1")
|
693
|
+
# @xml.menus(body, "menu1", "Options") do |menus|
|
694
|
+
# @xml.menu(menus, "move1") do |item|
|
695
|
+
# @xml.load_tag(item, "foo1.xml")
|
696
|
+
# end
|
697
|
+
# @xml.menu(menus, "move2") do |item|
|
698
|
+
# @xml.load_tag(item, 'foo2.xml')
|
699
|
+
# end
|
700
|
+
# @xml.menu(menus, "move3")
|
701
|
+
# @xml.menu(menus, "exit", "0") do |item|
|
702
|
+
# @xml.view_tag(item, '<m:exit ev:event="DOMActivate"/>')
|
703
|
+
# end
|
704
|
+
# end
|
705
|
+
# end
|
706
|
+
#genereates the following:
|
707
|
+
# <m:softkey position="3">
|
708
|
+
# <m:label>Options</m:label>
|
709
|
+
# <m:show-popup refid="menu1" ev:event="DOMActivate" />
|
710
|
+
# </m:softkey>
|
711
|
+
#
|
712
|
+
# <m:menu id="menu1" height="0" width="40%" style="popup-menu">
|
713
|
+
# <m:hstack height="1ex" style="title"><m:icon>jar://img/option.png</m:icon>
|
714
|
+
# <m:output style="option">Options</m:output>
|
715
|
+
# </m:hstack>
|
716
|
+
# <m:itemlist height="0" style="menu">
|
717
|
+
# <m:item style="optionmenu" height="1ex" accesskey="1">
|
718
|
+
# <m:output style="label">move1</m:output>
|
719
|
+
# <xf:load resource="foo1.xml" ev:event="DOMActivate"/>
|
720
|
+
# </m:item>
|
721
|
+
# <m:item style="optionmenu" height="1ex" accesskey="2">
|
722
|
+
# <m:output style="label">move2</m:output>
|
723
|
+
# <xf:load resource="foo2.xml" ev:event="DOMActivate"/>
|
724
|
+
# </m:item>
|
725
|
+
# <m:item style="optionmenu" height="1ex" accesskey="3">
|
726
|
+
# <m:output style="label">move3</m:output>
|
727
|
+
# </m:item>
|
728
|
+
# <m:item style="optionmenu" height="1ex" accesskey="0">
|
729
|
+
# <m:output style="label">exit</m:output>
|
730
|
+
# <m:exit ev:event="DOMActivate"/>
|
731
|
+
# </m:item>
|
732
|
+
# </m:itemlist>
|
733
|
+
#
|
734
|
+
# <m:softkey position="3"/>
|
735
|
+
# <m:softkey position="1">
|
736
|
+
# <m:hide-popup ev:event="DOMActivate" refid="menu1" />
|
737
|
+
# <m:label>Close</m:label>
|
738
|
+
# </m:softkey>
|
739
|
+
# </m:menu>
|
740
|
+
def softkey(doc, position="1", label="", refid=nil)
|
741
|
+
@view_buffer << "<m:softkey position=\"#{position}\"><m:label>#{label}</m:label>"
|
742
|
+
|
743
|
+
# If we have a refid, setup a popup for the child menus; otherwise, execute
|
744
|
+
# the proc to take action.
|
745
|
+
if refid.nil?
|
746
|
+
yield doc
|
747
|
+
else
|
748
|
+
@view_buffer << "<m:show-popup refid=\"#{refid}\" ev:event=\"DOMActivate\" />"
|
749
|
+
end
|
750
|
+
@view_buffer << '</m:softkey>'
|
751
|
+
end
|
752
|
+
#A holders for a popup menu.
|
753
|
+
#1. id: the widget's reference id. The id is used by softkey to trigger the popup\
|
754
|
+
#action.
|
755
|
+
#2. label: what is displayed on the title of the popup window. Default label \
|
756
|
+
#is "Options".
|
757
|
+
#3. xstyle: the xforms style string for the popup window. If xstyle is not \
|
758
|
+
#specified, default style string "width='40%' style='popup-menu'" is used.
|
759
|
+
#==== Examples
|
760
|
+
#Refer to softkey examples
|
761
|
+
def menus(doc, id, label="Options", xstyle=nil)
|
762
|
+
@view_buffer << "<m:menu id=\"#{id}\" height=\"0\""
|
763
|
+
if xstyle
|
764
|
+
@view_buffer << " #{xstyle}>"
|
765
|
+
else
|
766
|
+
@view_buffer << " width=\"40%\" style=\"popup-menu\">"
|
767
|
+
end
|
768
|
+
|
769
|
+
@view_buffer << "<m:hstack height=\"1ex\" style=\"title\"><m:icon>jar://img/option.png</m:icon>"
|
770
|
+
@view_buffer << "<m:output style=\"option\">#{label}</m:output></m:hstack>"
|
771
|
+
@accesskey=0
|
772
|
+
|
773
|
+
@view_buffer << "<m:itemlist height=\"0\" style=\"menu\"> "
|
774
|
+
yield doc
|
775
|
+
@view_buffer << "</m:itemlist>"
|
776
|
+
@view_buffer << "<m:softkey position=\"3\"/>
|
777
|
+
<m:softkey position=\"1\"><m:hide-popup ev:event=\"DOMActivate\" refid=\"#{id}\" />
|
778
|
+
<m:label>Close</m:label></m:softkey></m:menu>"
|
779
|
+
|
780
|
+
end
|
781
|
+
|
782
|
+
#Create an action item in a popup menu.
|
783
|
+
#1. label: what is displayed on the title of the popup window. Default label \
|
784
|
+
#is "Options".
|
785
|
+
#2. accesskey: A short cut key (0-9) that is assigned to this menu item. If \
|
786
|
+
#not specified, it is asssinged a number sequentially.
|
787
|
+
#3. xstyle: the xforms style string for the menu item. If xstyle is not \
|
788
|
+
#specified, default style string "style='optionmenu'" is used.
|
789
|
+
#==== Examples
|
790
|
+
#Refer to softkey examples
|
791
|
+
def menu(doc, label, accesskey=nil, xstyle=nil, &block)
|
792
|
+
@view_buffer << "<m:item height=\"1ex\" accesskey=\""
|
793
|
+
if accesskey
|
794
|
+
@view_buffer << accesskey
|
795
|
+
else
|
796
|
+
@view_buffer << "#{@accesskey+=1}"
|
797
|
+
end
|
798
|
+
@view_buffer << "\">"
|
799
|
+
if xstyle
|
800
|
+
@view_buffer << " style=\"#{xstyle}\""
|
801
|
+
else
|
802
|
+
@view_buffer << " style=\"optionmenu\""
|
803
|
+
end
|
804
|
+
@view_buffer << "<m:output style=\"label\">" << label << "</m:output>"
|
805
|
+
if block
|
806
|
+
yield doc
|
807
|
+
end
|
808
|
+
@view_buffer << "</m:item>"
|
809
|
+
end
|
810
|
+
|
811
|
+
#Create <xf:load> control to do a HTTP get for a new form. Default event
|
812
|
+
#is "DOMActivate".
|
813
|
+
#1. resource: the resource url that will be loaded.
|
814
|
+
#
|
815
|
+
#==== Examples
|
816
|
+
# @xml.softkey(body, "1", "GO") do |soft1|
|
817
|
+
# @xml.load_tag(soft1, "foo2.xml")
|
818
|
+
# end
|
819
|
+
#generates the following:
|
820
|
+
# <m:softkey position="1">
|
821
|
+
# <m:label>GO</m:label>
|
822
|
+
# <xf:load resource="foo2.xml" ev:event="DOMActivate"/>
|
823
|
+
# </m:softkey>
|
824
|
+
#
|
825
|
+
def load_tag(doc, resource)
|
826
|
+
@view_buffer << "<xf:load resource=\"#{resource}\" ev:event=\"DOMActivate\"/>"
|
827
|
+
end
|
828
|
+
|
563
829
|
#Override builder method_missing method to send output to model buffer so we
|
564
830
|
#can create arbitrary xml tags in the model. Typically combine with instance_tag
|
565
831
|
#to create model instance that can be used in any of the action tag (link, submit_tag, etc.)
|
@@ -643,6 +909,138 @@ A rails icon and some text will be displayed on Mobio runner when you load the r
|
|
643
909
|
@model_buffer << %{ #{k}="#{_attr_value(v)}"} unless order.member?(k) # " WART
|
644
910
|
end
|
645
911
|
end
|
912
|
+
|
913
|
+
# Put some default styles if user doesn't specify any
|
914
|
+
def basic_styles
|
915
|
+
@model_buffer << "<m:style xmlns=\"http://www.mobio.com/ext\">"
|
916
|
+
|
917
|
+
#skin
|
918
|
+
lightBlue = "#CADBDB";
|
919
|
+
brown = "#89613A";
|
920
|
+
turqoise = "#89B0B0";
|
921
|
+
@model_buffer << "<m:class name=\"body\"><m:background-color value=\"#ffffff\"/><m:scrollbar-track-color value=\"#{turqoise}\"/><m:scrollbar-slider-color value=\"#003366\" /></m:class>"
|
922
|
+
|
923
|
+
@model_buffer << '<m:class name="white"><m:font-color value="#ffffff"/></m:class>'
|
924
|
+
@model_buffer << '<m:class name="white:focused"><m:font-color value="#0"/></m:class>'
|
925
|
+
|
926
|
+
|
927
|
+
@model_buffer <<
|
928
|
+
'<class name="label">
|
929
|
+
<font-color value="#000000" />
|
930
|
+
</class>'
|
931
|
+
@model_buffer <<
|
932
|
+
'<class name="label:selected">
|
933
|
+
<font-color value="#ffffff" />
|
934
|
+
</class>'
|
935
|
+
@model_buffer <<
|
936
|
+
'<m:class name="tabbody">
|
937
|
+
<m:background-color value="#transparent" />
|
938
|
+
</m:class>'
|
939
|
+
|
940
|
+
@model_buffer <<
|
941
|
+
'<m:class name="tab">
|
942
|
+
<m:background-color value="#80B380" />
|
943
|
+
<m:font-color value="#ffffff" />
|
944
|
+
<m:font-weight value="bold" />
|
945
|
+
</m:class>'
|
946
|
+
|
947
|
+
@model_buffer <<
|
948
|
+
'<m:class name="tab:focused">
|
949
|
+
<m:background-color value="#FFFFFF" />
|
950
|
+
<m:font-color value="#000000" />
|
951
|
+
<m:font-weight value="bold" />
|
952
|
+
</m:class> '
|
953
|
+
@model_buffer <<
|
954
|
+
'<m:class name="bold">
|
955
|
+
<m:font-weight value="bold" />
|
956
|
+
</m:class>'
|
957
|
+
|
958
|
+
@model_buffer <<
|
959
|
+
'<m:class name="item">
|
960
|
+
<m:background-color value="transparent" />
|
961
|
+
</m:class>'
|
962
|
+
@model_buffer <<
|
963
|
+
"<m:class name=\"item:focused\">
|
964
|
+
<m:background-color value=\"#{brown}\"/>
|
965
|
+
<m:font-color value=\"#ffffff\"/>
|
966
|
+
</m:class>"
|
967
|
+
@model_buffer <<
|
968
|
+
"<m:class name=\"popup-menu\">
|
969
|
+
<m:background-color value=\"#{lightBlue}\" />
|
970
|
+
<m:border value=\"1\" />
|
971
|
+
<m:margin value=\"0,0,2,2\" />
|
972
|
+
</m:class>"
|
973
|
+
|
974
|
+
@model_buffer <<
|
975
|
+
'<m:class name="menu">
|
976
|
+
<m:margin value="2,0,2,2" />
|
977
|
+
</m:class>'
|
978
|
+
|
979
|
+
@model_buffer <<
|
980
|
+
'<m:class name="optionmenu">
|
981
|
+
<m:background-color value="#ffffff" />
|
982
|
+
</m:class>'
|
983
|
+
@model_buffer <<
|
984
|
+
"<m:class name=\"optionmenu:focused\">
|
985
|
+
<m:background-color value=\"#{brown}\" />
|
986
|
+
</m:class>"
|
987
|
+
@model_buffer <<
|
988
|
+
'<m:class name="input">
|
989
|
+
<m:background-color value="transparent" />
|
990
|
+
<m:margin value="1,2,1,1" />
|
991
|
+
</m:class>'
|
992
|
+
@model_buffer <<
|
993
|
+
"<m:class name=\"input:focused\">
|
994
|
+
<m:background-color value=\"#{brown}\" />
|
995
|
+
</m:class>"
|
996
|
+
|
997
|
+
@model_buffer <<
|
998
|
+
"<m:class name=\"button\">
|
999
|
+
<m:align value=\"center,text-center\" />
|
1000
|
+
<m:background-color value=\"#{lightBlue}\" />
|
1001
|
+
<m:border-color value=\"#{turqoise}\" />
|
1002
|
+
<m:margin value=\"0,2,0,2\" />
|
1003
|
+
</m:class>"
|
1004
|
+
@model_buffer <<
|
1005
|
+
"<m:class name=\"button:focused\">
|
1006
|
+
<m:font-color value=\"#FFFFFF\" />
|
1007
|
+
<m:background-color value=\"#{brown}\" />
|
1008
|
+
</m:class>"
|
1009
|
+
|
1010
|
+
@model_buffer <<
|
1011
|
+
"<m:class name=\"button:disabled\">
|
1012
|
+
<background-color value=\"transparent\" />
|
1013
|
+
<border value=\"1\"/>
|
1014
|
+
<border-color value=\"#{lightBlue}\"/>
|
1015
|
+
</m:class> "
|
1016
|
+
|
1017
|
+
@model_buffer <<
|
1018
|
+
'<m:class name="slist">
|
1019
|
+
<m:margin value="0,2,0,0"/>
|
1020
|
+
</m:class>'
|
1021
|
+
|
1022
|
+
# <m:class name="popup">
|
1023
|
+
# <m:background-color value="#FFFFFF" />
|
1024
|
+
# <m:border value="1" />
|
1025
|
+
# </m:class>
|
1026
|
+
# <m:class name="popup-title">
|
1027
|
+
# <m:background-color value="<%=lightBlue%>" />
|
1028
|
+
# <m:margin value="2,2,2,1" />
|
1029
|
+
# </m:class>
|
1030
|
+
# <m:class name="popup-bold" parent="bold">
|
1031
|
+
# <m:margin value="3,3,2,2" />
|
1032
|
+
# </m:class>
|
1033
|
+
# <m:class name="popup-in" parent="in">
|
1034
|
+
# <m:margin value="3,0,10,3" />
|
1035
|
+
# </m:class>
|
1036
|
+
# <m:class name="popup-item" parent="item" >
|
1037
|
+
# <m:margin value="2,1,2,1" />
|
1038
|
+
# </m:class>
|
1039
|
+
# #
|
1040
|
+
|
1041
|
+
@model_buffer << "</m:style>"
|
1042
|
+
end
|
1043
|
+
|
646
1044
|
# End builder methods
|
647
1045
|
end
|
648
1046
|
end
|
data/lib/rmobio/utils.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rmobio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mobio Networks
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-04-
|
12
|
+
date: 2008-04-20 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|