1 // ==========================================================================
  2 // Papercube.CircleViewController
  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   This controls some of the aspects of the CircleView display.
 13 
 14   @extends SC.ArrayController
 15   @author Peter Bergstrom
 16   @version 1.0
 17   @copyright 2008-2009 Peter Bergström.
 18   @static
 19 */
 20 Papercube.circleViewController = SC.Object.create(
 21 /** @scope Papercube.circleViewController */ {
 22   
 23   /**
 24     The increment value for the refThreshold slider. 
 25     
 26     @property {Integer}
 27     @default 1
 28   */
 29   refThresholdStep: 1,
 30 
 31   /**
 32     The max value for the refThreshold slider. 
 33     
 34     @property {Integer}
 35     @default 30
 36   */
 37   refThresholdValueMax: 30,
 38 
 39   /**
 40     The min value for the refThreshold slider. 
 41     
 42     @property {Integer}
 43     @default 0
 44   */
 45   refThresholdValueMin: 0,
 46 
 47   /**
 48     The value for the refThreshold slider. 
 49     
 50     @property {Integer}
 51     @default 0
 52   */
 53   refThreshold: 0,
 54 
 55   /**
 56     The default refThreshold value. 
 57     
 58     @property {Integer}
 59     @default 0
 60   */
 61   defaultRefThreshold: 0,
 62 
 63 
 64   /**
 65     The increment value for the citeThreshold slider. 
 66     
 67     @property {Integer}
 68     @default 1
 69   */
 70   citeThresholdStep: 1,
 71 
 72   /**
 73     The max value for the citeThreshold slider. 
 74     
 75     @property {Integer}
 76     @default 30
 77   */
 78   citeThresholdValueMax: 30,
 79 
 80   /**
 81     The min value for the citeThreshold slider. 
 82     
 83     @property {Integer}
 84     @default 0
 85   */
 86   citeThresholdValueMin: 0,
 87 
 88   /**
 89     The value for the citeThreshold slider. 
 90     
 91     @property {Integer}
 92     @default 0
 93   */
 94   citeThreshold: 0,
 95 
 96   /**
 97     The default citeThreshold value. 
 98     
 99     @property {Integer}
100     @default 0
101   */
102   defaultCiteThreshold: 0,
103   
104   /**
105     Route to the appropriate max strength action.
106   
107     @param opt {boolean} If YES, ref, if NO, cite.
108   */
109   maxStrength: function(opt)
110   {
111     if(opt)
112     {
113       this.maxRefStrength();
114     }
115     else
116     {
117       this.maxCiteStrength();
118     }
119   },
120 
121   /**
122     Route to the appropriate min strength action.
123   
124     @param opt {boolean} If YES, ref, if NO, cite.
125   */
126   minStrength: function(opt)  
127   {
128     if(opt)
129     {
130       this.minRefStrength();
131     }
132     else
133     {
134       this.minCiteStrength();
135     }
136   },
137   
138   /**
139     Increment the ref strength towards the maximum.
140   */
141   maxRefStrength: function()
142   {
143     if(this.get('refThreshold') < this.get('refThresholdValueMax'))
144       this.set('refThreshold', this.get('refThreshold')+1);
145   },
146 
147   /**
148     Increment the ref strength towards the minimum.
149   */
150   minRefStrength: function()
151   {
152     if(this.get('refThreshold') > this.get('refThresholdValueMin'))
153       this.set('refThreshold', this.get('refThreshold')-1);
154   },
155 
156   /**
157     Increment cite ref strength towards the maximum.
158   */
159 
160   maxCiteStrength: function()
161   {
162     if(this.get('citeThreshold') < this.get('citeThresholdValueMax'))
163       this.set('citeThreshold', this.get('citeThreshold')+1);
164   },
165 
166   /**
167     Increment cite ref strength towards the miniumum.
168   */
169   minCiteStrength: function()
170   {
171     if(this.get('citeThreshold') > this.get('citeThresholdValueMin'))
172       this.set('citeThreshold', this.get('citeThreshold')-1);
173   },
174 
175   /**
176     Set the default values for the controller.
177   */
178   setDefaults: function()
179   {
180     this.set('refThreshold', this.get('defaultRefThreshold'));
181     this.set('citeThreshold', this.get('defaultCiteThreshold'));
182   }
183   
184 }) ;
185