frontendeditor 0.0.8 → 0.0.9
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: a5446052de1900294655723753c99e6ece09468e
|
4
|
+
data.tar.gz: c5f81ef54d549d7c4eb8d67b9bf00e0c428700e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 300b1c21b7cfb4c6e71090c9b461dfc2cfade9892c0ad9ead91752487e313f9f2dd6f1fafb95c565d46e08e0038abd80d6ff70443e692b192218461b0b8ab39d
|
7
|
+
data.tar.gz: 8d754ae6054629f095ce75a7d215baf37f3b3bdbae73089534aa9e62a56eb6e2ea3187d10eec9bc308ee8ca229497a6db90159492b03fd029b7689358e58c268
|
@@ -12,10 +12,19 @@
|
|
12
12
|
};
|
13
13
|
|
14
14
|
Editor.commitAll = function() {
|
15
|
-
var model;
|
16
|
-
|
17
|
-
model
|
18
|
-
|
15
|
+
var attributes, model, objectName, values;
|
16
|
+
objectName = this.el().data('object');
|
17
|
+
model = FrontendEditor.findCurrentOrCreateModel(objectName);
|
18
|
+
values = {
|
19
|
+
id: this.el().data('id')
|
20
|
+
};
|
21
|
+
values[this.el().data('attribute')] = this.el().find('textarea').html();
|
22
|
+
attributes = {
|
23
|
+
values: values,
|
24
|
+
prefix: this.el().data('prefix'),
|
25
|
+
objectName: objectName
|
26
|
+
};
|
27
|
+
return model.setAttributes(attributes);
|
19
28
|
};
|
20
29
|
|
21
30
|
Editor.deactive = function() {
|
@@ -15,11 +15,11 @@
|
|
15
15
|
$('body').prepend(view.render().el);
|
16
16
|
return this.currentModels = new FrontendEditor.Collections.InlineEditor.Items();
|
17
17
|
},
|
18
|
-
|
18
|
+
findCurrentOrCreateModel: function(modelName) {
|
19
19
|
var currentModel;
|
20
20
|
currentModel = this.currentModels[modelName];
|
21
21
|
if (currentModel === void 0) {
|
22
|
-
currentModel = new this.Models.Item(
|
22
|
+
currentModel = new this.Models.Item();
|
23
23
|
this.currentModels.add(currentModel);
|
24
24
|
}
|
25
25
|
return currentModel;
|
@@ -33,12 +33,27 @@
|
|
33
33
|
return Item.__super__.constructor.apply(this, arguments);
|
34
34
|
}
|
35
35
|
|
36
|
-
Item.prototype.
|
37
|
-
|
36
|
+
Item.prototype.setAttributes = function(attributes) {
|
37
|
+
this.setUrlRoot(attributes);
|
38
|
+
return this.setValues(attributes.values);
|
38
39
|
};
|
39
40
|
|
40
|
-
Item.prototype.
|
41
|
-
|
41
|
+
Item.prototype.setValues = function(values) {
|
42
|
+
var key, value, _results;
|
43
|
+
_results = [];
|
44
|
+
for (key in values) {
|
45
|
+
value = values[key];
|
46
|
+
_results.push(this.set(key, value));
|
47
|
+
}
|
48
|
+
return _results;
|
49
|
+
};
|
50
|
+
|
51
|
+
Item.prototype.setUrlRoot = function(attributes) {
|
52
|
+
if (attributes.prefix) {
|
53
|
+
return this.urlRoot = "" + attributes.prefix + "/" + attributes.objectName;
|
54
|
+
} else {
|
55
|
+
return this.urlRoot = "/" + attributes.objectName;
|
56
|
+
}
|
42
57
|
};
|
43
58
|
|
44
59
|
return Item;
|
@@ -71,12 +86,7 @@
|
|
71
86
|
};
|
72
87
|
|
73
88
|
ToolbarView.prototype.saveChanges = function(event) {
|
74
|
-
var prefix;
|
75
89
|
Editor.commitAll();
|
76
|
-
prefix = Editor.el().data('prefix');
|
77
|
-
if (prefix) {
|
78
|
-
FrontendEditor.currentModels.prefix(prefix);
|
79
|
-
}
|
80
90
|
FrontendEditor.currentModels.save();
|
81
91
|
FrontendEditor.currentModels.reset();
|
82
92
|
alert("Enregistrement Effectué");
|
@@ -120,12 +130,6 @@
|
|
120
130
|
});
|
121
131
|
};
|
122
132
|
|
123
|
-
Items.prototype.prefix = function(prefix) {
|
124
|
-
return this.each(function(model) {
|
125
|
-
return model.prefix(prefix);
|
126
|
-
});
|
127
|
-
};
|
128
|
-
|
129
133
|
return Items;
|
130
134
|
|
131
135
|
})(Backbone.Collection);
|