PageSourceSearch

https://login.assuran.co.jp/js/common/form/widget/form_widget.js?261006_1

js assuran.co.jp collected 2026-10-06 07:59:22 UTC 4,298 bytes, 119 lines download raw bytes

1
2/**
3 * Created by 慶一郎 on 2016/08/25.
4 */
5
6jQuery.fn.extend({
7    form_widget: function() {
8        $.each($(this), function(e, elm){
9            var $elm = $(elm);
10            var obj = $elm.data('form_widget');
11            if (! obj ) {
12                obj = new Form_widget(elm);
13                $elm.data('form_widget', obj);
14            }
15            obj.init_option_setting();
16        });
17    }
18});
19function Form_widget(div){
20    var self = this;
21    self.$div = $(div);
22
23    /**
24     * ウィジェット変更時にオプションを読み込む
25     */
26    var $widget_form = self.$div.find("> span > select.widget");
27    var $module_form = self.$div.find("> span > select.module");
28    var $options_area = self.$div.find("> .options");
29
30    if(!$widget_form.has_event("change")){
31    }
32    $widget_form.on("change", function(){
33        var $widget = $(this);
34
35        $options_area.html('<i class="fa-refresh fa fa-spin"></i> 読込中');
36
37        var $form = $widget.closest("form");
38        // モジュールを変更
39        var module = $widget.find("> optgroup option:selected").attr("module");
40        $module_form.val(module);
41        var widget = $widget.val();
42        var table = $widget.attr("table");
43        var widget_field = $widget.attr("field");
44
45        var post_data = $form.find("input, select, textarea").serializeArray();
46
47        post_data.push({name: "table", value: table});
48        post_data.push({name: "module", value: module});
49        post_data.push({name: "widget", value: widget});
50        post_data.push({name: "widget_field", value: widget_field});
51
52        $widget.attr("disabled", "disabled");
53        $.post("/adm/load_widget_setting", post_data, function (data) {
54                $options_area.html(data.html);
55                $options_area.attr("widget_class", data.widget_class);
56                $widget.removeAttr("disabled");
57                Sitekitt._init_form($options_area.closest("form"));
58                return false;
59            }, "json");
60        return false;
61    });
62
63    // 初期処理 同一ウィジェット名がある場合に正しいモジュールを選択
64    var module = $module_form.val();
65    var widget = $widget_form.val();
66    var $widget_options = $widget_form.find("> optgroup option");
67    $.each($widget_options, function(i, $widget_option){
68        var $widget_option = $($widget_option);
69        // console.log($widget_option.attr("module") + " " + $widget_option.attr("value"));
70        if($widget_option.attr("module") == module && $widget_option.attr("value") == widget){
71            $widget_option.attr("selected", "selected");
72        } else {
73            $widget_option.removeAttr("selected");
74        }
75    });
76
77    this.$div.find(".options").attr("widget_class", self.$div.find(".widget option:selected").attr("widget_class"));
78
79
80    console.log("form_widget: complete");
81}
82
83Form_widget.prototype.init_option_setting = function(){
84    var $widget_options = this.$div.find(".options");
85    $setting_js = Form_widget.widget_setting[$widget_options.attr("widget_class")];
86    if(typeof($setting_js) == "function"){
87        $setting_js($widget_options);
88    }
89};
90
91Form_widget.widget_setting = {
92    _table_widget: function($setting_div, layout_selector){
93        var table_field = $setting_div.find(".table");
94        if(!table_field.has_event("change")){
95            table_field.change(function(){
96                var table = $(this).val();
97                if(!table){
98                    return;
99                }
100                var $form_layout = $setting_div.find(layout_selector);
101
102                $.post("/adm/get_table_fields", {table: table}, function(data){
103                    var template_description_box = $form_layout.find(".template_description_box");
104                    var $table_fields = template_description_box.find("tbody.table-fields");
105                    $table_fields.after(data);
106                    $table_fields.remove();
107                });
108            });
109            table_field.change();
110        }
111    },
112    Table_detail: function($setting_div){
113        Form_widget.widget_setting._table_widget($setting_div, ".layout");
114    },
115    Table_list: function($setting_div){
116        Form_widget.widget_setting._table_widget($setting_div, ".layout, .list_layout");
117    }
118
119};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.