Skip to content

Commit f137cb2

Browse files
committed
Merge branch 'master' of https://github.com/gitana/alpaca
2 parents f56baa1 + 393d7b7 commit f137cb2

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

src/js/fields/advanced/MarkdownField.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,44 @@
3939

4040
},
4141

42+
initMarkdownEditorEvents: function()
43+
{
44+
var self = this;
45+
46+
if (self.editor)
47+
{
48+
self.editor.codemirror.on("change", function(e) {
49+
self.onChange();
50+
self.triggerWithPropagation("change", e);
51+
self.triggerWithPropagation("after_nested_change", e);
52+
});
53+
54+
self.editor.codemirror.on("beforeChange", function(e) {
55+
self.triggerWithPropagation("before_nested_change", e);
56+
});
57+
58+
self.editor.codemirror.on("keyHandled", function(e) {
59+
self.onKeyPress.call(self, e);
60+
self.trigger("keypress", e);
61+
});
62+
63+
self.editor.codemirror.on('blur', function (e) {
64+
self.onBlur();
65+
self.trigger("blur", e);
66+
});
67+
68+
self.editor.codemirror.on("focus", function (e) {
69+
self.onFocus.call(self, e);
70+
self.trigger("focus", e);
71+
});
72+
73+
self.editor.codemirror.on("mousedown", function (e) {
74+
self.onClick.call(self, e);
75+
self.trigger("click", e);
76+
});
77+
}
78+
},
79+
4280
afterRenderControl: function(model, callback)
4381
{
4482
var self = this;
@@ -56,6 +94,8 @@
5694
{
5795
self.editor = new SimpleMDE(self.options.markdown);
5896
}
97+
98+
self.initMarkdownEditorEvents();
5999
});
60100
}
61101

src/js/fields/basic/ArrayField.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,6 +1394,9 @@
13941394

13951395
if (self._validateEqualMaxItems())
13961396
{
1397+
// propagate up with "before_nested_change"
1398+
self.triggerWithPropagation("before_nested_change");
1399+
13971400
self.createItem(index, schema, options, data, function(item) {
13981401

13991402
// register the child
@@ -1417,6 +1420,12 @@
14171420
// trigger update
14181421
self.triggerUpdate();
14191422

1423+
self.onChange.call(self);
1424+
self.triggerWithPropagation("change");
1425+
1426+
// propagate up with "after_nested_change"
1427+
self.triggerWithPropagation("after_nested_change");
1428+
14201429
if (callback)
14211430
{
14221431
Alpaca.nextTick(function() {
@@ -1463,6 +1472,9 @@
14631472

14641473
if (this._validateEqualMinItems() || force)
14651474
{
1475+
// propagate up with "before_nested_change"
1476+
self.triggerWithPropagation("before_nested_change");
1477+
14661478
// unregister the child
14671479
self.unregisterChild(childIndex);
14681480

@@ -1484,6 +1496,12 @@
14841496
// trigger update
14851497
self.triggerUpdate();
14861498

1499+
self.onChange.call(self);
1500+
self.triggerWithPropagation("change");
1501+
1502+
// propagate up with "after_nested_change"
1503+
self.triggerWithPropagation("after_nested_change");
1504+
14871505
if (callback)
14881506
{
14891507
Alpaca.nextTick(function() {
@@ -1558,6 +1576,9 @@
15581576

15591577
var onComplete = function()
15601578
{
1579+
// propagate up with "before_nested_change"
1580+
self.triggerWithPropagation("before_nested_change");
1581+
15611582
var adjustedTargetIndex = targetIndex;
15621583
if (sourceIndex < targetIndex) {
15631584
adjustedTargetIndex--;
@@ -1584,6 +1605,12 @@
15841605
// dispatch event: move
15851606
self.trigger("move");
15861607

1608+
self.onChange.call(self);
1609+
self.triggerWithPropagation("change");
1610+
1611+
// propagate up with "after_nested_change"
1612+
self.triggerWithPropagation("after_nested_change");
1613+
15871614
if (callback)
15881615
{
15891616
Alpaca.nextTick(function() {

0 commit comments

Comments
 (0)