SrBuj 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/SrBuj/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module SrBuj
2
- VERSION = '0.2.3'
2
+ VERSION = '0.3.0'
3
3
  end
@@ -28,19 +28,28 @@
28
28
  }
29
29
 
30
30
  },
31
+ getVerb: function($el){
32
+ var dataVerb = $el.data('method'),
33
+ replace = $el.data('replace'),
34
+ proto = $el.attr('method') || 'GET';
35
+
36
+ if( dataVerb )
37
+ return dataVerb.toUpperCase()
38
+ else
39
+ return ( replace && proto.toUpperCase() == 'POST' ) ? 'PUT' : proto.toUpperCase();
40
+ },
31
41
  success: function(e, data){
32
42
  var $el = $(e.target),
33
43
  isModal = $el.data('modal') || false,
34
- verb = $el.attr('method') || 'GET',
35
- method = ( verb.toUpperCase() == 'POST' && $el.data('replace')) ? 'PUT' : verb.toUpperCase();
36
- change = $el.attr('nochange') || true,
44
+ method = $.SrBuj.getVerb($el),
45
+ change = $el.attr('nochange') && false || true,
37
46
  fn = $el.data('callback'),
38
47
  callback = (typeof fn == 'function') ? fn : window[fn],
39
48
  target = document.getElementById($el.data('target')),
40
49
  wrapper = document.getElementById($el.data('error')),
41
50
  $target = $(target);
42
51
 
43
- if(change) $.SrBuj.changeDom(method.toUpperCase(),$target,data);
52
+ if(change) $.SrBuj.changeDom(method,$target,data);
44
53
  if(isModal) wrapper ? $(wrapper).modal('toggle') : $target.modal('toggle');
45
54
  if(callback) callback.apply(this,[e, data]);
46
55
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: SrBuj
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2013-03-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
- requirement: &70302604334460 !ruby/object:Gem::Requirement
16
+ requirement: &70239463969480 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.3'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70302604334460
24
+ version_requirements: *70239463969480
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: railties
27
- requirement: &70302604332220 !ruby/object:Gem::Requirement
27
+ requirement: &70239463968180 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '3.1'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70302604332220
35
+ version_requirements: *70239463968180
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &70302604330220 !ruby/object:Gem::Requirement
38
+ requirement: &70239463967160 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70302604330220
46
+ version_requirements: *70239463967160
47
47
  description: Better Unobtrusive JavaScript Request in asset pipeline
48
48
  email:
49
49
  - xeroice@gmail.com