SrBuj 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/SrBuj/version.rb +1 -1
- data/vendor/assets/javascripts/SrBuj.js +32 -12
- metadata +8 -8
data/lib/SrBuj/version.rb
CHANGED
@@ -11,27 +11,47 @@
|
|
11
11
|
var SrBuj;
|
12
12
|
$.SrBuj = SrBuj = {
|
13
13
|
selector: '[data-remote][data-target]',
|
14
|
+
changeDom: function(method,$target,data){
|
15
|
+
switch(method){
|
16
|
+
case 'POST':
|
17
|
+
$target.append(data);
|
18
|
+
break;
|
19
|
+
case 'PUT':
|
20
|
+
case 'PATCH':
|
21
|
+
$target.replaceWith(data);
|
22
|
+
break;
|
23
|
+
case 'DELETE':
|
24
|
+
$target.remove();
|
25
|
+
break;
|
26
|
+
default:
|
27
|
+
$target.html(data);
|
28
|
+
}
|
14
29
|
|
30
|
+
},
|
15
31
|
success: function(e, data){
|
16
32
|
var $el = $(e.target),
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
if(
|
33
|
+
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,
|
37
|
+
fn = $el.data('callback'),
|
38
|
+
callback = (typeof fn == 'function') ? fn : window[fn],
|
39
|
+
target = document.getElementById($el.data('target')),
|
40
|
+
wrapper = document.getElementById($el.data('error')),
|
41
|
+
$target = $(target);
|
42
|
+
|
43
|
+
if(change) $.SrBuj.changeDom(method.toUpperCase(),$target,data);
|
44
|
+
if(isModal) wrapper ? $(wrapper).modal('toggle') : $target.modal('toggle');
|
28
45
|
if(callback) callback.apply(this,[e, data]);
|
29
46
|
|
30
47
|
},
|
31
48
|
fail: function(e, data){
|
32
49
|
var $el = $(e.target),
|
33
50
|
error = document.getElementById($el.data('error'));
|
34
|
-
|
51
|
+
if( error )
|
52
|
+
$.SrBuj.changeDom('ERROR', $(error), data.responseText);
|
53
|
+
else
|
54
|
+
throw 'cant find data-error target on element';
|
35
55
|
},
|
36
56
|
bind: function(){
|
37
57
|
$(document).on('ajax:success', this.selector, this.success);
|
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.
|
4
|
+
version: 0.2.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement: &
|
16
|
+
requirement: &70302604334460 !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: *
|
24
|
+
version_requirements: *70302604334460
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: railties
|
27
|
-
requirement: &
|
27
|
+
requirement: &70302604332220 !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: *
|
35
|
+
version_requirements: *70302604332220
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &70302604330220 !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: *
|
46
|
+
version_requirements: *70302604330220
|
47
47
|
description: Better Unobtrusive JavaScript Request in asset pipeline
|
48
48
|
email:
|
49
49
|
- xeroice@gmail.com
|