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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e753707909ca94abaf54db4a9e66512d610d5cfc
|
4
|
+
data.tar.gz: 923bc056c6ef1c9b3bbcac97cf935e6139b6027f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d897bb0d03c8848b4406c846dd26241961549e1c061c846eb90358be7747ab9f962a681710389245151375bca2295e21dec73250a9b2a8e90e954b2804e4967
|
7
|
+
data.tar.gz: 7af741f2362298821b2f83089f87246eeaf902c2020a29fef65ac33330c498cad1ba3a154c6ce5ffcea99823a4ef64f1180a9d99e23665ae1180eefe28aa53da
|
@@ -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
|
-
|
13
|
-
|
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
|
-
|
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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
nested[
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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.
|
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-
|
11
|
+
date: 2013-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|