| 1 |
define(["dojo/_base/kernel", "dojo/_base/declare","dojo/_base/lang","dojo/_base/html","dojo/_base/array","dojo/_base/event", |
| 2 |
"dojo/_base/connect","dojo/dom-construct", "dijit/_Widget", "dojox/gfx", "./Range", "dojo/fx/easing"], |
| 3 |
function(kernel, declare, lang, html, arr, event, connect, dom, Widget, gfx, Range) { |
| 4 |
|
| 5 |
kernel.deprecated("dojox.gauges", "Use the new extensible dojox.dgauges framework instead", "2.0"); |
| 6 |
|
| 7 |
|
| 8 |
var _tooltipModule = 0; |
| 9 |
var _numberModule = 0; |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
return declare("dojox.gauges._Gauge",[Widget],{ |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
width: 0, |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
height: 0, |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
background: null, |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
image: null, |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
useRangeStyles: 0, |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
useTooltip: true, |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
majorTicks: null, |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
minorTicks: null, |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
_defaultIndicator: null, |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
defaultColors: [[0x00,0x54,0xAA,1], |
| 84 |
[0x44,0x77,0xBB,1], |
| 85 |
[0x66,0x99,0xCC,1], |
| 86 |
[0x99,0xBB,0xEE,1], |
| 87 |
[0x99,0xCC,0xFF,1], |
| 88 |
[0xCC,0xEE,0xFF,1], |
| 89 |
[0xDD,0xEE,0xFF,1]], |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
min: null, |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
max: null, |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
surface: null, |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
hideValues: false, |
| 109 |
|
| 110 |
|
| 111 |
gaugeContent: undefined, |
| 112 |
_backgroundDefault: {color: '#E0E0E0'}, |
| 113 |
_rangeData: null, |
| 114 |
_indicatorData: null, |
| 115 |
_drag: null, |
| 116 |
_img: null, |
| 117 |
_overOverlay: false, |
| 118 |
_lastHover: '', |
| 119 |
|
| 120 |
startup: function(){ |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
if(this.image === null){ |
| 125 |
this.image={}; |
| 126 |
} |
| 127 |
|
| 128 |
this.connect(this.gaugeContent, 'onmousedown', this.handleMouseDown); |
| 129 |
this.connect(this.gaugeContent, 'onmousemove', this.handleMouseMove); |
| 130 |
this.connect(this.gaugeContent, 'onmouseover', this.handleMouseOver); |
| 131 |
this.connect(this.gaugeContent, 'onmouseout', this.handleMouseOut); |
| 132 |
this.connect(this.gaugeContent, 'touchstart', this.handleTouchStart); |
| 133 |
this.connect(this.gaugeContent, 'touchend', this.handleTouchEnd); |
| 134 |
this.connect(this.gaugeContent, 'touchmove', this.handleTouchMove); |
| 135 |
|
| 136 |
if(!lang.isArray(this.ranges)){ this.ranges = []; } |
| 137 |
if(!lang.isArray(this.indicators)){ this.indicators = []; } |
| 138 |
var ranges = [], indicators = []; |
| 139 |
var i; |
| 140 |
if(this.hasChildren()){ |
| 141 |
var children = this.getChildren(); |
| 142 |
for(i=0; i<children.length; i++){ |
| 143 |
if(/.*Indicator/.test(children[i].declaredClass)){ |
| 144 |
indicators.push(children[i]); |
| 145 |
|
| 146 |
continue; |
| 147 |
} |
| 148 |
|
| 149 |
switch(children[i].declaredClass){ |
| 150 |
case Range.prototype.declaredClass: |
| 151 |
ranges.push(children[i]); |
| 152 |
break; |
| 153 |
} |
| 154 |
} |
| 155 |
this.ranges = this.ranges.concat(ranges); |
| 156 |
this.indicators = this.indicators.concat(indicators); |
| 157 |
} |
| 158 |
if(!this.background){ this.background = this._backgroundDefault; } |
| 159 |
this.background = this.background.color || this.background; |
| 160 |
if(!this.surface){ this.createSurface(); } |
| 161 |
|
| 162 |
this.addRanges(this.ranges); |
| 163 |
if(this.minorTicks && this.minorTicks.interval){ |
| 164 |
this.setMinorTicks(this.minorTicks); |
| 165 |
} |
| 166 |
if(this.majorTicks && this.majorTicks.interval){ |
| 167 |
this.setMajorTicks(this.majorTicks); |
| 168 |
} |
| 169 |
for(i=0; i<this.indicators.length; i++){ |
| 170 |
this.addIndicator(this.indicators[i]); |
| 171 |
} |
| 172 |
this.inherited(arguments); |
| 173 |
}, |
| 174 |
|
| 175 |
hasChildren: function(){ |
| 176 |
|
| 177 |
|
| 178 |
return this.getChildren().length > 0; |
| 179 |
}, |
| 180 |
|
| 181 |
buildRendering: function(){ |
| 182 |
|
| 183 |
|
| 184 |
var n = this.domNode = this.srcNodeRef ? this.srcNodeRef: dom.create("div"); |
| 185 |
this.gaugeContent = dom.create("div", { |
| 186 |
className: "dojoxGaugeContent" |
| 187 |
}); |
| 188 |
this.containerNode = dom.create("div"); |
| 189 |
this.mouseNode = dom.create("div"); |
| 190 |
while(n.hasChildNodes()){ |
| 191 |
this.containerNode.appendChild(n.firstChild); |
| 192 |
} |
| 193 |
dom.place(this.gaugeContent, n); |
| 194 |
dom.place(this.containerNode, n); |
| 195 |
dom.place(this.mouseNode, n); |
| 196 |
}, |
| 197 |
|
| 198 |
_setTicks: function( oldTicks, newTicks, major){ |
| 199 |
|
| 200 |
|
| 201 |
var i; |
| 202 |
if (oldTicks && lang.isArray(oldTicks._ticks)){ |
| 203 |
for (i = 0; i < oldTicks._ticks.length; i++){ |
| 204 |
this._removeScaleTick(oldTicks._ticks[i]); |
| 205 |
} |
| 206 |
} |
| 207 |
var t = { |
| 208 |
length: newTicks.length, |
| 209 |
offset: newTicks.offset, |
| 210 |
noChange: true |
| 211 |
}; |
| 212 |
if (newTicks.color){ |
| 213 |
t.color = newTicks.color; |
| 214 |
} |
| 215 |
if (newTicks.font){ |
| 216 |
t.font = newTicks.font; |
| 217 |
} |
| 218 |
if (newTicks.labelPlacement){ |
| 219 |
t.direction = newTicks.labelPlacement; |
| 220 |
} |
| 221 |
newTicks._ticks = []; |
| 222 |
for (i=this.min;i<=this.max;i+=newTicks.interval){ |
| 223 |
if (i==this.max&&this._isScaleCircular()) continue; |
| 224 |
t.value=i; |
| 225 |
if (major){ |
| 226 |
var NumberUtils = this._getNumberModule(); |
| 227 |
if (NumberUtils){ |
| 228 |
t.label = (newTicks.fixedPrecision && newTicks.precision) ? NumberUtils.format(i, { |
| 229 |
places: newTicks.precision |
| 230 |
}): NumberUtils.format(i); |
| 231 |
}else{ |
| 232 |
t.label = (newTicks.fixedPrecision && newTicks.precision) ? i.toFixed(newTicks.precision): i.toString(); |
| 233 |
} |
| 234 |
} |
| 235 |
newTicks._ticks.push(this._addScaleTick(t, major)); |
| 236 |
} |
| 237 |
return newTicks; |
| 238 |
}, |
| 239 |
|
| 240 |
_isScaleCircular: function(){ |
| 241 |
|
| 242 |
|
| 243 |
return false; |
| 244 |
}, |
| 245 |
|
| 246 |
setMinorTicks: function( ticks){ |
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
this.minorTicks = this._setTicks(this.minorTicks, ticks, false); |
| 251 |
}, |
| 252 |
|
| 253 |
setMajorTicks: function( ticks){ |
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
this.majorTicks = this._setTicks(this.majorTicks, ticks, true); |
| 258 |
}, |
| 259 |
|
| 260 |
postCreate: function(){ |
| 261 |
if(this.hideValues){ |
| 262 |
html.style(this.containerNode, "display", "none"); |
| 263 |
} |
| 264 |
html.style(this.mouseNode, 'width', '0'); |
| 265 |
html.style(this.mouseNode, 'height', '0'); |
| 266 |
html.style(this.mouseNode, 'position', 'absolute'); |
| 267 |
html.style(this.mouseNode, 'z-index', '100'); |
| 268 |
|
| 269 |
if(this.useTooltip){ |
| 270 |
require(["dijit/Tooltip"], dojo.hitch(this, function(Tooltip){ |
| 271 |
Tooltip.show('test', this.mouseNode, !this.isLeftToRight()); |
| 272 |
Tooltip.hide(this.mouseNode); |
| 273 |
})); |
| 274 |
} |
| 275 |
}, |
| 276 |
|
| 277 |
_getNumberModule :function() { |
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
if (_numberModule == 0) { |
| 282 |
try { |
| 283 |
_numberModule = require("dojo/number"); |
| 284 |
} |
| 285 |
catch (e) { |
| 286 |
_numberModule = null; |
| 287 |
} |
| 288 |
} |
| 289 |
return _numberModule; |
| 290 |
}, |
| 291 |
|
| 292 |
createSurface: function(){ |
| 293 |
|
| 294 |
|
| 295 |
this.gaugeContent.style.width = this.width + 'px'; |
| 296 |
this.gaugeContent.style.height = this.height + 'px'; |
| 297 |
this.surface = gfx.createSurface(this.gaugeContent, this.width, this.height); |
| 298 |
|
| 299 |
|
| 300 |
this._backgroundGroup = this.surface.createGroup(); |
| 301 |
this._rangeGroup = this.surface.createGroup(); |
| 302 |
this._minorTicksGroup = this.surface.createGroup(); |
| 303 |
this._majorTicksGroup = this.surface.createGroup(); |
| 304 |
this._overlayGroup = this.surface.createGroup(); |
| 305 |
this._indicatorsGroup = this.surface.createGroup(); |
| 306 |
this._foregroundGroup = this.surface.createGroup(); |
| 307 |
|
| 308 |
this._background = this._backgroundGroup.createRect({x: 0, y: 0, width: this.width, height: this.height }); |
| 309 |
this._background.setFill(this.background); |
| 310 |
|
| 311 |
if(this.image.url){ |
| 312 |
var imageGroup = this._backgroundGroup; |
| 313 |
if (this.image.overlay) |
| 314 |
imageGroup = this._overlayGroup; |
| 315 |
|
| 316 |
this._img = imageGroup.createImage({width: this.image.width || this.width, height: this.image.height || this.height, src: this.image.url}); |
| 317 |
if(this.image.x || this.image.y){ |
| 318 |
this._img.setTransform({dx: this.image.x || 0, dy: this.image.y || 0}); |
| 319 |
} |
| 320 |
} |
| 321 |
}, |
| 322 |
|
| 323 |
draw: function(){ |
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
var i; |
| 329 |
if (!this.surface)return; |
| 330 |
|
| 331 |
this.drawBackground(this._backgroundGroup); |
| 332 |
|
| 333 |
if(this._rangeData){ |
| 334 |
for(i=0; i<this._rangeData.length; i++){ |
| 335 |
this.drawRange(this._rangeGroup, this._rangeData[i]); |
| 336 |
} |
| 337 |
} |
| 338 |
|
| 339 |
if(this._minorTicksData){ |
| 340 |
for(i=0; i<this._minorTicksData.length; i++){ |
| 341 |
this._minorTicksData[i].draw(this._minorTicksGroup); |
| 342 |
} |
| 343 |
} |
| 344 |
if(this._majorTicksData){ |
| 345 |
for(i=0; i<this._majorTicksData.length; i++){ |
| 346 |
this._majorTicksData[i].draw(this._majorTicksGroup); |
| 347 |
} |
| 348 |
} |
| 349 |
|
| 350 |
if(this._indicatorData){ |
| 351 |
for(i=0; i<this._indicatorData.length; i++){ |
| 352 |
this._indicatorData[i].draw(this._indicatorsGroup); |
| 353 |
} |
| 354 |
} |
| 355 |
this.drawForeground(this._foregroundGroup); |
| 356 |
}, |
| 357 |
|
| 358 |
|
| 359 |
drawBackground:function(group){ |
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
}, |
| 366 |
|
| 367 |
drawForeground:function(group){ |
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
}, |
| 374 |
|
| 375 |
setBackground: function(background){ |
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
if(!background){ background = this._backgroundDefault; } |
| 388 |
this.background = background.color || background; |
| 389 |
this._background.setFill(this.background); |
| 390 |
}, |
| 391 |
|
| 392 |
addRange: function(range){ |
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
this.addRanges([range]); |
| 402 |
}, |
| 403 |
|
| 404 |
addRanges: function(ranges){ |
| 405 |
|
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
|
| 412 |
|
| 413 |
if(!this._rangeData){ |
| 414 |
this._rangeData = []; |
| 415 |
} |
| 416 |
var range; |
| 417 |
for(var i=0; i<ranges.length; i++){ |
| 418 |
range = ranges[i]; |
| 419 |
if((this.min === null) || (range.low < this.min)){this.min = range.low;} |
| 420 |
if((this.max === null) || (range.high > this.max)){this.max = range.high;} |
| 421 |
|
| 422 |
if(!range.color){ |
| 423 |
var colorIndex = this._rangeData.length % this.defaultColors.length; |
| 424 |
if(gfx.svg && this.useRangeStyles > 0){ |
| 425 |
colorIndex = (this._rangeData.length % this.useRangeStyles)+1; |
| 426 |
range.color = {style: "dojoxGaugeRange"+colorIndex}; |
| 427 |
}else{ |
| 428 |
colorIndex = this._rangeData.length % this.defaultColors.length; |
| 429 |
range.color = this.defaultColors[colorIndex]; |
| 430 |
} |
| 431 |
} |
| 432 |
this._rangeData[this._rangeData.length] = range; |
| 433 |
} |
| 434 |
this.draw(); |
| 435 |
}, |
| 436 |
|
| 437 |
_addScaleTick: function(indicator, major){ |
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
if(!indicator.declaredClass){ |
| 447 |
|
| 448 |
indicator = new this._defaultIndicator(indicator); |
| 449 |
} |
| 450 |
|
| 451 |
indicator._gauge = this; |
| 452 |
if (major){ |
| 453 |
if (!this._majorTicksData){ |
| 454 |
this._majorTicksData = []; |
| 455 |
} |
| 456 |
this._majorTicksData[this._majorTicksData.length] = indicator; |
| 457 |
indicator.draw(this._majorTicksGroup); |
| 458 |
} else { |
| 459 |
if (!this._minorTicksData){ |
| 460 |
this._minorTicksData = []; |
| 461 |
} |
| 462 |
this._minorTicksData[this._minorTicksData.length] = indicator; |
| 463 |
indicator.draw(this._minorTicksGroup); |
| 464 |
} |
| 465 |
return indicator; |
| 466 |
}, |
| 467 |
|
| 468 |
_removeScaleTick: function(indicator){ |
| 469 |
|
| 470 |
|
| 471 |
|
| 472 |
var i; |
| 473 |
if (this._majorTicksData) for (i = 0; i < this._majorTicksData.length; i++){ |
| 474 |
if (this._majorTicksData[i] === indicator){ |
| 475 |
this._majorTicksData.splice(i, 1); |
| 476 |
indicator.remove(); |
| 477 |
return; |
| 478 |
} |
| 479 |
} |
| 480 |
if (this._minorTicksData) for (i = 0; i < this._minorTicksData.length; i++){ |
| 481 |
if (this._minorTicksData[i] === indicator){ |
| 482 |
this._minorTicksData.splice(i, 1); |
| 483 |
indicator.remove(); |
| 484 |
return; |
| 485 |
} |
| 486 |
} |
| 487 |
}, |
| 488 |
|
| 489 |
addIndicator: function(indicator){ |
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
if(!indicator.declaredClass){ |
| 500 |
|
| 501 |
indicator = new this._defaultIndicator(indicator); |
| 502 |
} |
| 503 |
indicator._gauge = this; |
| 504 |
if(!indicator.hideValue){ |
| 505 |
this.containerNode.appendChild(indicator.domNode); |
| 506 |
} |
| 507 |
if(!this._indicatorData){this._indicatorData = [];} |
| 508 |
this._indicatorData[this._indicatorData.length] = indicator; |
| 509 |
indicator.draw(this._indicatorsGroup); |
| 510 |
return indicator; |
| 511 |
}, |
| 512 |
|
| 513 |
removeIndicator: function(indicator){ |
| 514 |
|
| 515 |
|
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
for(var i=0; i<this._indicatorData.length; i++){ |
| 520 |
if(this._indicatorData[i] === indicator){ |
| 521 |
this._indicatorData.splice(i, 1); |
| 522 |
indicator.remove(); |
| 523 |
break; |
| 524 |
} |
| 525 |
} |
| 526 |
}, |
| 527 |
|
| 528 |
moveIndicatorToFront: function(indicator){ |
| 529 |
|
| 530 |
|
| 531 |
|
| 532 |
|
| 533 |
|
| 534 |
|
| 535 |
if(indicator.shape) |
| 536 |
indicator.shape.moveToFront(); |
| 537 |
|
| 538 |
}, |
| 539 |
|
| 540 |
drawText: function( group, txt, x, y, align, color, font){ |
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
|
| 558 |
|
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
var t = group.createText({x: x, y: y, text: txt, align: align}); |
| 563 |
t.setFill(color ? color: 'black'); |
| 564 |
if (font) t.setFont(font); |
| 565 |
return t; |
| 566 |
}, |
| 567 |
|
| 568 |
removeText:function(t){ |
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
if (t.parent) |
| 574 |
t.parent.remove(t); |
| 575 |
}, |
| 576 |
|
| 577 |
updateTooltip: function(txt, e){ |
| 578 |
|
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
if (this.useTooltip) { |
| 584 |
require(["dijit/Tooltip"], dojo.hitch(this, function(Tooltip){ |
| 585 |
if (this._lastHover != txt) { |
| 586 |
if (txt !== '') { |
| 587 |
Tooltip.hide(this.mouseNode); |
| 588 |
Tooltip.show(txt, this.mouseNode, !this.isLeftToRight()); |
| 589 |
} else { |
| 590 |
Tooltip.hide(this.mouseNode); |
| 591 |
} |
| 592 |
this._lastHover = txt; |
| 593 |
} |
| 594 |
})); |
| 595 |
} |
| 596 |
}, |
| 597 |
|
| 598 |
handleMouseOver: function(e){ |
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
|
| 603 |
|
| 604 |
|
| 605 |
if (this.image && this.image.overlay){ |
| 606 |
if (e.target == this._img.getEventSource()){ |
| 607 |
var hover; |
| 608 |
this._overOverlay = true; |
| 609 |
var r = this.getRangeUnderMouse(e); |
| 610 |
if (r && r.hover){ |
| 611 |
hover = r.hover; |
| 612 |
} |
| 613 |
|
| 614 |
if (this.useTooltip && !this._drag){ |
| 615 |
if (hover){ |
| 616 |
this.updateTooltip(hover, e); |
| 617 |
} else { |
| 618 |
this.updateTooltip('', e); |
| 619 |
} |
| 620 |
} |
| 621 |
} |
| 622 |
} |
| 623 |
}, |
| 624 |
|
| 625 |
handleMouseOut: function(e){ |
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
|
| 630 |
|
| 631 |
|
| 632 |
this._overOverlay = false; |
| 633 |
this._hideTooltip(); |
| 634 |
}, |
| 635 |
|
| 636 |
handleMouseMove: function(e){ |
| 637 |
|
| 638 |
|
| 639 |
|
| 640 |
|
| 641 |
|
| 642 |
|
| 643 |
if (this.useTooltip) { |
| 644 |
if (e) { |
| 645 |
html.style(this.mouseNode, 'left', e.pageX + 1 + 'px'); |
| 646 |
html.style(this.mouseNode, 'top', e.pageY + 1 + 'px'); |
| 647 |
} |
| 648 |
if (this._overOverlay) { |
| 649 |
var r = this.getRangeUnderMouse(e); |
| 650 |
if (r && r.hover) { |
| 651 |
this.updateTooltip(r.hover, e); |
| 652 |
} else { |
| 653 |
this.updateTooltip('', e); |
| 654 |
} |
| 655 |
} |
| 656 |
} |
| 657 |
}, |
| 658 |
|
| 659 |
handleMouseDown: function(e){ |
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
|
| 664 |
|
| 665 |
var indicator = this._getInteractiveIndicator(); |
| 666 |
if (indicator){ |
| 667 |
this._handleMouseDownIndicator(indicator, e); |
| 668 |
} |
| 669 |
}, |
| 670 |
|
| 671 |
_handleDragInteractionMouseMove: function(e){ |
| 672 |
|
| 673 |
|
| 674 |
|
| 675 |
|
| 676 |
|
| 677 |
|
| 678 |
if(this._drag){ |
| 679 |
this._dragIndicator(this, e); |
| 680 |
event.stop(e); |
| 681 |
} |
| 682 |
}, |
| 683 |
|
| 684 |
_handleDragInteractionMouseUp: function(e){ |
| 685 |
|
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
|
| 690 |
this._drag = null; |
| 691 |
|
| 692 |
for (var i = 0 ; i < this._mouseListeners.length; i++){ |
| 693 |
connect.disconnect(this._mouseListeners[i]); |
| 694 |
} |
| 695 |
this._mouseListeners = []; |
| 696 |
event.stop(e); |
| 697 |
}, |
| 698 |
|
| 699 |
_handleMouseDownIndicator: function (indicator, e){ |
| 700 |
|
| 701 |
|
| 702 |
|
| 703 |
|
| 704 |
|
| 705 |
|
| 706 |
|
| 707 |
|
| 708 |
if (!indicator.noChange){ |
| 709 |
if (!this._mouseListeners) this._mouseListeners = []; |
| 710 |
this._drag = indicator; |
| 711 |
this._mouseListeners.push(connect.connect(document, "onmouseup", this, this._handleDragInteractionMouseUp)); |
| 712 |
this._mouseListeners.push(connect.connect(document, "onmousemove", this, this._handleDragInteractionMouseMove)); |
| 713 |
this._mouseListeners.push(connect.connect(document, "ondragstart", this, event.stop)); |
| 714 |
this._mouseListeners.push(connect.connect(document, "onselectstart", this, event.stop)); |
| 715 |
this._dragIndicator(this, e); |
| 716 |
event.stop(e); |
| 717 |
} |
| 718 |
}, |
| 719 |
|
| 720 |
_handleMouseOverIndicator: function (indicator, e){ |
| 721 |
|
| 722 |
|
| 723 |
|
| 724 |
|
| 725 |
|
| 726 |
|
| 727 |
|
| 728 |
if (this.useTooltip && !this._drag){ |
| 729 |
|
| 730 |
if (indicator.hover){ |
| 731 |
require(["dijit/Tooltip"], dojo.hitch(this, function(Tooltip){ |
| 732 |
html.style(this.mouseNode, 'left', e.pageX + 1 + 'px'); |
| 733 |
html.style(this.mouseNode, 'top', e.pageY + 1 + 'px'); |
| 734 |
Tooltip.show(indicator.hover, this.mouseNode, !this.isLeftToRight()); |
| 735 |
})); |
| 736 |
} else { |
| 737 |
this.updateTooltip('', e); |
| 738 |
} |
| 739 |
} |
| 740 |
|
| 741 |
if (indicator.onDragMove && !indicator.noChange){ |
| 742 |
this.gaugeContent.style.cursor = 'pointer'; |
| 743 |
} |
| 744 |
}, |
| 745 |
|
| 746 |
_handleMouseOutIndicator: function (indicator, e){ |
| 747 |
|
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
|
| 752 |
|
| 753 |
|
| 754 |
this._hideTooltip(); |
| 755 |
this.gaugeContent.style.cursor = 'pointer'; |
| 756 |
|
| 757 |
}, |
| 758 |
|
| 759 |
_hideTooltip: function(){ |
| 760 |
if (this.useTooltip && this.mouseNode) { |
| 761 |
require(["dijit/Tooltip"], dojo.hitch(this, function(Tooltip){ |
| 762 |
Tooltip.hide(this.mouseNode); |
| 763 |
})); |
| 764 |
} |
| 765 |
}, |
| 766 |
|
| 767 |
_handleMouseOutRange: function ( range, e){ |
| 768 |
this._hideTooltip(); |
| 769 |
}, |
| 770 |
|
| 771 |
_handleMouseOverRange: function (range, e){ |
| 772 |
if (this.useTooltip && !this._drag){ |
| 773 |
if (range.hover) { |
| 774 |
html.style(this.mouseNode, 'left', e.pageX + 1 + 'px'); |
| 775 |
html.style(this.mouseNode, 'top', e.pageY + 1 + 'px'); |
| 776 |
require(["dijit/Tooltip"], dojo.hitch(this, function(Tooltip){ |
| 777 |
Tooltip.show(range.hover, this.mouseNode, !this.isLeftToRight()); |
| 778 |
})); |
| 779 |
} else { |
| 780 |
this.updateTooltip('', e); |
| 781 |
} |
| 782 |
} |
| 783 |
}, |
| 784 |
|
| 785 |
handleTouchStartIndicator: function(indicator, e){ |
| 786 |
|
| 787 |
|
| 788 |
|
| 789 |
|
| 790 |
|
| 791 |
|
| 792 |
|
| 793 |
if (!indicator.noChange){ |
| 794 |
this._drag = indicator; |
| 795 |
event.stop(e); |
| 796 |
} |
| 797 |
}, |
| 798 |
|
| 799 |
handleTouchStart: function(e){ |
| 800 |
|
| 801 |
|
| 802 |
|
| 803 |
|
| 804 |
|
| 805 |
this._drag = this._getInteractiveIndicator(); |
| 806 |
this.handleTouchMove(e); |
| 807 |
}, |
| 808 |
|
| 809 |
handleTouchEnd: function(e){ |
| 810 |
|
| 811 |
|
| 812 |
|
| 813 |
|
| 814 |
|
| 815 |
if (this._drag){ |
| 816 |
this._drag = null; |
| 817 |
event.stop(e); |
| 818 |
} |
| 819 |
}, |
| 820 |
|
| 821 |
handleTouchMove: function(e){ |
| 822 |
|
| 823 |
|
| 824 |
|
| 825 |
|
| 826 |
|
| 827 |
|
| 828 |
if (this._drag && !this._drag.noChange){ |
| 829 |
var touches = e.touches; |
| 830 |
var firstTouch = touches[0]; |
| 831 |
this._dragIndicatorAt(this, firstTouch.pageX, firstTouch.pageY); |
| 832 |
event.stop(e); |
| 833 |
} |
| 834 |
}, |
| 835 |
|
| 836 |
_getInteractiveIndicator: function(){ |
| 837 |
for (var i = 0; i < this._indicatorData.length; i++){ |
| 838 |
var indicator = this._indicatorData[i]; |
| 839 |
if (indicator.interactionMode == "gauge" && !indicator.noChange){ |
| 840 |
return indicator; |
| 841 |
} |
| 842 |
} |
| 843 |
return null; |
| 844 |
} |
| 845 |
}); |
| 846 |
}); |
| 847 |
|