alpaca
Version:
Alpaca provides the easiest and fastest way to generate interactive forms for the web and mobile devices. It runs simply as HTML5 or more elaborately using Bootstrap, jQuery Mobile or jQuery UI. Alpaca uses Handlebars to process JSON schema and provide
39 lines (32 loc) • 991 B
JavaScript
define(function () {
var Placeholder = function (context) {
var self = this;
var $editingArea = context.layoutInfo.editingArea;
var options = context.options;
this.events = {
'summernote.init summernote.change': function () {
self.update();
},
'summernote.codeview.toggled': function () {
self.update();
}
};
this.shouldInitialize = function () {
return !!options.placeholder;
};
this.initialize = function () {
this.$placeholder = $('<div class="note-placeholder">');
this.$placeholder.on('click', function () {
context.invoke('focus');
}).text(options.placeholder).prependTo($editingArea);
};
this.destroy = function () {
this.$placeholder.remove();
};
this.update = function () {
var isShow = !context.invoke('codeview.isActivated') && context.invoke('editor.isEmpty');
this.$placeholder.toggle(isShow);
};
};
return Placeholder;
});