aboutsummaryrefslogtreecommitdiff
path: root/js/mediators
diff options
context:
space:
mode:
Diffstat (limited to 'js/mediators')
-rwxr-xr-xjs/mediators/element-mediator.js61
1 files changed, 11 insertions, 50 deletions
diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js
index 7244b58e..da8cbb76 100755
--- a/js/mediators/element-mediator.js
+++ b/js/mediators/element-mediator.js
@@ -373,17 +373,13 @@ exports.ElementMediator = Montage.create(Component, {
373 }, 373 },
374 374
375 getStroke: { 375 getStroke: {
376 value: function(el) { 376 value: function(el, strokeProperties) {
377 if(!el.elementModel) { 377 return el.elementModel.controller["getStroke"](el, strokeProperties);
378 NJUtils.makeElementModel(el, "Div", "block");
379 }
380 return el.elementModel.controller["getStroke"](el);
381 } 378 }
382 }, 379 },
383 380
384
385 /** 381 /**
386 Set a property change command for an element or array of elements 382 Set stroke/border properties on an element or array of elements
387 @param els: Array of elements. Can contain 1 or more elements 383 @param els: Array of elements. Can contain 1 or more elements
388 @param value: Value to be set. This is the stroke info 384 @param value: Value to be set. This is the stroke info
389 @param eventType: Change/Changing. Will be passed to the dispatched event 385 @param eventType: Change/Changing. Will be passed to the dispatched event
@@ -393,54 +389,20 @@ exports.ElementMediator = Montage.create(Component, {
393 setStroke: { 389 setStroke: {
394 value: function(els, value, eventType, source, currentValue) { 390 value: function(els, value, eventType, source, currentValue) {
395 391
396 if(eventType === "Changing") { 392 if(eventType !== "Changing") {
397 this._setStroke(els, value, isFill, eventType, source);
398 } else {
399 // Calculate currentValue if not found for each element 393 // Calculate currentValue if not found for each element
400 if(!currentValue) { 394 if(!currentValue) {
401 var that = this; 395 var that = this,
396 val = value;
402 currentValue = els.map(function(item) { 397 currentValue = els.map(function(item) {
403 return that.getStroke(item); 398 return that.getStroke(item, val);
404 }); 399 });
405 } 400 }
406 401 document.application.undoManager.add("Set stroke", this.setStroke, this, els, currentValue, eventType, source, value);
407 var command = Montage.create(Command, {
408 _els: { value: els },
409 _value: { value: value },
410 _previous: { value: currentValue },
411 _eventType: { value: eventType},
412 _source: { value: "undo-redo"},
413 description: { value: "Set Color"},
414 receiver: { value: this},
415
416 execute: {
417 value: function(senderObject) {
418 if(senderObject) this._source = senderObject;
419 this.receiver._setStroke(this._els, this._value, this._eventType, this._source);
420 this._source = "undo-redo";
421 return "";
422 }
423 },
424
425 unexecute: {
426 value: function() {
427 this.receiver._setStroke(this._els, this._previous, this._eventType, this._source);
428 return "";
429 }
430 }
431 });
432
433 NJevent("sendToUndo", command);
434 command.execute(source);
435 } 402 }
436 403
437 }
438 },
439
440 _setStroke: {
441 value: function(els, value, eventType, source) {
442 for(var i=0, item; item = els[i]; i++) { 404 for(var i=0, item; item = els[i]; i++) {
443 item.elementModel.controller["setStroke"](item, value); 405 item.elementModel.controller["setStroke"](item, (value[i] || value), eventType, source);
444 } 406 }
445 407
446 NJevent("element" + eventType, {type : "setStroke", source: source, data: {"els": els, "prop": "stroke", "value": value}, redraw: null}); 408 NJevent("element" + eventType, {type : "setStroke", source: source, data: {"els": els, "prop": "stroke", "value": value}, redraw: null});
@@ -453,9 +415,8 @@ exports.ElementMediator = Montage.create(Component, {
453 } 415 }
454 }, 416 },
455 417
456
457 /** 418 /**
458 Set a property change command for an element or array of elements 419 Set fill/background properties for an element or array of elements
459 @param els: Array of elements. Can contain 1 or more elements 420 @param els: Array of elements. Can contain 1 or more elements
460 @param value: Value to be set. This is the fill info 421 @param value: Value to be set. This is the fill info
461 @param eventType: Change/Changing. Will be passed to the dispatched event 422 @param eventType: Change/Changing. Will be passed to the dispatched event
@@ -478,7 +439,7 @@ exports.ElementMediator = Montage.create(Component, {
478 } 439 }
479 440
480 for(var i=0, item; item = els[i]; i++) { 441 for(var i=0, item; item = els[i]; i++) {
481 item.elementModel.controller["setFill"](item, (value[i] || value), eventType, source); 442 item.elementModel.controller["setFill"](item, (value[i] || value));
482 } 443 }
483 444
484 NJevent("element" + eventType, {type : "setFill", source: source, data: {"els": els, "prop": "fill", "value": value}, redraw: null}); 445 NJevent("element" + eventType, {type : "setFill", source: source, data: {"els": els, "prop": "fill", "value": value}, redraw: null});