From d44f3196c925332dcaf45f7cf8c64e22a1994bb9 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 4 Jun 2012 17:11:06 -0700 Subject: Fill and Ink-Bottle fixes. Signed-off-by: Nivesh Rajbhandari --- js/mediators/element-mediator.js | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'js/mediators/element-mediator.js') diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index 1d5e9ade..7244b58e 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js @@ -389,7 +389,6 @@ exports.ElementMediator = Montage.create(Component, { @param eventType: Change/Changing. Will be passed to the dispatched event @param source: String for the source object making the call @param currentValue *OPTIONAL*: current value array. If not found the current value is calculated - @param stageRedraw: *OPTIONAL*: True. If set to false the stage will not redraw the selection/outline */ setStroke: { value: function(els, value, eventType, source, currentValue) { @@ -448,6 +447,44 @@ exports.ElementMediator = Montage.create(Component, { } }, + getFill: { + value: function(el, fillProperties) { + return el.elementModel.controller["getFill"](el, fillProperties); + } + }, + + + /** + Set a property change command for an element or array of elements + @param els: Array of elements. Can contain 1 or more elements + @param value: Value to be set. This is the fill info + @param eventType: Change/Changing. Will be passed to the dispatched event + @param source: String for the source object making the call + @param currentValue *OPTIONAL*: current value array. If not found the current value is calculated + */ + setFill: { + value: function(els, value, eventType, source, currentValue) { + + if(eventType !== "Changing") { + // Calculate currentValue if not found for each element + if(!currentValue) { + var that = this, + val = value; + currentValue = els.map(function(item) { + return that.getFill(item, val); + }); + } + document.application.undoManager.add("Set fill", this.setFill, this, els, currentValue, eventType, source, value); + } + + for(var i=0, item; item = els[i]; i++) { + item.elementModel.controller["setFill"](item, (value[i] || value), eventType, source); + } + + NJevent("element" + eventType, {type : "setFill", source: source, data: {"els": els, "prop": "fill", "value": value}, redraw: null}); + } + }, + //-------------------------------------------------------------------------------------------------------- // Routines to get/set 3D properties get3DProperty: { -- cgit v1.2.3