wide/static/js/bottomGroup.js

96 lines
3.0 KiB
JavaScript
Raw Normal View History

2015-01-01 05:06:33 +03:00
/*
2019-05-17 06:28:50 +03:00
* Copyright (c) 2014-present, b3log.org
2015-01-01 05:06:33 +03:00
*
2014-11-12 18:13:14 +03:00
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
2015-01-01 05:06:33 +03:00
*
2018-03-12 07:28:33 +03:00
* https://www.apache.org/licenses/LICENSE-2.0
2015-01-01 05:06:33 +03:00
*
2014-11-12 18:13:14 +03:00
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
2014-12-03 11:40:45 +03:00
*/
2014-11-12 18:13:14 +03:00
2015-12-08 18:48:16 +03:00
/*
* @file bottomGroup.js
*
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.1.1, Mar 15, 2017
2015-12-08 18:48:16 +03:00
*/
2014-11-06 06:58:55 +03:00
var bottomGroup = {
tabs: undefined,
searchTab: undefined,
init: function () {
this._initTabs();
2014-11-06 09:41:46 +03:00
this._initFrame();
2014-12-03 11:40:45 +03:00
2014-11-06 10:04:33 +03:00
$('.bottom-window-group .output').click(function () {
2014-12-03 11:40:45 +03:00
$(this).focus();
});
2014-12-03 12:25:06 +03:00
$('.bottom-window-group .output').on('click', '.path', function (event) {
2014-12-03 12:03:09 +03:00
var $path = $(this),
tId = tree.getTIdByPath($path.data("path"));
tree.openFile(tree.fileTree.getNodeByTId(tId),
CodeMirror.Pos($path.data("line") - 1, $path.data("column") - 1));
2014-12-03 12:25:06 +03:00
event.preventDefault();
return false;
2014-11-06 10:04:33 +03:00
});
2014-11-06 09:41:46 +03:00
},
_initFrame: function () {
2015-01-04 06:21:44 +03:00
$(".bottom-window-group .output").parent().mouseup(function (event) {
2014-11-06 09:41:46 +03:00
event.stopPropagation();
if (event.button === 0) { // 左键
$(".bottom-window-group .frame").hide();
2014-12-23 06:32:05 +03:00
return;
2014-11-06 09:41:46 +03:00
}
// event.button === 2 右键
2014-12-23 06:32:05 +03:00
var left = event.screenX,
$it = $(this);
2014-11-06 09:41:46 +03:00
if ($(".side").css("left") === "auto" || $(".side").css("left") === "0px") {
left = event.screenX - $(".side").width();
}
$(".bottom-window-group .frame").show().css({
"left": left + "px",
2014-12-23 06:32:05 +03:00
"top": (event.offsetY + event.target.offsetTop - $it.scrollTop() - 10) + "px"
2014-11-06 09:41:46 +03:00
});
2014-12-23 06:32:05 +03:00
return;
2014-11-06 09:41:46 +03:00
});
},
2014-11-06 10:04:33 +03:00
clear: function (id) {
$('.bottom-window-group .' + id + ' > div').text('');
2014-11-06 06:58:55 +03:00
},
2014-11-06 10:04:33 +03:00
resetOutput: function () {
this.clear('output');
2014-11-06 06:58:55 +03:00
bottomGroup.tabs.setCurrent("output");
windows.flowBottom();
},
_initTabs: function () {
this.tabs = new Tabs({
id: ".bottom-window-group",
clickAfter: function (id) {
this._$tabsPanel.find("." + id).focus();
}
});
},
fillOutput: function (data) {
var $output = $('.bottom-window-group .output');
2015-01-14 06:13:27 +03:00
data = data.replace(/\r/g, '');
2014-12-25 18:59:32 +03:00
data = data.replace(/\n/g, '<br/>');
2015-01-14 06:13:27 +03:00
2014-12-25 18:59:32 +03:00
if (-1 !== data.indexOf("<br/>")) {
data = Autolinker.link(data);
}
2015-01-14 06:13:27 +03:00
2014-12-25 18:59:32 +03:00
$output.find("div").html(data);
2014-11-06 06:58:55 +03:00
$output.parent().scrollTop($output[0].scrollHeight);
}
2014-12-25 18:59:32 +03:00
};