better_frame 0.3.1 → 0.3.2

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: efce9ae5a3ae64f1e9b2d780d4bd22dc23f88e7f
4
- data.tar.gz: b34de21b687948a9f412f1902ce5783dfb947979
3
+ metadata.gz: 13d2177a2085fbc59122813f41ce7eea8d248e94
4
+ data.tar.gz: ac8ea62d957ecb4f3e42029d2e2942192b9ade9c
5
5
  SHA512:
6
- metadata.gz: fd06295a1252fa78dafee10440aded01067ecf9d63f616051501c55fd3c1e0d9bebbc027e0ac8a1d7d97164ff9bafc9f6f37e4b1345a5c35846c2ab65571c1f2
7
- data.tar.gz: 3934267675fd7b82c4e0ee57cf9e3b5ec877be8da9e3b5ea6be36639f005401c15cb3cf8f114154d92412740899c0338ab2ddf9142017da32c87929a81ae73f2
6
+ metadata.gz: aec1bf79d43e0bdcde5f87d79aa3f0bec953da5aef2ec4b9d7f4100d8a1de37fdcf644ee9d85960355d20eae5ed64ba5af6add43e22933511020ab452811c31d
7
+ data.tar.gz: 1254e457555eff500ce75aeb4fc177d28a7d2a2cb098729906a186313402198ac8aaafc5c88fdbb09e8d9f32ae8774b9bcb66f0d902328de8bfed488f1ae6ee0
@@ -35,7 +35,7 @@
35
35
  fill(url).then(storeURLInHistory);
36
36
  }
37
37
 
38
- $(document).on("click", "#app-content a:not([target=\"_blank\"]):not([data-ignore-better-frame])", handleLinks);
38
+ $(document).on("click", "#app-content a:not([target=\"_blank\"]):not([data-ignore-better-frame]):not([data-method])", handleLinks);
39
39
 
40
40
  $(document).on("ajax:success", "#app-content form", function(e, data, status, xhr) {
41
41
  fillContent(data);
@@ -99,7 +99,7 @@
99
99
 
100
100
  // Default way to get an element's href. May be overridden at $.rails.href.
101
101
  href: function(element) {
102
- return element[0].href;
102
+ return element[0].getAttribute("href");
103
103
  },
104
104
 
105
105
  // Checks "data-remote" if true to handle the request through a XHR request.
@@ -117,14 +117,7 @@
117
117
 
118
118
  if (element.is('form')) {
119
119
  method = element.data('ujs:submit-button-formmethod') || element.attr('method');
120
- var url_or_path = element.data('ujs:submit-button-formaction') || element.attr('action');
121
- var railsURL = $("#app-content").data("railsurl");
122
- // if url_or_path starts with a slash assume it's a path
123
- if (url_or_path.match(/^\//) && railsURL !== undefined) {
124
- url = railsURL + url_or_path;
125
- } else {
126
- url = url_or_path;
127
- }
120
+ url = element.data('ujs:submit-button-formaction') || element.attr('action');
128
121
  data = $(element[0]).serializeArray();
129
122
  // memoized value from clicked submit button
130
123
  var button = element.data('ujs:submit-button');
@@ -149,6 +142,13 @@
149
142
  url = rails.href(element);
150
143
  data = element.data('params') || null;
151
144
  }
145
+ var railsURL = $("#app-content").data("railsurl");
146
+ // if url starts with a slash assume it's a path
147
+ if (url.match(/^\//) && railsURL !== undefined) {
148
+ url = railsURL + url;
149
+ } else {
150
+ url = url;
151
+ }
152
152
 
153
153
  options = {
154
154
  type: method || 'GET', data: data, dataType: dataType,
@@ -229,12 +229,13 @@
229
229
  // <a href="/users/5" data-method="delete" rel="nofollow" data-confirm="Are you sure?">Delete</a>
230
230
  handleMethod: function(link) {
231
231
  var href = rails.href(link),
232
- method = link.data('method'),
233
- target = link.attr('target'),
234
- csrfToken = rails.csrfToken(),
235
- csrfParam = rails.csrfParam(),
236
- form = $('<form method="post" action="' + href + '"></form>'),
237
- metadataInput = '<input name="_method" value="' + method + '" type="hidden" />';
232
+ method = link.data('method'),
233
+ target = link.attr('target'),
234
+ csrfToken = rails.csrfToken(),
235
+ csrfParam = rails.csrfParam(),
236
+ remote = rails.isRemote(link),
237
+ form = $('<form method="post" action="' + href + '" data-with-credentials="true" data-remote="true"></form>'),
238
+ metadataInput = '<input name="_method" value="' + method + '" type="hidden" />';
238
239
 
239
240
  if (csrfParam !== undefined && csrfToken !== undefined && !rails.isCrossDomain(href)) {
240
241
  metadataInput += '<input name="' + csrfParam + '" value="' + csrfToken + '" type="hidden" />';
@@ -242,7 +243,7 @@
242
243
 
243
244
  if (target) { form.attr('target', target); }
244
245
 
245
- form.hide().append(metadataInput).appendTo('body');
246
+ form.hide().append(metadataInput).appendTo('#app-content');
246
247
  form.submit();
247
248
  },
248
249
 
@@ -1,3 +1,3 @@
1
1
  module BetterFrame
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: better_frame
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yves Siegrist
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-22 00:00:00.000000000 Z
11
+ date: 2016-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler