x-editable-rails 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f39c1375f2107089642f9db987497129da954a8
4
- data.tar.gz: 8327e2d422935b22a68e3abb880e62c7a64684ad
3
+ metadata.gz: e753707909ca94abaf54db4a9e66512d610d5cfc
4
+ data.tar.gz: 923bc056c6ef1c9b3bbcac97cf935e6139b6027f
5
5
  SHA512:
6
- metadata.gz: 8443ec604c47018fac79f45674e3314a8d0579a9aadb8d4c7505d65147f645fb6b3919de927945753b4edf56837541ec9c52829628b29f3a672558b35fbe6cbc
7
- data.tar.gz: 421750f2132b0eebeac8cbd5530de78826abad6e4744f284176d2fdbba84d91997f5f060d2dcf41394db79ab4388d75d0f11ade1d5272d86a57431964d3a0873
6
+ metadata.gz: 5d897bb0d03c8848b4406c846dd26241961549e1c061c846eb90358be7747ab9f962a681710389245151375bca2295e21dec73250a9b2a8e90e954b2804e4967
7
+ data.tar.gz: 7af741f2362298821b2f83089f87246eeaf902c2020a29fef65ac33330c498cad1ba3a154c6ce5ffcea99823a4ef64f1180a9d99e23665ae1180eefe28aa53da
@@ -1,7 +1,7 @@
1
1
  module X
2
2
  module Editable
3
3
  module Rails
4
- VERSION = "1.2.0"
4
+ VERSION = "1.2.1"
5
5
  end
6
6
  end
7
7
  end
@@ -9,8 +9,17 @@ module X
9
9
  model = object.class.to_s.downcase
10
10
  model_param = model.gsub('::', '_')
11
11
  model_name = model.gsub('::', '/')
12
- content_tag :a, href: "#", class: "editable", data: { type: 'text', model: model_param, name: method, url: data_url,
13
- nested: (options[:nested] if options[:nested]), nid: (options[:nid] if options[:nid]), 'original-title' => t("activerecord.attributes.#{model_name}#{"/#{options[:nested].singularize}" if options[:nested]}.#{method}") } do
12
+ klass = options[:nested] ? object.class.const_get(options[:nested].singularize.capitalize) : object.class
13
+ content_tag :a, href: "#", class: "editable",
14
+ data: {
15
+ type: 'text',
16
+ model: model_param,
17
+ name: method,
18
+ url: data_url,
19
+ nested: (options[:nested] if options[:nested]),
20
+ nid: (options[:nid] if options[:nid]),
21
+ :'original-title' => klass.human_attribute_name(method)
22
+ } do
14
23
  object.send(method)
15
24
  end
16
25
  else
@@ -1,34 +1,37 @@
1
1
  jQuery ($) ->
2
2
  EditableForm = $.fn.editableform.Constructor
3
3
  EditableForm.prototype.saveWithUrlHook = (value) ->
4
- url = @options.url
4
+ originalUrl = @options.url
5
5
  model = @options.model
6
6
  nestedName = @options.nested
7
7
  nestedId = @options.nid
8
8
  nestedLocale = @options.locale
9
9
  @options.url = (params) =>
10
- myName = params.name
11
- myValue = params.value.replace(/(\r\n|\n|\r)/gm,"<br/>")
12
- obj = {}
13
- if nestedName
14
- nested = {}
15
- nested[myName] = myValue
16
- nested['id'] = nestedId
17
- if nestedLocale
18
- nested['locale'] = nestedLocale
19
- obj[nestedName + '_attributes'] = nested
20
- else
21
- obj[myName] = myValue
22
- params[model] = obj
23
- delete params.name
24
- delete params.value
25
- delete params.pk
26
- $.ajax($.extend({
27
- url : url
28
- data : params
29
- type : 'PUT'
30
- dataType: 'json'
31
- }, @options.ajaxOptions))
10
+ if typeof originalUrl == 'function'
11
+ originalUrl.call(@options.scope, params)
12
+ else if originalUrl? && @options.send != 'never'
13
+ myName = params.name
14
+ myValue = params.value.replace(/(\r\n|\n|\r)/gm,"<br/>")
15
+ obj = {}
16
+ if nestedName
17
+ nested = {}
18
+ nested[myName] = myValue
19
+ nested['id'] = nestedId
20
+ if nestedLocale
21
+ nested['locale'] = nestedLocale
22
+ obj[nestedName + '_attributes'] = nested
23
+ else
24
+ obj[myName] = myValue
25
+ params[model] = obj
26
+ delete params.name
27
+ delete params.value
28
+ delete params.pk
29
+ $.ajax($.extend({
30
+ url : originalUrl
31
+ data : params
32
+ type : 'PUT'
33
+ dataType: 'json'
34
+ }, @options.ajaxOptions))
32
35
  @saveWithoutUrlHook(value)
33
36
  EditableForm.prototype.saveWithoutUrlHook = EditableForm.prototype.save
34
37
  EditableForm.prototype.save = EditableForm.prototype.saveWithUrlHook
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: x-editable-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jiri Kolarik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-22 00:00:00.000000000 Z
11
+ date: 2013-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler