-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtemplate.js
73 lines (63 loc) · 1.97 KB
/
template.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
AutoForm.addInputType('medium', {
template: 'afMedium',
valueOut: function() {
return this[0].innerHTML;
},
contextAdjust: function(context) {
return context;
}
});
function initializeMediumEditor(options){
var input = this.find('div');
var opts = _.defaults((this.data.atts.mediumOptions || {}), options, {
staticToolbar: true,
stickyToolbar: true
});
var editor = new MediumEditor(input, opts);
// TODO: restore when medium editor fixe deactivate
/*
Meteor.setTimeout((function(_this) {
return function() {
return Tracker.autorun(function() {
var language, mediumOptions;
editor.deactivate();
if (Package['tap:i18n']) {
language = TAPi18n.getLanguage();
}
mediumOptions = _this.data.atts.mediumOptions;
opts = _.defaults(mediumOptions, {
staticToolbar: true,
stickyToolbar: true
});
_.extend(editor.options, mediumOptions);
return editor.activate();
}, 1000);
};
})(this));
*/
}
var helpers = {
atts: function() {
var atts = _.clone(this.atts) || {};
delete atts.mediumOptions;
return _.defaults(atts, {
class: 'medium-editor'
});
}
};
Template.afMedium.rendered = function() {
initializeMediumEditor.call(this);
};
Template.afMedium_materialize.rendered = function() {
if(!this.data.atts.mediumOptions || (this.data.atts.mediumOptions && !this.data.atts.mediumOptions.keepLabel)){
$('label[for=' + this.data.atts.id + ']:not([data-medium-label])').remove();
return initializeMediumEditor.call(this, {
placeholder: {
text: 'Type your text for: ' + AutoForm.getLabelForField(this.data.atts.name)
}
});
}
initializeMediumEditor.call(this);
};
Template.afMedium.helpers(helpers);
Template.afMedium_materialize.helpers(helpers);