|
@@ -19,4 +19,93 @@ $(function () {
|
|
|
// do something
|
|
|
});
|
|
|
|
|
|
-});
|
|
|
+ slideResize($("#main"), function() {
|
|
|
+ projectObj.mainSpread.refresh();
|
|
|
+ refreshSubSpread();
|
|
|
+ });
|
|
|
+});
|
|
|
+
|
|
|
+/**
|
|
|
+ * 拖动更改div大小
|
|
|
+ *
|
|
|
+ * @param {Object} rootElement - 最顶层div
|
|
|
+ * @param {function} callback - 成功后执行
|
|
|
+ * @return {void}
|
|
|
+ */
|
|
|
+function slideResize(rootElement, callback) {
|
|
|
+ let startY = 0;
|
|
|
+ let drag = false;
|
|
|
+ const element = rootElement.find('.resize-line');
|
|
|
+ const topContentEle = rootElement.find(".top-content");
|
|
|
+ const bottomContentEle = rootElement.find(".bottom-content");
|
|
|
+ let topContentHeight = 0;
|
|
|
+ let bottomContentHeight = 0;
|
|
|
+ let navHeight = 0;
|
|
|
+ let topChangeHeight = 0;
|
|
|
+ let bottomChangeHeight = 0;
|
|
|
+
|
|
|
+ // 鼠标点下时
|
|
|
+ element.mousedown(function(e) {
|
|
|
+ drag = true;
|
|
|
+ startY = e.clientY;
|
|
|
+ // 获取上部分的高度
|
|
|
+ topContentHeight = topContentEle.height();
|
|
|
+ // 获取下部分的高度
|
|
|
+ bottomContentHeight = bottomContentEle.height();
|
|
|
+ // nav高度部分
|
|
|
+ navHeight = bottomContentEle.children('ul.nav').height();
|
|
|
+ });
|
|
|
+
|
|
|
+ // 鼠标移动
|
|
|
+ $("body").mousemove(function(e) {
|
|
|
+ if (drag) {
|
|
|
+ let moveHeight = e.clientY - startY;
|
|
|
+ // 判断拖动范围不能超出
|
|
|
+ topChangeHeight = topContentHeight + moveHeight;
|
|
|
+ topChangeHeight = topChangeHeight < 150 ? 150 : topChangeHeight;
|
|
|
+ topChangeHeight = topChangeHeight > 700 ? 700 : topChangeHeight;
|
|
|
+ topContentEle.children(".main-data-top").height(topChangeHeight);
|
|
|
+
|
|
|
+ bottomChangeHeight = bottomContentHeight - moveHeight;
|
|
|
+ bottomChangeHeight = bottomChangeHeight < 150 ? 150 : bottomChangeHeight;
|
|
|
+ bottomChangeHeight = bottomChangeHeight > 700 ? 700 : bottomChangeHeight;
|
|
|
+ bottomContentEle.children().find(".main-data-bottom").height(bottomChangeHeight - navHeight);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 鼠标弹起
|
|
|
+ $("body").mouseup(function(e) {
|
|
|
+ if (drag) {
|
|
|
+ callback();
|
|
|
+ drag = false;
|
|
|
+ // 存入本地缓存
|
|
|
+ const storage = window.localStorage;
|
|
|
+ if (storage) {
|
|
|
+ const id = rootElement.attr('id');
|
|
|
+ storage.setItem('topHeight:' + id, topChangeHeight);
|
|
|
+ storage.setItem('bottomHeight:' + id, bottomChangeHeight);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 读取设置的高度
|
|
|
+ *
|
|
|
+ * @param {String} tag - 顶层div的id
|
|
|
+ * @param {function} callback - 回调函数
|
|
|
+ * @return {void}
|
|
|
+ */
|
|
|
+function loadSize(tag, callback) {
|
|
|
+ const storage = window.localStorage;
|
|
|
+ if (!storage || tag === '') {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const topHeight = storage.getItem('topHeight:' + tag);
|
|
|
+ const bottomHeight = storage.getItem('bottomHeight:' + tag);
|
|
|
+ const navHeight = $("#"+ tag +" .bottom-content").children('ul.nav').height();
|
|
|
+ $("#"+ tag +" .main-data-top").height(topHeight);
|
|
|
+ $("#"+ tag +" .main-data-bottom").height(bottomHeight - navHeight);
|
|
|
+ $("#"+ tag +" .bottom-content").height(bottomHeight);
|
|
|
+ callback();
|
|
|
+}
|