mack-javascript 0.8.2 → 0.8.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.
@@ -21,7 +21,7 @@ module Mack
21
21
  end
22
22
 
23
23
  def link_to_remote(link_text, ajax_options, options = {})
24
- link_to_function(link_text, remote_function(ajax_options), options)
24
+ link_to_function(link_text, ajax(ajax_options), options)
25
25
  end
26
26
 
27
27
  def link_to_function(link_text, *args, &block)
@@ -33,12 +33,14 @@ module Mack
33
33
  end
34
34
 
35
35
  # Returns javascript that does an Ajax call
36
- def remote_function(options)
37
- Mack::JavaScript::ScriptGenerator.framework.remote_function(options)
36
+ def ajax(options)
37
+ Mack::JavaScript::ScriptGenerator.new(session.id).ajax(options).to_s
38
38
  end
39
39
 
40
+ alias_deprecated_method :remote_function, :ajax, '0.8.3', '>=0.8.4'
41
+
40
42
  def js
41
- Mack::JavaScript::ScriptGenerator.new
43
+ Mack::JavaScript::ScriptGenerator.new(session.id)
42
44
  end
43
45
 
44
46
  # Returns a button that links to a remote function.
@@ -48,10 +50,21 @@ module Mack
48
50
  def button_to_remote(value = "Submit", options = {}, *original_args)
49
51
  with = options.delete(:with) || 'Form.serialize(this.form)'
50
52
  url = options.delete(:url) || '#'
51
- options[:onclick] = remote_function(:with => with, :url => url) + '; return false'
53
+ options[:onclick] = ajax(:with => with, :url => url) + '; return false'
52
54
  submit_button(value, options, *original_args)
53
55
  end
54
56
 
57
+ def form_remote(action, options = {}, &block)
58
+ options[:form] = true
59
+ options[:url] = action
60
+ options[:html] ||= {}
61
+ options[:html][:onsubmit] =
62
+ (options[:html][:onsubmit] ? options[:html][:onsubmit] + "; " : "") +
63
+ "#{ajax(options)}; return false;"
64
+
65
+ form(action, options[:html], &block)
66
+ end
67
+
55
68
  end
56
69
  end
57
70
  end
@@ -24,16 +24,7 @@ dir_globs.each do |d|
24
24
  end
25
25
 
26
26
  if configatron.mack.js_framework
27
- case configatron.mack.js_framework.to_s
28
- when 'prototype'
29
- file_list = ["controls.js", "dragdrop.js", "effects.js", "prototype.js"]
30
- when 'jquery'
31
- file_list = ["jquery.js", "jquery-ui.js", "jquery-fx.js"]
32
- end
33
-
34
- file_list.each do |file|
35
- assets_mgr.defaults do |a|
36
- a.add_js file
37
- end
27
+ assets_mgr.defaults do |a|
28
+ a.add_js "#{configatron.mack.js_framework.to_s}.js"
38
29
  end
39
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mack-javascript
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerardo Pis-Lopez
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-30 00:00:00 -05:00
12
+ date: 2009-01-18 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -62,11 +62,6 @@ files:
62
62
  - lib/mack-javascript/generators/manifest.yml
63
63
  - lib/mack-javascript/generators/templates
64
64
  - lib/mack-javascript/generators/templates/javascripts
65
- - lib/mack-javascript/generators/templates/javascripts/controls.js.template
66
- - lib/mack-javascript/generators/templates/javascripts/dragdrop.js.template
67
- - lib/mack-javascript/generators/templates/javascripts/effects.js.template
68
- - lib/mack-javascript/generators/templates/javascripts/jquery-fx.js.template
69
- - lib/mack-javascript/generators/templates/javascripts/jquery-ui.js.template
70
65
  - lib/mack-javascript/generators/templates/javascripts/jquery.js.template
71
66
  - lib/mack-javascript/generators/templates/javascripts/prototype.js.template
72
67
  - lib/mack-javascript/helpers