Browse Source

Make freezed a status of the component

pull/187/head
Artur Arseniev 9 years ago
parent
commit
5ed91bc20c
  1. 27
      src/dom_components/view/ComponentView.js
  2. 29
      src/utils/Sorter.js

27
src/dom_components/view/ComponentView.js

@ -100,22 +100,27 @@ module.exports = Backbone.View.extend({
* @private
* */
updateStatus(e) {
var s = this.model.get('status');
var el = this.el;
var status = this.model.get('status');
var pfx = this.pfx;
var selectedClass = pfx + 'selected';
var selectedParentClass = selectedClass + '-parent';
var ppfx = this.ppfx;
var selectedCls = pfx + 'selected';
var selectedParentCls = selectedCls + '-parent';
var freezedCls = `${ppfx}freezed`;
var actualCls = el.getAttribute('class');
switch(s) {
switch (status) {
case 'selected':
this.$el.addClass(selectedClass);
break;
el.setAttribute('class', `${actualCls} ${selectedCls}`);
break;
case 'selected-parent':
this.$el.addClass(selectedParentClass);
break;
case 'moving':
break;
el.setAttribute('class', `${actualCls} ${selectedParentCls}`);
break;
case 'freezed':
el.setAttribute('class', `${actualCls} ${freezedCls}`);
break;
default:
this.$el.removeClass(`${selectedClass} ${selectedParentClass}`);
this.$el.removeClass(`${selectedCls} ${selectedParentCls} ${freezedCls}`);
}
},

29
src/utils/Sorter.js

@ -220,26 +220,27 @@ module.exports = Backbone.View.extend({
/**
* Picking component to move
* @param {HTMLElement} trg
* @param {HTMLElement} src
* */
startSort(trg) {
startSort(src) {
this.dropModel = null;
this.moved = 0;
//this.$document = $([document, trg.ownerDocument]);
if(trg && !this.matches(trg, this.itemSel + ',' + this.containerSel))
trg = this.closest(trg, this.itemSel);
if(src && !this.matches(src, this.itemSel + ',' + this.containerSel))
src = this.closest(src, this.itemSel);
this.eV = trg;
this.eV = src;
// Create placeholder if not exists
if(!this.plh) {
if (!this.plh) {
this.plh = this.createPlaceholder();
this.getContainerEl().appendChild(this.plh);
}
if(trg) {
var className = trg.getAttribute('class');
trg.setAttribute('class', `${className} ${this.freezeClass}`);
if (src) {
var srcModel = this.getSourceModel();
srcModel.set('status', 'freezed');
this.$document.on('mouseup', this.endMove);
}
@ -728,15 +729,15 @@ module.exports = Backbone.View.extend({
this.$document.off('keydown', this.rollback);
this.plh.style.display = 'none';
var clsReg = new RegExp('(?:^|\\s)'+this.freezeClass+'(?!\\S)', 'gi');
let trg = this.eV;
let src = this.eV;
if (trg) {
var className = (trg.getAttribute('class')+'').replace(clsReg, '');
trg.setAttribute('class', className);
if (src) {
var srcModel = this.getSourceModel();
srcModel.set('status', 'selected');
}
if(this.moved)
created = this.move(this.target, trg, this.lastPos);
created = this.move(this.target, src, this.lastPos);
if(this.plh)
this.plh.style.display = 'none';

Loading…
Cancel
Save