anychart_xml_builder 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'rake'
4
4
  begin
5
5
  require 'jeweler'
6
6
  Jeweler::Tasks.new do |gem|
7
- gem.version = "0.0.2"
7
+ gem.version = "0.0.3"
8
8
  gem.name = "anychart_xml_builder"
9
9
  gem.summary = %Q{AnyChart (http://anychart.com/home/) XML Builders}
10
10
  gem.description = %Q{This gem provides you the methods to easily generate the XML necessary for AnyChart}
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{anychart_xml_builder}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["jduarte"]
@@ -1,61 +1,71 @@
1
- module Anychart
2
-
3
- module ViewHelpers
4
-
5
- @@default_options = {
6
- :anychart_swf_path => '/anychart_swfs/AnyChart.swf',
7
- :anychart_swf_preloader => '/anychart_swfs/Preloader.swf',
8
- :div_id => 'anychart'
9
- }
10
-
11
- def anychart(xml, options={})
12
- opts = @@default_options.merge(options)
13
- "<div id='#{opts[:div_id]}'>
14
- <noscript>
15
- <object id='chart'
16
- name='chart'
17
- classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'
18
- width='100%'
19
- height='100%'
20
- codebase='http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab'>
21
- <param name='movie' value='#{opts[:anychart_swf_preloader]}' />
22
- <param name='bgcolor' value='#FFFFFF' />
23
- <param name='allowScriptAccess' value='always' />
24
- <param name='flashvars' value='swfFile=#{opts[:anychart_swf_path]}&XMLFile=#{xml}' />
1
+ require 'action_view'
2
+
3
+ module ActionView #:nodoc:
4
+ module Helpers # :nodoc:
5
+ module AnychartHelper # :nodoc:
6
+
7
+ def self.included(base)
8
+ base.send(:include, InstanceMethods)
9
+ end
10
+
11
+ module InstanceMethods
12
+ @@default_options = {
13
+ :anychart_swf_path => '/anychart_swfs/AnyChart.swf',
14
+ :anychart_swf_preloader => '/anychart_swfs/Preloader.swf',
15
+ :div_id => 'anychart'
16
+ }
25
17
 
26
- <embed type='application/x-shockwave-flash'
27
- pluginspage='http://www.adobe.com/go/getflashplayer'
28
- src='#{opts[:anychart_swf_preloader]}'
29
- width='100%'
30
- height='100%'
31
- id='chart'
32
- name='chart'
33
- bgColor='#FFFFFF'
34
- allowScriptAccess='always'
35
- flashvars='swfFile=#{opts[:anychart_swf_path]}&XMLFile=#{xml}' />
36
- </object>
37
- </noscript>
38
- <script type='text/javascript'>
39
- //<![CDATA[
40
- document.write('<center>');
41
- document.write('You need to have Adobe Flash Player 9 (or above) to view the chart.<br /><br />');
42
- document.write('<a href=\'http://www.adobe.com/go/getflashplayer\'><img border=\'0\' src=\'http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif\' /></a><br />');
43
- document.write('</center>');
44
- //]]>
45
- </script>
18
+ def anychart(xml, options={})
19
+ opts = @@default_options.merge(options)
20
+ "<div id='#{opts[:div_id]}'>
21
+ <noscript>
22
+ <object id='chart'
23
+ name='chart'
24
+ classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'
25
+ width='100%'
26
+ height='100%'
27
+ codebase='http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab'>
28
+ <param name='movie' value='#{opts[:anychart_swf_preloader]}' />
29
+ <param name='bgcolor' value='#FFFFFF' />
30
+ <param name='allowScriptAccess' value='always' />
31
+ <param name='flashvars' value='swfFile=#{opts[:anychart_swf_path]}&XMLFile=#{xml}' />
46
32
 
47
- <script type='text/javascript' language='JavaScript'>
48
- //<![CDATA[
49
- var chartSample = new AnyChart('#{opts[:anychart_swf_path]}','#{opts[:anychart_swf_preloader]}');
50
- chartSample.width = '100%';
51
- chartSample.height = '100%';
52
- chartSample.setXMLFile('#{xml}');
53
- chartSample.write('#{opts[:div_id]}');
54
- //init();
55
- //]]>
56
- </script>
57
- </div>"
33
+ <embed type='application/x-shockwave-flash'
34
+ pluginspage='http://www.adobe.com/go/getflashplayer'
35
+ src='#{opts[:anychart_swf_preloader]}'
36
+ width='100%'
37
+ height='100%'
38
+ id='chart'
39
+ name='chart'
40
+ bgColor='#FFFFFF'
41
+ allowScriptAccess='always'
42
+ flashvars='swfFile=#{opts[:anychart_swf_path]}&XMLFile=#{xml}' />
43
+ </object>
44
+ </noscript>
45
+ <script type='text/javascript'>
46
+ //<![CDATA[
47
+ document.write('<center>');
48
+ document.write('You need to have Adobe Flash Player 9 (or above) to view the chart.<br /><br />');
49
+ document.write('<a href=\'http://www.adobe.com/go/getflashplayer\'><img border=\'0\' src=\'http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif\' /></a><br />');
50
+ document.write('</center>');
51
+ //]]>
52
+ </script>
53
+
54
+ <script type='text/javascript' language='JavaScript'>
55
+ //<![CDATA[
56
+ var chartSample = new AnyChart('#{opts[:anychart_swf_path]}','#{opts[:anychart_swf_preloader]}');
57
+ chartSample.width = '100%';
58
+ chartSample.height = '100%';
59
+ chartSample.setXMLFile('#{xml}');
60
+ chartSample.write('#{opts[:div_id]}');
61
+ //init();
62
+ //]]>
63
+ </script>
64
+ </div>"
65
+ end
66
+ end
58
67
  end
59
68
  end
60
-
61
- end
69
+ end
70
+
71
+ ActionView::Base.send(:include, ActionView::Helpers::AppletHelper)
@@ -1,33 +1,8 @@
1
1
  require 'nokogiri'
2
2
  require 'column_bar'
3
- require 'activesupport'
4
3
 
5
4
  module Anychart
6
-
7
- class << self
8
- def enable
9
- enable_actionpack
10
- end
11
-
12
- # hooks Anychart::ViewHelpers into ActionView::Base
13
- def enable_actionpack
14
- def enable_actionpack
15
- return if ActionView::Base.instance_methods.include_method? :anychart
16
- require 'anychart/view_helpers'
17
- ActionView::Base.send :include, ViewHelpers
18
-
19
- if defined?(ActionController::Base) and ActionController::Base.respond_to? :rescue_responses
20
- ActionController::Base.rescue_responses['Anychart::InvalidPage'] = :not_found
21
- end
22
- end
23
- end
24
- end
25
-
26
5
  module XML
27
6
 
28
7
  end
29
- end
30
-
31
- if defined? Rails
32
- Anychart.enable_actionpack if defined? ActionController
33
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anychart_xml_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - jduarte