UNPKG

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

46 lines (40 loc) 1.28 kB
define([ 'jquery', 'summernote/base/core/list', 'summernote/base/Context' ], function ($, list, Context) { $.fn.extend({ /** * Summernote API * * @param {Object|String} * @return {this} */ summernote: function () { var type = $.type(list.head(arguments)); var isExternalAPICalled = type === 'string'; var hasInitOptions = type === 'object'; var options = hasInitOptions ? list.head(arguments) : {}; options = $.extend({}, $.summernote.options, options); options.langInfo = $.extend(true, {}, $.summernote.lang['en-US'], $.summernote.lang[options.lang]); this.each(function (idx, note) { var $note = $(note); if (!$note.data('summernote')) { var context = new Context($note, options); $note.data('summernote', context); $note.data('summernote').triggerEvent('init', context.layoutInfo); } }); var $note = this.first(); if ($note.length) { var context = $note.data('summernote'); if (isExternalAPICalled) { return context.invoke.apply(context, list.from(arguments)); } else if (options.focus) { context.invoke('editor.focus'); } } return this; } }); });