地质所 沉降监测网建设项目
zmk
2024-05-15 9e3afc6d0fa514f986d3fea40fa23124e6fb5070
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*!
 * Goto line dialog plugin for Editor.md
 *
 * @file        goto-line-dialog.js
 * @author      pandao
 * @version     1.2.1
 * @updateTime  2015-06-09
 * {@link       https://github.com/pandao/editor.md}
 * @license     MIT
 */
 
(function() {
 
    var factory = function (exports) {
 
        var $            = jQuery;
        var pluginName   = "goto-line-dialog";
 
        var langs = {
            "zh-cn" : {
                toolbar : {
                    "goto-line" : "跳转到行"
                },
                dialog : {
                    "goto-line" : {
                        title  : "跳转到行",
                        label  : "请输入行号",
                        error  : "错误:"
                    }
                }
            },
            "zh-tw" : {
                toolbar : {
                    "goto-line" : "跳轉到行"
                },
                dialog : {
                    "goto-line" : {
                        title  : "跳轉到行",
                        label  : "請輸入行號",
                        error  : "錯誤:"
                    }
                }
            },
            "en" : {
                toolbar : {
                    "goto-line" : "Goto line"
                },
                dialog : {
                    "goto-line" : {
                        title  : "Goto line",
                        label  : "Enter a line number, range ",
                        error  : "Error: "
                    }
                }
            }
        };
 
        exports.fn.gotoLineDialog = function() {
            var _this       = this;
            var cm          = this.cm;
            var editor      = this.editor;
            var settings    = this.settings;
            var path        = settings.pluginPath + pluginName +"/";
            var classPrefix = this.classPrefix;
            var dialogName  = classPrefix + pluginName, dialog;
 
            $.extend(true, this.lang, langs[this.lang.name]);
            this.setToolbar();
 
            var lang        = this.lang;
            var dialogLang  = lang.dialog["goto-line"];
            var lineCount   = cm.lineCount();
 
            dialogLang.error += dialogLang.label + " 1-" + lineCount;
 
            if (editor.find("." + dialogName).length < 1) 
            {            
                var dialogContent = [
                    "<div class=\"editormd-form\" style=\"padding: 10px 0;\">",
                    "<p style=\"margin: 0;\">" + dialogLang.label + " 1-" + lineCount +"&nbsp;&nbsp;&nbsp;<input type=\"number\" class=\"number-input\" style=\"width: 60px;\" value=\"1\" max=\"" + lineCount + "\" min=\"1\" data-line-number /></p>",
                    "</div>"
                ].join("\n");
 
                dialog = this.createDialog({
                    name       : dialogName,
                    title      : dialogLang.title,
                    width      : 400,
                    height     : 180,
                    mask       : settings.dialogShowMask,
                    drag       : settings.dialogDraggable,
                    content    : dialogContent,
                    lockScreen : settings.dialogLockScreen,
                    maskStyle  : {
                        opacity         : settings.dialogMaskOpacity,
                        backgroundColor : settings.dialogMaskBgColor
                    },
                    buttons    : {
                        enter : [lang.buttons.enter, function() {
                            var line   = parseInt(this.find("[data-line-number]").val());
 
                            if (line < 1 || line > lineCount) {
                                alert(dialogLang.error);
 
                                return false;
                            }
 
                            _this.gotoLine(line);
 
                            this.hide().lockScreen(false).hideMask();
 
                            return false;
                        }],
 
                        cancel : [lang.buttons.cancel, function() {                                   
                            this.hide().lockScreen(false).hideMask();
 
                            return false;
                        }]
                    }
                });
            }
 
            dialog = editor.find("." + dialogName);
 
            this.dialogShowMask(dialog);
            this.dialogLockScreen();
            dialog.show();
        };
 
    };
    
    // CommonJS/Node.js
    if (typeof require === "function" && typeof exports === "object" && typeof module === "object")
    { 
        module.exports = factory;
    }
    else if (typeof define === "function")  // AMD/CMD/Sea.js
    {
        if (define.amd) { // for Require.js
 
            define(["editormd"], function(editormd) {
                factory(editormd);
            });
 
        } else { // for Sea.js
            define(function(require) {
                var editormd = require("./../../editormd");
                factory(editormd);
            });
        }
    } 
    else
    {
        factory(window.editormd);
    }
 
})();