Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New properties for BootstrapDatePicker #296

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/bootstrapdatepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ function init(Survey, $) {
category: "general",
default: "mm/dd/yyyy",
},
{
// Can take a string
name: "language",
category: "general",
default: "en",
},
{
// Can take a Date or a string
// https://bootstrap-datepicker.readthedocs.io/en/latest/options.html#options
Expand All @@ -69,6 +75,21 @@ function init(Survey, $) {
category: "general",
default: 0,
},
{
name: "startView:number",
category: "general",
default: 0,
},
{
name: "minViewMode:number",
category: "general",
default: 0,
},
{
name: "maxViewMode:number",
category: "general",
default: 4,
},
{
name: "clearBtn:boolean",
category: "general",
Expand Down Expand Up @@ -103,8 +124,12 @@ function init(Survey, $) {
const options = {
enableOnReadonly: false,
format: question.dateFormat,
language: question.language,
todayHighlight: question.todayHighlight,
weekStart: question.weekStart,
startView: question.startView,
minViewMode: question.minViewMode,
maxViewMode: question.maxViewMode,
clearBtn: question.clearBtn,
autoclose: question.autoClose,
daysOfWeekDisabled: question.daysOfWeekDisabled,
Expand Down
57 changes: 51 additions & 6 deletions src/ck-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,63 @@ function init(Survey) {
"<textarea rows='10' cols='80' style: {width:'100%'}></textarea>",
activatedByChanged: function (activatedBy) {
Survey.JsonObject.metaData.addClass("editor", [], null, "empty");
Survey.JsonObject.metaData.addProperty("editor", {
name: "height",
default: 300,
category: "general",
});
Survey.JsonObject.metaData.addProperties("editor",[
{
name: "height",
default: 300,
category: "general",
},
{
name: "language",
default: "en",
category: "general"
},
{
name: "defaultLanguage",
default: "en",
category: "general"
}
]);
},
afterRender: function (question, el) {
var name = question.inputId;
CKEDITOR.editorConfig = function (config) {
config.language = "es";
config.defaultLanguage = question.language;
config.language = question.language;
config.height = question.height;
config.toolbarCanCollapse = true;

// Define changes to default configuration here.
// For complete reference see:
// https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html

// The toolbar groups arrangement, optimized for two toolbar rows.
config.toolbarGroups = [
{ name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
// { name: 'editing', groups: [ 'find', 'selection', 'spellchecker' ] },
// { name: 'links' },
// { name: 'insert' },
// { name: 'forms' },
{ name: 'tools' },
// { name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
// { name: 'others' },
'/',
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ] },
{ name: 'styles' },
{ name: 'colors' }
// { name: 'about' }
];

// Remove some buttons provided by the standard plugins, which are
// not needed in the Standard(s) toolbar.
config.removeButtons = 'Underline,Subscript,Superscript';

// Set the most common block elements.
config.format_tags = 'p;h1;h2;h3;pre';

// Simplify the dialog windows.
config.removeDialogTabs = 'image:advanced;link:advanced';
};
el.name = name;

Expand Down
6 changes: 3 additions & 3 deletions src/icheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ function escValue(val) {
function init(Survey, $) {
$ = $ || window.$;
var widget = {
className: "iradio_square-blue",
checkboxClass: "iradio_square-blue",
radioClass: "iradio_square-blue",
className: "iradio_flat-green",
checkboxClass: "icheckbox_flat-green",
radioClass: "iradio_flat-green",
name: "icheck",
widgetIsLoaded: function () {
return typeof $ == "function" && !!$.fn.iCheck;
Expand Down
147 changes: 147 additions & 0 deletions src/summernote.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
function init(Survey) {
const iconId = "icon-editor";
Survey.SvgRegistry && Survey.SvgRegistry.registerIconFromSvg(iconId, require('svg-inline-loader!./images/editor.svg'), "");
var widget = {
name: "summernote",
title: "Editor",
iconName: iconId,
widgetIsLoaded: function () {
return typeof $ == "function" && !!$.fn.summernote;
},
isFit: function (question) {
return question.getType() === "summernote";
},
htmlTemplate:
'<textarea class="form-control widget-summernote" rows="10" cols="80" style: {width:"100%"}></textarea>',
activatedByChanged: function (activatedBy) {
Survey.JsonObject.metaData.addClass("summernote", [], null, "text");
Survey.JsonObject.metaData.addProperties("summernote",[
// {
// name: "height",
// default: 300,
// category: "general",
// },
{
name: "lang",
default: "en",
category: "general"
},
{
name: "placeholder",
default: "",
category: "general"
},
{
name: "toolbar",
default: [
['style', ['bold', 'italic', 'underline', 'clear']],
['para', ['ul', 'ol', 'paragraph']]
],
category:"general"
},
{
name:"hint",
default: {},
category:"general"
},
{
name: "disableDragAndDrop:boolean",
default: true,
category:"general"
},
{
name: "shortcuts:boolean",
default: false,
category:"general"
},
{
name: "codeviewFilter:boolean",
default: true,
category:"general"
},
{
name: "codeviewIFrameFilter:boolean",
default: true,
category:"general"
}
]);
},
afterRender: function (question, el) {
var $el = $(el).is('.widget-summernote')
? $(el)
: $(el).find('.widget-summernote');
const options = {
lang: question.language,
placeholder: question.placeholder,
toolbar: [['style', ['bold', 'italic', 'underline', 'clear']],
['para', ['ul', 'ol', 'paragraph']]]
};
const summernoteWidget = $el.summernote(options).on("summernote.change", function (we, contents, $editable) {
if (question.value != contents) {
question.value = contents;
}
});

question.valueChangedCallback = function () {
var oldValue = summernoteWidget.summernote('code');
if(oldValue != question.value)
summernoteWidget.summernote(
"code",
!!question.value ? question.value : ""
);
};
question.valueChangedCallback();
question.readOnlyChangedCallback = function () {
if (question.isReadOnly) {
summernoteWidget.summernote('disable');
} else {
summernoteWidget.summernote('enable');
}
};
question.readOnlyChangedCallback();

},
willUnmount: function (question, el) {
var $el = $(el).is(".widget-summernote")
? $(el)
: $(el).find(".widget-summernote");
$el.summernote("destroy");
question.valueChangedCallback = null;
question.readOnlyChangedCallback = null;
},
pdfQuestionType: "text",
// pdfRender: function (survey, options) {
// if (options.question.getType() === "editor") {
// const loc = new Survey.LocalizableString(survey, true);
// loc.text = options.question.value || options.question.defaultValue;
// options.question["locHtml"] = loc;
// if (
// options.question.renderAs === "standard" ||
// options.question.renderAs === "image"
// ) {
// options.question["renderAs"] = options.question.renderAs;
// } else options.question["renderAs"] = "auto";
// const flatHtml = options.repository.create(
// survey,
// options.question,
// options.controller,
// "html"
// );
// return new Promise(function (resolve) {
// flatHtml.generateFlats(options.point).then(function (htmlBricks) {
// options.bricks = htmlBricks;
// resolve();
// });
// });
// }
// },
};

Survey.CustomWidgetCollection.Instance.addCustomWidget(widget, "customtype");
}

if (typeof Survey !== "undefined") {
init(Survey);
}

export default init;
1 change: 1 addition & 0 deletions src/surveyjs-widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ export { default as bootstrapslider } from "./bootstrap-slider.js";
export { default as microphone } from "./microphone.js";
export { default as emotionsratings } from "./emotionsratings.js";
export { default as bootstrapdatepicker } from "./bootstrapdatepicker.js";
export { default as summernote } from "./summernote.js";
5 changes: 3 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ var widgets = [
"easy-autocomplete",
"pretty-checkbox",
"bootstrap-slider",
"microphone",
"emotionsratings"
// "microphone",
"emotionsratings",
"summernote"
];

var dependencies = {
Expand Down