SrBuj 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/SrBuj/version.rb +5 -0
- data/lib/Srbuj.rb +8 -0
- data/vendor/assets/javascripts/SrBuj.js +46 -0
- metadata +49 -0
data/lib/Srbuj.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
(function($, undefined) {
|
2
|
+
/**
|
3
|
+
* Better Unobtrusive javascript request for Jquery
|
4
|
+
* https://github.com/gagoar/SrBuj
|
5
|
+
*
|
6
|
+
* Requires jQuery 1.7.0 or later.
|
7
|
+
*
|
8
|
+
* Released under the MIT license
|
9
|
+
*
|
10
|
+
*/
|
11
|
+
var SrBuj;
|
12
|
+
$.SrBuj = SrBuj = {
|
13
|
+
selector: '[data-remote][data-target]',
|
14
|
+
|
15
|
+
success: function(e, data){
|
16
|
+
var $el = $(e.target),
|
17
|
+
ismodal = $el.data('modal') || false,
|
18
|
+
replace = $el.data('replace') || false,
|
19
|
+
remove = $el.attr('method') == 'delete' || false,
|
20
|
+
fn = $el.data('callback'),
|
21
|
+
callback = (typeof fn == 'function') ? fn : window[fn],
|
22
|
+
target = document.getElementById($el.data('target')),
|
23
|
+
wrapper = document.getElementById($el.data('error')),
|
24
|
+
$target = $(target);
|
25
|
+
if(remove) $target.remove();
|
26
|
+
else replace ? $target.replaceWith(data) : $target.html(data);
|
27
|
+
if(ismodal) wrapper ? $(wrapper).modal('toggle') : $target.modal('toggle');
|
28
|
+
if(callback) callback.apply(this,[e, data]);
|
29
|
+
|
30
|
+
},
|
31
|
+
fail: function(e, data){
|
32
|
+
var $el = $(e.target),
|
33
|
+
error = document.getElementById($el.data('error'));
|
34
|
+
$(error).html(data.responseText);
|
35
|
+
},
|
36
|
+
bind: function(){
|
37
|
+
$(document).on('ajax:success', this.selector, this.success);
|
38
|
+
$(document).on('ajax:error', this.selector, this.fail);
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
$(function() {
|
43
|
+
$.SrBuj.bind();
|
44
|
+
});
|
45
|
+
|
46
|
+
})( jQuery );
|
metadata
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: SrBuj
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- gagoar
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-03 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description:
|
15
|
+
email:
|
16
|
+
- xeroice@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/SrBuj/version.rb
|
22
|
+
- lib/Srbuj.rb
|
23
|
+
- vendor/assets/javascripts/SrBuj.js
|
24
|
+
homepage: http://github.com/gagoar/SrBuj
|
25
|
+
licenses: []
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ! '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ! '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubyforge_project:
|
44
|
+
rubygems_version: 1.8.11
|
45
|
+
signing_key:
|
46
|
+
specification_version: 3
|
47
|
+
summary: Better Unobtrusive JavaScript Request in asset pipeline
|
48
|
+
test_files: []
|
49
|
+
has_rdoc:
|