Skip to content

Commit 491930c

Browse files
committed
2.0
1 parent bbf8a8c commit 491930c

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

resources/assets/component.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,6 @@ class ComponentCascadeDot {
551551
class ComponentLine {
552552
constructor(name, columns, data, options = {}) {
553553
this.DOM = document.getElementById(name);
554-
this.NAME = name;
555554
this.COLUMNS = columns;
556555
this.DATA = data;
557556
this.OPTIONS = Object.assign({
@@ -579,7 +578,7 @@ class ComponentLine {
579578
let foot = head;
580579
let columns = this.COLUMNS;
581580
for (let column in columns) {
582-
if (columns[column].type == 'hidden') {
581+
if (columns[column].type === 'hidden') {
583582
continue;
584583
}
585584
if (columns[column].style) {
@@ -603,13 +602,13 @@ class ComponentLine {
603602
var tbody = document.createElement('tbody');
604603
var object = this;
605604
var columns = this.COLUMNS;
606-
if (Array.isArray(this.DATA) == false) return;
605+
if (Array.isArray(this.DATA) === false) return;
607606
this.DATA.forEach(function (value, key) {
608607
let tr = document.createElement('tr');
609608
tr.setAttribute('sortable-item', 'sortable-item');
610609
let record = {};
611610
for (let column in columns) {
612-
if (columns[column].type == 'hidden') {
611+
if (columns[column].type === 'hidden') {
613612
if (value[column]) {
614613
record[column] = value[column];
615614
}
@@ -779,7 +778,7 @@ class ComponentPlane {
779778
}
780779

781780
makeModal() {
782-
let html = `<div id="dlp-plane" class="dlp-plane-gauze"><div class="dlp-plane" style="width: ${window.innerWidth * this.OPTIONS.W}px;"><div class="dlp plane-header"></div><div class="plane-body dlp-scroll" style="max-height:${window.innerHeight * this.OPTIONS.H}px; min-height: ${window.innerHeight * this.OPTIONS.H / 2}px;"></div></div></div>`;
781+
let html = `<div id="dlp-plane" class="dlp-plane-gauze"><div class="dlp-plane" style="width: ${window.innerWidth * this.OPTIONS.W}px;"><div class="dlp plane-header"></div><div class="plane-body dlp-scroll" style="max-height:${window.innerHeight * this.OPTIONS.H}px;min-height:${window.innerHeight * this.OPTIONS.H / 2}px;"></div></div></div>`;
783782
document.body.insertAdjacentHTML('beforeEnd', html);
784783
this.DOM = document.getElementById('dlp-plane');
785784
/*X*/
@@ -800,11 +799,11 @@ class ComponentPlane {
800799

801800
makeContent() {
802801
this.loading();
803-
var object = this;
802+
let object = this;
804803
_component.request(this.URL, 'GET', {}, function (response) {
805804
object.loading(true);
806-
/*object.MODEL_BODY_DOM.innerHTML = response;*/
807-
$('#dlp-plane .plane-body').append(response);
805+
let fragment = document.createRange().createContextualFragment(response);
806+
document.querySelector('#dlp-plane .plane-body').appendChild(fragment);
808807
let submit = object.MODEL_BODY_DOM.querySelector('button[type="submit"]');
809808
if (submit instanceof HTMLElement) {
810809
submit.addEventListener('click', object.submitEvent.bind(object, submit), false);
@@ -817,15 +816,14 @@ class ComponentPlane {
817816
element.innerText = '提交中...';
818817
let form = this.MODEL_BODY_DOM.getElementsByTagName('form')[0];
819818
let formdata = new FormData(form);
820-
var object = this;
819+
let object = this;
821820
_component.request(this.XHR_URL, this.METHOD, formdata, function (response) {
822821
if (typeof object.CALLBACK == 'function') {
823822
object.CALLBACK(response);
824823
return;
825824
}
826-
if (response.code == 0) {
825+
if (response.code === 0) {
827826
window.location.reload();
828-
return;
829827
} else {
830828
_component.alert(response.message, 3, function () {
831829
element.removeAttribute('disabled');
@@ -892,7 +890,7 @@ class ComponentSortable {
892890

893891
if (!this.handle) return;
894892
this.list.style.position = 'relative';
895-
this.item.classList.add('is-dragging')
893+
this.item.classList.add('is-dragging');
896894
this.itemHeight = this.items[1].offsetTop;
897895
this.startTouchY = this.getDragY(e);
898896
this.startTop = this.item.offsetTop;
@@ -904,13 +902,13 @@ class ComponentSortable {
904902
item.style.top = 0;
905903
item.style.left = 0;
906904
item.style.transform = `translateY(${offsetsTop[index]}px)`;
907-
item.style.zIndex = (item == this.item) ? 2 : 1;
905+
item.style.zIndex = (item === this.item) ? 2 : 1;
908906
});
909907

910908
this.positions = this.items.map((item, index) => index);
911909
this.position = Math.round((this.startTop / this.listHeight) * this.items.length);
912910

913-
this.touch = e.type == 'touchstart';
911+
this.touch = e.type === 'touchstart';
914912
window.addEventListener((this.touch ? 'touchmove' : 'mousemove'), this.dragMove);
915913
window.addEventListener((this.touch ? 'touchend' : 'mouseup'), this.dragEnd, false);
916914
}
@@ -924,12 +922,12 @@ class ComponentSortable {
924922
this.item.style.transform = `translateY(${top}px)`;
925923

926924
this.positions.forEach(index => {
927-
if (index == this.position || index != newPosition) return;
925+
if (index === this.position || index !== newPosition) return;
928926
this.swapElements(this.positions, this.position, index);
929927
this.position = index;
930928
});
931929
this.items.forEach((item, index) => {
932-
if (item == this.item) return;
930+
if (item === this.item) return;
933931
item.style.transform = `translateY(${this.positions.indexOf(index) * this.itemHeight}px)`;
934932
item.style.transition = `transform ${this.options.animationSpeed}ms ${this.options.animationEasing}`;
935933
});

0 commit comments

Comments
 (0)