SrBuj 0.7.0 → 0.8.1

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTVjMWVlMWVhNWU4NzIzMmU4Y2NjZjMyOTc3ODJmYTk4YzQxY2JlOQ==
4
+ NDZlZTQ2MmUzZWY1MTIzMzU4MGU5YWU5MTI4Mjc3YWZlNDFlZWQ3YQ==
5
5
  data.tar.gz: !binary |-
6
- ODQxYThjYWY1NTU4NzUzNzJlZTNmNjVmY2YzNGI1OWNkNjcyNDNjNQ==
6
+ YjQ1Y2Q2MzZhN2FiNDdiM2U4MGQ5YWY0ZDVhMDI0N2QwNDg5MTY2ZQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZjdhYmE4NTkxZWY0ZTVmNzEyNWYzZGZjMzMxZmIzNTFiMGI5M2M4NmUzZjQx
10
- MTY2OGY1M2M3ZTEyNzc0NTYyZmMzOTNkYWIxODEwYTA1N2Q0ZTNhNTM5OWFj
11
- ODE4YzFlN2Y1NDE3ODkxMDIyODBkYWRhMjM3NzIyYjE4MDc2YzM=
9
+ M2FmYzE3ZmQwYmEzNGRiMjNmMzYwOWJlZTQ2ZDA2ZjMwNDFhMWM5Yjc0ZDIx
10
+ NzJjNzVlNDIyMGRiMGM5MWY3YjZmN2ZmYmQ2NmNjNzVjYzZhYWFiOWNmZmJl
11
+ NTQ4MTNkNzY4MTFlOTBiZGNkNGUyYWJkNDU1N2QxYWUxMzk5ZjM=
12
12
  data.tar.gz: !binary |-
13
- MDA2ZTFmZTU4ZGUzZWUyYmNmNjZiZGU5NjRmZjEwYzhjYmFhZGVhOTg2Nzhh
14
- MmMzM2UxYTUwNjhhNzA3Y2Y3OWEwNmYxODBmODNmY2ZhMjNmYzM5MTFiOGQx
15
- YTg2NDdmM2FjZGZkYzkxZGI3YTVlNTM4ZWQ0Yjk4ZDQ1YTI3Y2E=
13
+ ZmNjMjE3NmRiNzg4NTRlZmNiNDIwOTljMDRmMDY1MDk4MTE3ODE3MDA4YzZm
14
+ MDdhOTA5MzUxOTI4Mjc2MTJiYzg3ZDcyMDMxMjJkY2JjNmQ2NDY4MzRlMmM5
15
+ MDlkYTgxNGFiMmIyZThjMTMxYTY1NGE0NzYwMGFkZjIwNzYwNmY=
data/lib/SrBuj/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module SrBuj
2
- VERSION = '0.7.0'
2
+ VERSION = '0.8.1'
3
3
  end
@@ -19,7 +19,7 @@
19
19
  };
20
20
  var SrBuj;
21
21
  $.SrBuj = SrBuj = {
22
- version: '0.7.0',
22
+ version: '0.8.1',
23
23
  selector: '[data-remote][data-target]',
24
24
  defaults: {
25
25
  '$el': undefined,
@@ -32,6 +32,7 @@
32
32
  custom: false,
33
33
  replace: false,
34
34
  callback: false,
35
+ remove: false,
35
36
  url: undefined,
36
37
  push: false,
37
38
  jqueryselector: false
@@ -108,7 +109,8 @@
108
109
  'custom': $el.data('custom'),
109
110
  'replace': $el.data('replace'),
110
111
  'url': $.SrBuj.getUrl($el),
111
- 'push': $el.data('push')
112
+ 'push': $el.data('push'),
113
+ 'remove': $el.is('[data-srbuj]')
112
114
  };
113
115
  user_options = user_options || {};
114
116
  for (var attr in this.defaults) {
@@ -145,10 +147,12 @@
145
147
  callback.apply(this, [e, data, status]);
146
148
  }
147
149
  }
150
+ if (options.remove){
151
+ this.remove();
152
+ }
148
153
 
149
154
  }
150
155
  },
151
-
152
156
  fail: function (e, data, status, user_options) {
153
157
  e.stopPropagation();
154
158
  var $el = $(e.target).present(),
@@ -166,6 +170,40 @@
166
170
  selector = selector || this.selector;
167
171
  $(document).on('ajax:success', selector, this.success);
168
172
  $(document).on('ajax:error', selector, this.fail);
173
+ },
174
+ Util: {
175
+ link: function (user_options){
176
+ /*This function will create a link with options, trigger it and remove the link afterwards
177
+ * user_options must be a hash (Obj) with key: value without the data word
178
+ * if the hash contain more keys, these will be integrated too as data-key form. Example:
179
+ * { target: 'modal', error: 'modal', modal: true, href: '/admin/request'}
180
+ * this will become:
181
+ * <a href: '/admin/request' data-remote data-srbuj data-target= 'modal' data-modal data-error= 'modal' ></a>
182
+ * note: we add an extra attribute, in order to debug ([data-srbuj]) and recover the link that has been made from the dom that
183
+ * if the attribute [data-srbuj] its present in any element that is handled by SrBuj response it will be removed form dom after complete the process
184
+ * the white spaces will be removed from keys.
185
+ */
186
+ var user_options = user_options || {};
187
+ $.extend(user_options, {remote: true, srbuj: true});
188
+ if(user_options.target && user_options.href){
189
+ var _srbujLink = document.createElement('a');
190
+ _srbujLink.id = '_srbujLink';
191
+ _srbujLink.href = user_options.href;
192
+ delete user_options.href;
193
+ for (var attr in user_options) {
194
+ if (user_options.hasOwnProperty(attr)) {
195
+ var key = ['data', attr.replace(/\s/g, '')].join('-'),
196
+ value = user_options[attr];
197
+ if( value === true ){ value = '' }
198
+ _srbujLink.setAttribute(key, value);
199
+ }
200
+ }
201
+ $('body').append(_srbujLink);
202
+ $(_srbujLink).trigger('click');
203
+ }else{
204
+ throw 'not enough options given. Maybe target or href not present?'
205
+ }
206
+ }
169
207
  }
170
208
  };
171
209
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: SrBuj
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - gagoar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-21 00:00:00.000000000 Z
11
+ date: 2013-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -103,4 +103,3 @@ signing_key:
103
103
  specification_version: 4
104
104
  summary: http://github.com/gagoar/SrBuj/
105
105
  test_files: []
106
- has_rdoc: