|
@@ -82,7 +82,7 @@ yzPage.prototype = {
|
|
|
let $column = this.$colums[this.currentColumn];
|
|
|
let $paragraph = $('<div class="js-paragraph-view"></div>');
|
|
|
$paragraph.css('margin', 0)
|
|
|
- .css('padding', '0 25px')
|
|
|
+ .css('padding', '0 15px')
|
|
|
.css('outline', 'none')
|
|
|
.css('box-sizing', 'border-box')
|
|
|
.css('white-space', 'pre-wrap')
|
|
@@ -196,7 +196,7 @@ yzPage.prototype = {
|
|
|
let $templateb = this._placeholderTemplate();
|
|
|
let left = i * cwidth - 25;
|
|
|
if (i > 0) {
|
|
|
- left += 15
|
|
|
+ left += 10;
|
|
|
$template.css('left', left + 'px').css('top', '-16px');
|
|
|
this.$textElem.append($template);
|
|
|
}
|
|
@@ -422,14 +422,14 @@ yzPage.prototype = {
|
|
|
if ($prevColumn) {
|
|
|
let $paragraphs = $prevColumn.find('.js-paragraph-view');
|
|
|
let lastIndex = $paragraphs.length - 1;
|
|
|
- if (lastIndex) {
|
|
|
+ if (lastIndex >= 0) {
|
|
|
prevIndex = $paragraphs[lastIndex].getAttribute('data-index');
|
|
|
}
|
|
|
}
|
|
|
if ($nextColumn) {
|
|
|
let $nextParagraphs = $nextColumn.find('.js-paragraph-view');
|
|
|
let nextLastIndex = $nextParagraphs.length - 1;
|
|
|
- if (nextLastIndex) {
|
|
|
+ if (nextLastIndex >= 0) {
|
|
|
nextIndex = $nextParagraphs[nextLastIndex].getAttribute('data-index');
|
|
|
}
|
|
|
}
|
|
@@ -702,6 +702,29 @@ yzPage.prototype = {
|
|
|
return firstChild && firstChild.className && firstChild.className.indexOf('js-answer-header') > -1;
|
|
|
},
|
|
|
/**
|
|
|
+ * function 如果该栏没有内容,而下一栏有内容,则移动下一栏内容到该栏
|
|
|
+ * @param {DomElement} $column 需要检测的栏
|
|
|
+ */
|
|
|
+ _moveColumnBack: function ($column, page) {
|
|
|
+ page = page || this;
|
|
|
+ let nextColumn = page._getNextColumn($column, false);
|
|
|
+ if (nextColumn.column) {
|
|
|
+ let $paragraphs = nextColumn.column.find('.js-paragraph-view');
|
|
|
+ let i = $paragraphs.length - 1;
|
|
|
+ if (!$paragraphs[i] || ($paragraphs.length && $paragraphs.length === 1 && page.isHeadParagraph($($paragraphs[0])))) {
|
|
|
+ page._moveColumnBack(nextColumn.column, nextColumn.page);
|
|
|
+ }
|
|
|
+ nextColumn.column.childNodes().forEach(paragraph => {
|
|
|
+ if (!page.isHeadParagraph($(paragraph))) {
|
|
|
+ $column[0].appendChild(paragraph);
|
|
|
+ this.manage._needReTryBack = true;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /**
|
|
|
* function 检测栏是否需要回退
|
|
|
* @param {DomElement} $column 需要检测的栏
|
|
|
*/
|
|
@@ -710,183 +733,184 @@ yzPage.prototype = {
|
|
|
let cSize = $column.getSizeData();
|
|
|
let i = $paragraphs.length - 1;
|
|
|
let $moves = [];
|
|
|
- if (!$paragraphs[i]) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- let $lastParagraph = $($paragraphs[i]);
|
|
|
- let lastSize = $lastParagraph.getSizeData();
|
|
|
- let diff = cSize.bottom - lastSize.bottom;
|
|
|
- if (diff > this.lineHeight) {
|
|
|
- let nextColumn = this._getNextColumn($column, false);
|
|
|
- // 如果有下一页,进行检测
|
|
|
- if (nextColumn.column) {
|
|
|
- let $nextParagraphs = nextColumn.column.find('.js-paragraph-view');
|
|
|
- let j = 0;
|
|
|
- let nextParagraphLength = $nextParagraphs.length || 0;
|
|
|
- while (j < nextParagraphLength) {
|
|
|
- if (j > 0) {
|
|
|
- let prevIndex = j - 1;
|
|
|
- if ($nextParagraphs[prevIndex] && !isEmptyElement($nextParagraphs[prevIndex]) && !this.isHeadParagraph($($nextParagraphs[prevIndex]))) {
|
|
|
- j++;
|
|
|
- continue;
|
|
|
+ if (!$paragraphs[i] || ($paragraphs.length && $paragraphs.length === 1 && this.isHeadParagraph($($paragraphs[0])))) {
|
|
|
+ this._moveColumnBack($column);
|
|
|
+ } else {
|
|
|
+ let $lastParagraph = $($paragraphs[i]);
|
|
|
+ let lastSize = $lastParagraph.getSizeData();
|
|
|
+ let diff = cSize.bottom - lastSize.bottom;
|
|
|
+ if (diff > this.lineHeight) {
|
|
|
+ let nextColumn = this._getNextColumn($column, false);
|
|
|
+ // 如果有下一页,进行检测
|
|
|
+ if (nextColumn.column) {
|
|
|
+ let $nextParagraphs = nextColumn.column.find('.js-paragraph-view');
|
|
|
+ let j = 0;
|
|
|
+ let nextParagraphLength = $nextParagraphs.length || 0;
|
|
|
+ while (j < nextParagraphLength) {
|
|
|
+ if (j > 0) {
|
|
|
+ let prevIndex = j - 1;
|
|
|
+ if ($nextParagraphs[prevIndex] && !isEmptyElement($nextParagraphs[prevIndex]) && !this.isHeadParagraph($($nextParagraphs[prevIndex]))) {
|
|
|
+ j++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- if ($nextParagraphs[j]) {
|
|
|
- let $paragraph = $($nextParagraphs[j]);
|
|
|
- if ($paragraph && !this.isHeadParagraph($paragraph)) {
|
|
|
- let pSize = $paragraph.getSizeData();
|
|
|
- if (pSize.height < diff) {
|
|
|
- $moves.push($paragraph);
|
|
|
- } else {
|
|
|
- let size = {
|
|
|
- diff: diff
|
|
|
+ if ($nextParagraphs[j]) {
|
|
|
+ let $paragraph = $($nextParagraphs[j]);
|
|
|
+ if ($paragraph && !this.isHeadParagraph($paragraph)) {
|
|
|
+ let pSize = $paragraph.getSizeData();
|
|
|
+ if (pSize.height < diff) {
|
|
|
+ $moves.push($paragraph);
|
|
|
+ } else {
|
|
|
+ let size = {
|
|
|
+ diff: diff
|
|
|
+ }
|
|
|
+ this._prevParagraph($moves, $paragraph, size, $lastParagraph);
|
|
|
}
|
|
|
- this._prevParagraph($moves, $paragraph, size, $lastParagraph);
|
|
|
}
|
|
|
}
|
|
|
+ j++;
|
|
|
}
|
|
|
- j++;
|
|
|
- }
|
|
|
- let lastPid = $lastParagraph.attr('data-index');
|
|
|
- let lastBorderItem = $lastParagraph[0].lastChild;
|
|
|
- let lastIsBorder = lastBorderItem && lastBorderItem.className && lastBorderItem.className.indexOf('js-lsiten-border') > -1;
|
|
|
- $moves.forEach($paragraphITem => {
|
|
|
- let currentPid = $paragraphITem.attr('data-index');
|
|
|
- if (lastPid === currentPid) {
|
|
|
- $paragraphITem.childNodes().forEach(item => {
|
|
|
- if (item.nodeType === 3) {
|
|
|
- $paragraph[0].removeChild(item);
|
|
|
- } else {
|
|
|
- let $item = $(item);
|
|
|
- let itemClass = $item.attr('class');
|
|
|
- if (itemClass && itemClass.indexOf('js-lsiten-line') > -1) {
|
|
|
- // 普通行
|
|
|
- $lastParagraph.append($item);
|
|
|
- } else if (itemClass && itemClass.indexOf('js-lsiten-border') > -1) {
|
|
|
- // 框处理
|
|
|
- if (lastIsBorder) {
|
|
|
- let borderId = lastBorderItem.getAttribute('data-id');
|
|
|
- let currentBorderId = $item.attr('data-id');
|
|
|
+ let lastPid = $lastParagraph.attr('data-index');
|
|
|
+ let lastBorderItem = $lastParagraph[0].lastChild;
|
|
|
+ let lastIsBorder = lastBorderItem && lastBorderItem.className && lastBorderItem.className.indexOf('js-lsiten-border') > -1;
|
|
|
+ $moves.forEach($paragraphITem => {
|
|
|
+ let currentPid = $paragraphITem.attr('data-index');
|
|
|
+ if (lastPid === currentPid) {
|
|
|
+ $paragraphITem.childNodes().forEach(item => {
|
|
|
+ if (item.nodeType === 3) {
|
|
|
+ $paragraph[0].removeChild(item);
|
|
|
+ } else {
|
|
|
+ let $item = $(item);
|
|
|
+ let itemClass = $item.attr('class');
|
|
|
+ if (itemClass && itemClass.indexOf('js-lsiten-line') > -1) {
|
|
|
+ // 普通行
|
|
|
+ $lastParagraph.append($item);
|
|
|
+ } else if (itemClass && itemClass.indexOf('js-lsiten-border') > -1) {
|
|
|
+ // 框处理
|
|
|
+ if (lastIsBorder) {
|
|
|
+ let borderId = lastBorderItem.getAttribute('data-id');
|
|
|
+ let currentBorderId = $item.attr('data-id');
|
|
|
|
|
|
- if (currentBorderId === borderId) {
|
|
|
- let borderType = parseInt($item.attr('data-type'));
|
|
|
- if (borderType === 1) {
|
|
|
- // 客观题处理
|
|
|
- $item.childNodes().forEach(objectRow => {
|
|
|
- if (!objectRow.previousSibling) {
|
|
|
- let lastRow = lastBorderItem.lastChild;
|
|
|
- let firstRowId = objectRow.getAttribute('data-id');
|
|
|
- let lastRowId = lastRow.getAttribute('data-id');
|
|
|
- if (firstRowId === lastRowId) {
|
|
|
- let objectColumns = $(objectRow).find('.js-option-column');
|
|
|
- // 以第一栏的为基准
|
|
|
- let objectFirstColumn = objectColumns[0];
|
|
|
- $(objectFirstColumn.firstChild).childNodes().forEach(objectQuestion => {
|
|
|
- if (!objectQuestion.previousSibling) {
|
|
|
- this._mergeObjectRow(objectColumns, lastRow);
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- lastBorderItem.appendChild(objectRow);
|
|
|
+ if (currentBorderId === borderId) {
|
|
|
+ let borderType = parseInt($item.attr('data-type'));
|
|
|
+ if (borderType === 1) {
|
|
|
+ // 客观题处理
|
|
|
+ $item.childNodes().forEach(objectRow => {
|
|
|
+ if (!objectRow.previousSibling) {
|
|
|
+ let lastRow = lastBorderItem.lastChild;
|
|
|
+ let firstRowId = objectRow.getAttribute('data-id');
|
|
|
+ let lastRowId = lastRow.getAttribute('data-id');
|
|
|
+ if (firstRowId === lastRowId) {
|
|
|
+ let objectColumns = $(objectRow).find('.js-option-column');
|
|
|
+ // 以第一栏的为基准
|
|
|
+ let objectFirstColumn = objectColumns[0];
|
|
|
+ $(objectFirstColumn.firstChild).childNodes().forEach(objectQuestion => {
|
|
|
+ if (!objectQuestion.previousSibling) {
|
|
|
+ this._mergeObjectRow(objectColumns, lastRow);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ lastBorderItem.appendChild(objectRow);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- })
|
|
|
- $item.remove();
|
|
|
- this._updateObjectColumnBorder(lastBorderItem);
|
|
|
- this._updateObjectColumnHeightByBorder(lastBorderItem);
|
|
|
- } else if (borderType === 2) {
|
|
|
- $($item[0].firstChild).childNodes().forEach(borderItem => {
|
|
|
- if (borderItem.className) {
|
|
|
- if (borderItem.className.indexOf('js-lsiten-question') > -1) {
|
|
|
- let qustionType = parseInt(borderItem.getAttribute('data-type'));
|
|
|
- let lastQuestionItem = lastBorderItem.lastChild;
|
|
|
- let lastQuestionId = lastQuestionItem.getAttribute('data-id');
|
|
|
- let currentQuestionId = borderItem.getAttribute('data-id');
|
|
|
- if (lastQuestionId && currentQuestionId && currentQuestionId === lastQuestionId) {
|
|
|
- if (qustionType === 3) {
|
|
|
- $(borderItem).childNodes().forEach(subjectItem => {
|
|
|
- lastQuestionItem.appendChild(subjectItem);
|
|
|
- })
|
|
|
-
|
|
|
- } else if (qustionType === 4) {
|
|
|
- $(borderItem).childNodes().forEach(writtingItem => {
|
|
|
- if (writtingItem.className.indexOf('lsiten-title') > -1) {
|
|
|
- let $prevWrittingTitleItem = $(lastQuestionItem).find('.lsiten-title');
|
|
|
- let needMergeItem = true;
|
|
|
- if (!$prevWrittingTitleItem.length) {
|
|
|
- needMergeItem = false;
|
|
|
- $prevWrittingTitleItem = $($prevWrittingTitleItem);
|
|
|
- } else {
|
|
|
- needMergeItem = false;
|
|
|
- $prevWrittingTitleItem = $(writtingItem).clone(false);
|
|
|
- }
|
|
|
- $(writtingItem).childNodes().forEach(writtingTitleItem => {
|
|
|
- $prevWrittingTitleItem[0].appendChild(writtingTitleItem);
|
|
|
- })
|
|
|
-
|
|
|
- if (needMergeItem && !isEmptyElement($prevWrittingTitleItem[0])) {
|
|
|
- lastQuestionItem.appendChild($prevWrittingTitleItem[0]);
|
|
|
- }
|
|
|
- } else if (writtingItem.className.indexOf('lsiten-border-box') > -1) {
|
|
|
- let $prevWrittingRowsItem = $(lastQuestionItem).find('.lsiten-border-box');
|
|
|
- let needMergeItem = true;
|
|
|
- if (!$prevWrittingRowsItem.length) {
|
|
|
- needMergeItem = false;
|
|
|
- $prevWrittingRowsItem = $($prevWrittingRowsItem);
|
|
|
- } else {
|
|
|
- needMergeItem = false;
|
|
|
- $prevWrittingRowsItem = $(writtingItem).clone(false);
|
|
|
- }
|
|
|
- $(writtingItem).childNodes().forEach(writtingRowItem => {
|
|
|
- $prevWrittingRowsItem[0].appendChild(writtingRowItem);
|
|
|
- })
|
|
|
-
|
|
|
- if (needMergeItem && !isEmptyElement($prevWrittingRowsItem[0])) {
|
|
|
- lastQuestionItem.appendChild($prevWrittingRowsItem[0]);
|
|
|
+ })
|
|
|
+ $item.remove();
|
|
|
+ this._updateObjectColumnBorder(lastBorderItem);
|
|
|
+ this._updateObjectColumnHeightByBorder(lastBorderItem);
|
|
|
+ } else if (borderType === 2) {
|
|
|
+ $($item[0].firstChild).childNodes().forEach(borderItem => {
|
|
|
+ if (borderItem.className) {
|
|
|
+ if (borderItem.className.indexOf('js-lsiten-question') > -1) {
|
|
|
+ let qustionType = parseInt(borderItem.getAttribute('data-type'));
|
|
|
+ let lastQuestionItem = lastBorderItem.lastChild;
|
|
|
+ let lastQuestionId = lastQuestionItem.getAttribute('data-id');
|
|
|
+ let currentQuestionId = borderItem.getAttribute('data-id');
|
|
|
+ if (lastQuestionId && currentQuestionId && currentQuestionId === lastQuestionId) {
|
|
|
+ if (qustionType === 3) {
|
|
|
+ $(borderItem).childNodes().forEach(subjectItem => {
|
|
|
+ lastQuestionItem.appendChild(subjectItem);
|
|
|
+ })
|
|
|
+
|
|
|
+ } else if (qustionType === 4) {
|
|
|
+ $(borderItem).childNodes().forEach(writtingItem => {
|
|
|
+ if (writtingItem.className.indexOf('lsiten-title') > -1) {
|
|
|
+ let $prevWrittingTitleItem = $(lastQuestionItem).find('.lsiten-title');
|
|
|
+ let needMergeItem = true;
|
|
|
+ if (!$prevWrittingTitleItem.length) {
|
|
|
+ needMergeItem = false;
|
|
|
+ $prevWrittingTitleItem = $($prevWrittingTitleItem);
|
|
|
+ } else {
|
|
|
+ needMergeItem = false;
|
|
|
+ $prevWrittingTitleItem = $(writtingItem).clone(false);
|
|
|
+ }
|
|
|
+ $(writtingItem).childNodes().forEach(writtingTitleItem => {
|
|
|
+ $prevWrittingTitleItem[0].appendChild(writtingTitleItem);
|
|
|
+ })
|
|
|
+
|
|
|
+ if (needMergeItem && !isEmptyElement($prevWrittingTitleItem[0])) {
|
|
|
+ lastQuestionItem.appendChild($prevWrittingTitleItem[0]);
|
|
|
+ }
|
|
|
+ } else if (writtingItem.className.indexOf('lsiten-border-box') > -1) {
|
|
|
+ let $prevWrittingRowsItem = $(lastQuestionItem).find('.lsiten-border-box');
|
|
|
+ let needMergeItem = true;
|
|
|
+ if (!$prevWrittingRowsItem.length) {
|
|
|
+ needMergeItem = false;
|
|
|
+ $prevWrittingRowsItem = $($prevWrittingRowsItem);
|
|
|
+ } else {
|
|
|
+ needMergeItem = false;
|
|
|
+ $prevWrittingRowsItem = $(writtingItem).clone(false);
|
|
|
+ }
|
|
|
+ $(writtingItem).childNodes().forEach(writtingRowItem => {
|
|
|
+ $prevWrittingRowsItem[0].appendChild(writtingRowItem);
|
|
|
+ })
|
|
|
+
|
|
|
+ if (needMergeItem && !isEmptyElement($prevWrittingRowsItem[0])) {
|
|
|
+ lastQuestionItem.appendChild($prevWrittingRowsItem[0]);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ $(borderItem).remove();
|
|
|
+ }
|
|
|
$(borderItem).remove();
|
|
|
+ } else {
|
|
|
+ lastBorderItem.firstChild.appendChild(borderItem);
|
|
|
}
|
|
|
- $(borderItem).remove();
|
|
|
- } else {
|
|
|
+ } else if (itemClass && itemClass.indexOf('js-lsiten-options-box') > -1) {
|
|
|
+ // 选作题组【回退】
|
|
|
lastBorderItem.firstChild.appendChild(borderItem);
|
|
|
+ } else if (borderItem.className.indexOf('js-lsiten-line') > -1) {
|
|
|
+ lastBorderItem.firstChild.appendChild(borderItem);
|
|
|
+ } else {
|
|
|
+ $(borderItem).remove();
|
|
|
}
|
|
|
- } else if (itemClass && itemClass.indexOf('js-lsiten-options-box') > -1) {
|
|
|
- // 选作题组【回退】
|
|
|
- lastBorderItem.firstChild.appendChild(borderItem);
|
|
|
- } else if (borderItem.className.indexOf('js-lsiten-line') > -1) {
|
|
|
- lastBorderItem.firstChild.appendChild(borderItem);
|
|
|
- } else {
|
|
|
- $(borderItem).remove();
|
|
|
}
|
|
|
- }
|
|
|
- })
|
|
|
- $item.remove();
|
|
|
+ })
|
|
|
+ $item.remove();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $lastParagraph.append($item);
|
|
|
}
|
|
|
} else {
|
|
|
- $lastParagraph.append($item);
|
|
|
+ $lastParagraph.append($item);
|
|
|
}
|
|
|
} else {
|
|
|
- $lastParagraph.append($item);
|
|
|
+ $item.remove();
|
|
|
}
|
|
|
- } else {
|
|
|
- $item.remove();
|
|
|
}
|
|
|
- }
|
|
|
- })
|
|
|
- $paragraphITem.remove();
|
|
|
- } else {
|
|
|
- $paragraphITem.insertAfter($lastParagraph);
|
|
|
- }
|
|
|
- })
|
|
|
- // 跨栏符检测
|
|
|
- this._checkIsCross($($paragraphs[$paragraphs.length - 1]), $column);
|
|
|
- this._checkIsCross($($nextParagraphs[0]), nextColumn.column);
|
|
|
- this._updateCrossColumn($column);
|
|
|
- this._updateCrossColumn(nextColumn.column);
|
|
|
- this._updateObjectColumnHeight(nextColumn.column[0]);
|
|
|
+ })
|
|
|
+ $paragraphITem.remove();
|
|
|
+ } else {
|
|
|
+ $paragraphITem.insertAfter($lastParagraph);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // 跨栏符检测
|
|
|
+ this._checkIsCross($($paragraphs[$paragraphs.length - 1]), $column);
|
|
|
+ this._checkIsCross($($nextParagraphs[0]), nextColumn.column);
|
|
|
+ this._updateCrossColumn($column);
|
|
|
+ this._updateCrossColumn(nextColumn.column);
|
|
|
+ this._updateObjectColumnHeight(nextColumn.column[0]);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -1594,8 +1618,8 @@ yzPage.prototype = {
|
|
|
'A3': '970px'
|
|
|
},
|
|
|
_pagesWidth: {
|
|
|
- 'A4': 653,
|
|
|
- 'A3': 1447
|
|
|
+ 'A4': 713,
|
|
|
+ 'A3': 1507
|
|
|
}
|
|
|
}
|
|
|
|