js: Convert static/js/zform.js to ES6 module.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-02-10 07:51:51 -08:00 committed by Tim Abbott
parent 4513ef8861
commit f66441adb2
6 changed files with 8 additions and 15 deletions

View File

@ -306,7 +306,6 @@
"vdom": false,
"widgetize": false,
"zcommand": false,
"zform": false,
"zxcvbn": false
}
},

View File

@ -8,7 +8,6 @@ const {make_zjquery} = require("../zjsunit/zjquery");
set_global("$", make_zjquery());
const poll_widget = set_global("poll_widget", {});
set_global("zform", {});
set_global("document", "document-stub");
const return_true = () => true;

View File

@ -43,7 +43,6 @@ import "../top_left_corner";
import "../stream_list";
import "../filter";
import "../poll_widget";
import "../zform";
import "../widgetize";
import "../submessage";
import "../fetch_status";

View File

@ -169,4 +169,3 @@ declare let user_status: any;
declare let user_status_ui: any;
declare let widgetize: any;
declare let zcommand: any;
declare let zform: any;

View File

@ -1,6 +1,7 @@
"use strict";
const todo_widget = require("./todo_widget");
const zform = require("./zform");
const widgets = new Map([
["poll", poll_widget],

View File

@ -1,10 +1,8 @@
"use strict";
import render_widgets_zform_choices from "../templates/widgets/zform_choices.hbs";
const render_widgets_zform_choices = require("../templates/widgets/zform_choices.hbs");
import * as schema from "./schema";
const schema = require("./schema");
exports.validate_extra_data = function (data) {
export function validate_extra_data(data) {
function check(data) {
function check_choice_data(data) {
function check_choice_item(field_name, val) {
@ -40,15 +38,15 @@ exports.validate_extra_data = function (data) {
}
return true;
};
}
exports.activate = function (opts) {
export function activate(opts) {
const self = {};
const outer_elem = opts.elem;
const data = opts.extra_data;
if (!exports.validate_extra_data(data)) {
if (!validate_extra_data(data)) {
// callee will log reason we fail
return undefined;
}
@ -102,6 +100,4 @@ exports.activate = function (opts) {
render();
return self;
};
window.zform = exports;
}