Browse Source

Update undo and redo methods

pull/36/head
Artur Arseniev 10 years ago
parent
commit
ef7ccff81b
  1. 1
      src/commands/view/MoveComponent.js
  2. 4
      src/editor/model/Editor.js
  3. 12
      src/utils/Sorter.js
  4. 10
      styles/css/main.css
  5. 10
      styles/scss/main.scss

1
src/commands/view/MoveComponent.js

@ -87,6 +87,7 @@ define(['backbone', './SelectComponent','./SelectPosition'],
var utils = this.editor.Utils; var utils = this.editor.Utils;
if(utils && utils.Sorter) if(utils && utils.Sorter)
this.sorter = new utils.Sorter({ this.sorter = new utils.Sorter({
editor: this.editor,
container: this.$el.get(0), container: this.$el.get(0),
containerSel: '*', containerSel: '*',
itemSel: '*', itemSel: '*',

4
src/editor/model/Editor.js

@ -381,10 +381,10 @@ define([
this.UndoManager = this.um; this.UndoManager = this.um;
this.set('UndoManager', this.um); this.set('UndoManager', this.um);
key('⌘+z, ctrl+z', function(){ key('⌘+z, ctrl+z', function(){
that.um.undo(); that.um.undo(true);
}); });
key('⌘+shift+z, ctrl+shift+z', function(){ key('⌘+shift+z, ctrl+shift+z', function(){
that.um.redo(); that.um.redo(true);
}); });
Backbone.UndoManager.removeUndoType("change"); Backbone.UndoManager.removeUndoType("change");

12
src/utils/Sorter.js

@ -22,6 +22,7 @@ define(['backbone'],
this.direction = o.direction || 'v'; // v (vertical), h (horizontal), a (auto) this.direction = o.direction || 'v'; // v (vertical), h (horizontal), a (auto)
this.onMoveClb = o.onMove || ''; this.onMoveClb = o.onMove || '';
this.relative = o.relative || 0; this.relative = o.relative || 0;
this.editor = o.editor || '';
this.dropContent = ''; this.dropContent = '';
}, },
@ -383,9 +384,12 @@ define(['backbone'],
* */ * */
movePlaceholder: function(plh, dims, pos, trgDim){ movePlaceholder: function(plh, dims, pos, trgDim){
var marg = 0, t = 0, l = 0, w = 0, h = 0, var marg = 0, t = 0, l = 0, w = 0, h = 0,
un = 'px', margI = 5, un = 'px', margI = 5, brdCol = '#62c462', brd = 3,
method = pos.method; method = pos.method;
var elDim = dims[pos.index]; var elDim = dims[pos.index];//#62c462
plh.style.borderColor = 'transparent ' + brdCol;
plh.style.borderWidth = brd + ' ' + (brd + 2);
plh.style.margin = '-' + brd + 'px 0 0';
if(elDim){ if(elDim){
// If it's not in flow (like 'float' element) // If it's not in flow (like 'float' element)
if(!elDim[4]){ if(!elDim[4]){
@ -393,6 +397,9 @@ define(['backbone'],
h = elDim[2] - (marg * 2) + un; h = elDim[2] - (marg * 2) + un;
t = elDim[0] + marg; t = elDim[0] + marg;
l = (method == 'before') ? (elDim[1] - marg) : (elDim[1] + elDim[3] - marg); l = (method == 'before') ? (elDim[1] - marg) : (elDim[1] + elDim[3] - marg);
plh.style.borderColor = brdCol + ' transparent';
plh.style.borderWidth = (brd + 2) + ' ' + brd;
plh.style.margin = '0 0 0 -' + brd + 'px';
}else{ }else{
w = elDim[3] + un; w = elDim[3] + un;
h = 'auto'; h = 'auto';
@ -460,6 +467,7 @@ define(['backbone'],
if(!this.dropContent){ if(!this.dropContent){
modelTemp = targetCollection.add({}, opts); modelTemp = targetCollection.add({}, opts);
modelToDrop = model.collection.remove(model); modelToDrop = model.collection.remove(model);
}else{ }else{
modelToDrop = this.dropContent; modelToDrop = this.dropContent;
opts.silent = false; opts.silent = false;

10
styles/css/main.css

@ -2749,12 +2749,20 @@ ol.example li.placeholder:before {
position: absolute; position: absolute;
z-index: 10; } z-index: 10; }
.wte-placeholder {
/*border-width: 3px !important;*/
border-style: solid !important;
border-color: #62c462;
outline: none; }
.wte-placeholder-int, .wte-com-placeholder-int { .wte-placeholder-int, .wte-com-placeholder-int {
background-color: #62c462; background-color: #62c462;
box-shadow: 0 0 3px rgba(0, 0, 0, 0.2);
height: 100%; height: 100%;
width: 100%; width: 100%;
pointer-events: 'none'; pointer-events: 'none';
padding: 2px; } padding: 1px;
outline: none; }
/********* PANELS **********/ /********* PANELS **********/
.wte-pn-panel { .wte-pn-panel {

10
styles/scss/main.scss

@ -222,11 +222,19 @@ ol.example li.placeholder:before {position: absolute;}
position: absolute; position: absolute;
z-index: 10; z-index: 10;
} }
.#{$app-prefix}placeholder{
/*border-width: 3px !important;*/
border-style: solid !important;
border-color: $colorGreen;
outline: none;
}
.#{$app-prefix}placeholder-int, .#{$com-prefix}placeholder-int{ .#{$app-prefix}placeholder-int, .#{$com-prefix}placeholder-int{
background-color: $colorGreen; background-color: $colorGreen;
box-shadow: 0 0 3px rgba(0, 0, 0, 0.2);
height: 100%; width: 100%; height: 100%; width: 100%;
pointer-events: 'none'; pointer-events: 'none';
padding: 2px; padding: 1px;
outline: none;
} }
/********* PANELS **********/ /********* PANELS **********/

Loading…
Cancel
Save