MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / bindEvents

Function bindEvents

examples/js/editor.js:196–248  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

194}
195
196function bindEvents() {
197 $("#sidebar ul.third-menu a").click(function (evt) {
198 var target = $(evt.target).parent().parent();
199 var nodeId = evt.target.id;
200 //如果点击的是span节点还要往上一层
201 if (evt.target.localName === "span") {
202 nodeId = target.attr('id');
203 }
204
205 if (nodeId) {
206 //阻止冒泡防止上层事件响应导致修改url hash值
207 evt.preventDefault();
208 window.location.hash = "#" + nodeId;
209 initEditor();
210 evt.stopPropagation();
211 }
212 });
213 var codePane = $("#codePane");
214 var previewPane = $("#previewPane");
215 var expand = !!1;
216 $("#showCodeBtn").click(function () {
217 if (expand) {
218 //编辑器和预览宽度5:7
219 $(this).text(resources.editor.expand);
220 $(this).addClass("fa-arrows-alt");
221 $(this).removeClass(" fa-compress");
222 codePane.show(10, function () {
223 previewPane.removeClass("col-md-12");
224 previewPane.addClass("col-md-7");
225 codePane.addClass("col-md-5");
226 });
227 } else {
228 //预览独占一行
229 $(this).text(resources.editor.source);
230 $(this).addClass(" fa-compress");
231 $(this).removeClass("fa-arrows-alt");
232 codePane.hide(200, function () {
233 codePane.removeClass("col-md-5");
234 previewPane.removeClass("col-md-7");
235 previewPane.addClass("col-md-12");
236 });
237 }
238 expand = !expand;
239 });
240
241 window.addEventListener("hashchange", function () {
242 var hash = window.location.hash;
243 if (hash.indexOf("#") !== -1) {
244 var id = hash.split("#")[1];
245 selectMenu(id);
246 }
247 });
248}

Callers 1

editor.jsFile · 0.70

Calls 6

initEditorFunction · 0.85
selectMenuFunction · 0.85
indexOfMethod · 0.80
$Function · 0.50
showMethod · 0.45
hideMethod · 0.45

Tested by

no test coverage detected