1 // ========================================================================== 2 // Papercube.CiteRefController 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 ref/cite 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.citeRefController = NodeGraph.NodeGraphDelegate.create( 21 /** @scope Papercube.citeRefController */ { 22 23 /** 24 The increment value for the linkThreshold slider. 25 26 @property {Integer} 27 @default 1 28 */ 29 linkThresholdStep: 1, 30 31 /** 32 The max value for the linkThreshold slider. 33 34 @property {Integer} 35 @default 30 36 */ 37 linkThresholdValueMax: 30, 38 39 /** 40 The min value for the linkThreshold slider. 41 42 @property {Integer} 43 @default 1 44 */ 45 linkThresholdValueMin: 1, 46 47 /** 48 The value for the linkThreshold slider. 49 50 @property {Integer} 51 @default 1 52 */ 53 linkThreshold: 1, 54 55 /** 56 The default linkThreshold value. 57 58 @property {Integer} 59 @default 1 60 */ 61 defaultLinkThreshold: 1, 62 63 /** 64 The search prompt value. This value is bound in the view. 65 66 @property {String} 67 */ 68 strengthPrompt: '', 69 70 /** 71 The reference prompt value. 72 73 'Hide authors who were referenced by focused author less than ' 74 75 @property {String} 76 */ 77 refPrompt: 'Hide authors who were referenced by focused author less than ', 78 79 /** 80 The citation prompt value. 81 82 'Hide authors who referenced the focused author less than ' 83 84 @property {String} 85 */ 86 citePrompt: 'Hide authors who referenced the focused author less than ', 87 88 /** 89 Called by the NodeGraph instance when a mouseDown is triggered. 90 91 @param {DOM Event} evt The mouseDown event. 92 @param {NodeGraph.NodeGraphView} The NodeGraph view. 93 @param guid {String} The guid of the node. 94 */ 95 nodeGraphDidMouseDown: function(evt, view, guid) { 96 var type = evt.target.getAttribute('type'); 97 if(guid && type) 98 { 99 Papercube.canvasController.showFan(Event.pointerX(evt), 100 Event.pointerY(evt), 101 view.viewName, (type+"Fan")); 102 return YES; 103 } 104 return NO; 105 }, 106 107 /** 108 Allow for additional customized setup of the NodeGraph view. 109 110 @param {NodeGraph.NodeGraphView} nodeGraph The NodeGraph instance. 111 */ 112 finishInitForGraph: function(nodeGraph) { 113 Papercube.canvasController.fanForNodeGraph(nodeGraph); 114 }, 115 116 /** 117 Based on the view direction, set the appropriate search prompt. 118 */ 119 setPrompt: function() 120 { 121 if(Papercube.viewController.get('viewDirection') == 'References') 122 { 123 Papercube.citeRefController.set('strengthPrompt', this.get('refPrompt')); 124 } 125 else 126 { 127 Papercube.citeRefController.set('strengthPrompt', this.get('citePrompt')); 128 } 129 }, 130 131 /** 132 Increment the strength towards the maximum. 133 */ 134 maxStrength: function() 135 { 136 if(this.get('linkThreshold') < this.get('linkThresholdValueMax')) 137 this.set('linkThreshold', this.get('linkThreshold')+1); 138 }, 139 140 /** 141 Increment the strength towards the minimum. 142 */ 143 minStrength: function() 144 { 145 if(this.get('linkThreshold') > this.get('linkThresholdValueMin')) 146 this.set('linkThreshold', this.get('linkThreshold')-1); 147 }, 148 149 /** 150 Set the default values for the controller. 151 */ 152 setDefaults: function() 153 { 154 this.set('linkThreshold', this.get('defaultLinkThreshold')); 155 this.setPrompt(); 156 } 157 158 159 }) ; 160