1 // ==========================================================================
  2 // Papercube.CollaboratorController
  3 //
  4 // License:  PaperCube is open source software released under 
  5 //           the MIT License (see license.js)
  6 // ==========================================================================
  7 
  8 require('core');
  9 
 10 /** @class
 11 
 12   Controls the sliders used for the author view.
 13 
 14   @extends NodeGraph.NodeGraphDelegate
 15   @author Peter Bergstrom
 16   @version 1.0
 17   @copyright 2008-2009 Peter Bergström.
 18   @static
 19 */
 20 Papercube.collaboratorController = NodeGraph.NodeGraphDelegate.create(
 21 /** @scope Papercube.collaboratorController */ {
 22 
 23   
 24   /**
 25     The increment value for the depth slider. 
 26     
 27     @property {Integer}
 28     @default 1
 29   */
 30   depthStep: 1,
 31   
 32   /**
 33     The max value for the depth slider. 
 34     
 35     @property {Integer}
 36     @default 5
 37   */
 38   depthValueMax: 5,
 39   
 40   /**
 41     The min value for the depth slider. 
 42     
 43     @property {Integer}
 44     @default 1
 45   */
 46   depthValueMin: 1,
 47 
 48   /**
 49     The value for the depth slider. 
 50     
 51     @property {Integer}
 52     @default 1
 53   */
 54   depth: 1,
 55 
 56   /**
 57     The default depth value. 
 58     
 59     @property {Integer}
 60     @default 1
 61   */
 62   defaultDepth: 1,
 63   
 64   /**
 65     The increment value for the collabThreshold slider. 
 66     
 67     @property {Integer}
 68     @default 1
 69   */
 70   collabThresholdStep: 1,
 71 
 72   /**
 73     The max value for the collabThreshold slider. 
 74     
 75     @property {Integer}
 76     @default 30
 77   */
 78   collabThresholdValueMax: 30,
 79 
 80   /**
 81     The min value for the collabThreshold slider. 
 82     
 83     @property {Integer}
 84     @default 1
 85   */
 86   collabThresholdValueMin: 1,
 87 
 88   /**
 89     The value for the collabThreshold slider. 
 90     
 91     @property {Integer}
 92     @default 30
 93   */
 94   collabThreshold: 30,
 95 
 96   /**
 97     The default collabThreshold value. 
 98     
 99     @property {Integer}
100     @default 1
101   */
102   defaultCollabThreshold: 1,
103 
104   /**
105     The increment value for the paperThreshold slider. 
106     
107     @property {Integer}
108     @default 1
109   */
110   paperThresholdStep: 1,
111 
112   /**
113     The max value for the paperThreshold slider. 
114     
115     @property {Integer}
116     @default 30
117   */
118   paperThresholdValueMax: 30,
119 
120   /**
121     The min value for the paperThreshold slider. 
122     
123     @property {Integer}
124     @default 1
125   */
126   paperThresholdValueMin: 1,
127 
128   /**
129     The value for the paperThreshold slider. 
130     
131     @property {Integer}
132     @default 30
133   */
134   paperThreshold: 30,
135 
136   /**
137     The default paperThreshold value. 
138     
139     @property {Integer}
140     @default 1
141   */
142   defaultPaperThreshold: 1,
143     
144   /**
145     Called by the NodeGraph instance when a mouseDown is triggered.
146     
147     @param {DOM Event} evt The mouseDown event.
148     @param {NodeGraph.NodeGraphView} The NodeGraph view.
149     @param guid {String} The guid of the node.
150   */
151   nodeGraphDidMouseDown: function(evt, view, guid) {
152     var type = evt.target.getAttribute('type');
153     if(guid && type)
154     {
155       Papercube.canvasController.showFan(Event.pointerX(evt), 
156                                          Event.pointerY(evt), 
157                                          view.viewName, (type+"Fan"));
158       return YES;
159     }
160     return NO;
161   },
162 
163   /**
164     Allow for additional customized setup of the NodeGraph view.
165     
166     @param {NodeGraph.NodeGraphView} nodeGraph The NodeGraph instance.
167   */
168   finishInitForGraph: function(nodeGraph) {
169     Papercube.canvasController.fanForNodeGraph(nodeGraph);
170   },
171 
172   /**
173     Route to the appropriate max strength action.
174   
175     @param opt {boolean} If YES, ref, if NO, cite.
176   */
177   maxStrength: function(opt)
178   {
179     if(opt)
180     {
181       this.maxPaperStrength();
182     }
183     else
184     {
185       this.maxCollabStrength();
186     }
187   },
188 
189   /**
190     Route to the appropriate min strength action.
191   
192     @param opt {boolean} If YES, ref, if NO, cite.
193   */
194   minStrength: function(opt)  
195   {
196 
197     if(opt)
198     {
199       this.minPaperStrength();
200     }
201     else
202     {
203       this.minCollabStrength();
204     }
205   },
206     
207   /**
208     Increment the collaborator strength towards the maximum.
209   */
210   maxCollabStrength: function()
211   {
212     if(this.get('collabThreshold') < this.get('collabThresholdValueMax'))
213       this.set('collabThreshold', this.get('collabThreshold')+1);
214   },
215 
216   /**
217     Increment the collaborator strength towards the minimum.
218   */
219   minCollabStrength: function()
220   {
221     if(this.get('collabThreshold') > this.get('collabThresholdValueMin'))
222       this.set('collabThreshold', this.get('collabThreshold')-1);
223   },
224 
225   /**
226     Increment the paper strength towards the maximum.
227   */
228   maxPaperStrength: function()
229   {
230     if(this.get('paperThreshold') < this.get('paperThresholdValueMax'))
231       this.set('paperThreshold', this.get('paperThreshold')+1);
232   },
233 
234   /**
235     Increment the paper strength towards the minimum.
236   */
237   minPaperStrength: function()
238   {
239     if(this.get('paperThreshold') > this.get('paperThresholdValueMin'))
240       this.set('paperThreshold', this.get('paperThreshold')-1);
241   },
242 
243   /**
244     Increment the depth towards the maximum.
245     Take her down!
246   */
247   maxDepth: function()
248   {
249     if(this.get('depth') < this.get('depthValueMax'))
250       this.set('depth',this.get('depth')+1);
251   },
252 
253   /**
254     Increment the depth towards the maximum.
255     
256     Rig for surface!
257   */
258   minDepth: function()
259   {
260     if(this.get('depth') > this.get('depthValueMin'))
261       this.set('depth',this.get('depth')-1);
262   },
263   
264   /**
265     Set the default values for the controller.
266   */
267   setDefaults: function()
268   {
269     this.set('depth', this.get('defaultDepth'));
270     this.set('collabThreshold', this.get('defaultCollabThreshold'));
271     this.set('paperThreshold', this.get('defaultPaperThreshold'));
272   }
273   
274 }) ;
275