1var rdc = rdc || {}; 2var cjs = createjs; 3var p; 4 5var firefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1; 6if (firefox && createjs) 7{ 8 createjs.Text.prototype._drawTextLine = function(ctx, text, y) 9 { 10 // Adjust text position only if textBaseline is "top" 11 if (this.textBaseline === "top") 12 { 13 var lineHeight = this.lineHeight || this.getMeasuredLineHeight(); 14 y += lineHeight * 0.2; 15 } 16 // Chrome 17 will fail to draw the text if the last param is included but null, so we feed it a large value instead: 17 if (this.outline) { ctx.strokeText(text, 0, y, this.maxWidth||0xFFFF); } 18 else { ctx.fillText(text, 0, y, this.maxWidth||0xFFFF); } 19 }; 20} 21Object.defineProperties(rdc, { 22 ObjectDelegate:{ 23 value:function(displayObject){ 24 this.object = displayObject; 25 this.object.delegate = this; 26 this.object.on("tick", this.initialize, this, true); 27 } 28 }, 29 ButtonDelegate:{ 30 value:function(displayObject){ 31 rdc.ObjectDelegate.call(this, displayObject); 32 } 33 }, 34 SwitchDelegate:{ 35 value:function(displayObject){ 36 rdc.ObjectDelegate.call(this, displayObject); 37 } 38 }, 39 StepperDelegate:{ 40 value:function(displayObject){ 41 rdc.ObjectDelegate.call(this, displayObject); 42 } 43 }, 44 InputDelegate:{ 45 value:function(textInput){ 46 this.input = textInput._element._$this[0]; 47 } 48 }, 49 PickerListDelegate:{ 50 value:function(displayObject){ 51 rdc.ButtonDelegate.call(this, displayObject); 52 } 53 }, 54 PickerCellDelegate:{ 55 value:function(displayObject){ 56 rdc.ObjectDelegate.call(this, displayObject); 57 } 58 }, 59 PickerButtonDelegate:{ 60 value:function(displayObject){ 61 rdc.ButtonDelegate.call(this, displayObject); 62 } 63 }, 64 DataEvent:{ 65 value:function(type, data, bubbles){ 66 cjs.Event.call(this, type, bubbles); 67 this.data = data; 68 } 69 } 70}); 71//Locale 72rdc.Locale = rdc.L = rdc.Locale||(function(){ 73 var loadFunc = function(path){ 74 var self = this; 75 var loader = new cjs.LoadQueue(true); 76 loader.on("fileload", function(e){ 77 self.strings = loader.getResult("strings"); 78 self.change(self.EN); 79 self.dispatcher.dispatchEvent("complete"); 80 }); 81 loader.loadFile({id:"strings", type:"jsonp", src:path, callback:"getData"}); 82 } 83 var getFunc = function(localizationID){ 84 return this.strings ? this.strings[localizationID][this.current] : ""; 85 } 86 var registerFunc = function(observer){ 87 if(this.observers.indexOf(observer) > -1){ return; } 88 this.observers.push(observer); 89 } 90 var unregisterFunc = function(observer){ 91 var index = this.observers.indexOf(observer); 92 if(index == -1){ return; } 93 this.observers.splice(index, 1); 94 } 95 var changeFunc = function(value){ 96 this.current = value; 97 for (var i = 0; i < this.observers.length; i++) { 98 this.observers[i].updateLocale(); 99 } 100 } 101 return {load:loadFunc, get:getFunc, register:registerFunc, unregister:unregisterFunc, change:changeFunc, dispatcher:new cjs.EventDispatcher(), observers:[], EN:"en", EL:"el", ES:"es", DE:"de", IT:"it", FR:"fr"}; 102})(); 103//Object 104 105p = cjs.extend(rdc.ObjectDelegate, cjs.EventDispatcher); 106 107Object.defineProperties(p, { 108 initialize:{ 109 value:function(){ 110 if(this.object.initWithContent){ 111 this.object.initWithContent(); 112 } 113 //performance benefit 114 this.object.tickEnabled = false; 115 } 116 }, 117 localizationID:{ 118 set:function(value){ 119 this._localizationID = value; 120 rdc.L.register(this); 121 this.updateLocale(); 122 }, 123 get:function(){ 124 return this._localizationID; 125 } 126 }, 127 updateLocale:{ 128 value:function(){} 129 }, 130 visible:{ 131 get:function(){ 132 return this.object.visible; 133 }, 134 set:function(value){ 135 this.object.visible = value; 136 } 137 }, 138 destroy:{ 139 value:function(){ 140 if(this.object.children){ 141 for(var child in this.object.children){ 142 child.removeAllEventListeners(); 143 if(child.destroy){ 144 child.destroy(); 145 } 146 } 147 } 148 if(this.localizationID){ 149 rdc.L.unregister(this); 150 } 151 this.object.removeAllEventListeners(); 152 this.object = null; 153 } 154 }, 155 toString:{ 156 value:function(){ 157 return "[rdc.ObjectDelegate]"; 158 } 159 } 160}); 161 162//Button 163rdc.Button = rdc.Button||(function(){ 164 return {UP:0, DOWN:1, DISABLED:2}; 165})(); 166 167p = cjs.extend(rdc.ButtonDelegate, rdc.ObjectDelegate); 168 169Object.defineProperties(p, { 170 initialize:{ 171 value:function(){ 172 this.state = rdc.Button.DISABLED; 173 this.longPressInterval; 174 rdc.ObjectDelegate.prototype.initialize.call(this); 175 } 176 }, 177 activate:{ 178 value:function(){ 179 if(this.isActivated == true){ return; } 180 this.object.on("mousedown", this.pressed, this, true); 181 this.object.cursor = "pointer"; 182 this.isActivated = true; 183 } 184 }, 185 deactivate:{ 186 value:function(){ 187 if(this.isActivated == false){ return; } 188 this.object.removeAllEventListeners("pressup"); 189 this.object.removeAllEventListeners("mousedown"); 190 this.object.cursor = null; 191 this.isActivated = false; 192 } 193 }, 194 pressed:{ 195 value:function(e){
196 this.state = this._state === rdc.Button.UP ? rdc.Button.DOWN:rdc.Button.UP; 197 this.object.removeAllEventListeners("mousedown"); 198 this.object.on("pressup", this.released, this, true); 199 this.dispatchEvent("pressed"); 200 if(this.longPress){ 201 var self = this; 202 this.longPressInterval = window.setInterval(function(){ 203 self.dispatchEvent("released"); 204 }, 64); 205 } 206 } 207 }, 208 released:{ 209 value:function(e){ 210 if(!this.isToggle){ 211 this.state = rdc.Button.UP; 212 } 213 this.object.removeAllEventListeners("pressup"); 214 this.object.on("mousedown", this.pressed, this, true); 215 this.dispatchEvent("released"); 216 if(this.longPress){ 217 window.clearInterval(this.longPressInterval); 218 } 219 } 220 }, 221 state:{ 222 set:function(newState){ 223 if(this._state === newState){ return; } 224 this._state = newState; 225 for(var i = 0; i < 3; i++){ 226 this.object.children[i].visible = (i == this._state); 227 } 228 this._state != rdc.Button.DISABLED ? this.activate():this.deactivate(); 229 }, 230 get:function(){ 231 return this._state; 232 } 233 }, 234 label:{ 235 get:function(){ 236 if(!this.field){ 237 this.field = this.object.getChildAt(this.object.children.length - 1); 238 } 239 return this.field; 240 } 241 }, 242 text:{ 243 set:function(value){ 244 this.label.text = value; 245 var metrics = this.label.getMetrics(); 246 if(metrics.lines.length > 1){ 247 this.text = metrics.lines[0] + "..."; 248 } 249 }, 250 get:function(){ return this.label.text; } 251 }, 252 updateLocale:{ 253 value:function(){ 254 this.text = rdc.L.get(this.localizationID); 255 } 256 }, 257 toString:{ 258 value:function(){ 259 return "[rdc.ButtonDelegate]"; 260 } 261 } 262}); 263 264//Switch 265 266p = cjs.extend(rdc.SwitchDelegate, rdc.ObjectDelegate); 267/* 268 props: tweenDuration, buttonBounds[on|off] 269*/ 270Object.defineProperties(p, { 271 initialize:{ 272 value:function(){ 273 rdc.ObjectDelegate.prototype.initialize.call(this); 274 this.tweenDuration = .2; 275 this.object.cursor = "pointer"; 276 this.button = this.object.getChildAt(2); 277 this.object.on("click", this.toggle, this); 278 } 279 }, 280 toggle:{ 281 value:function(){ 282 this.isOn ? this.switchOff() : this.switchOn(); 283 } 284 }, 285 animate:{ 286 value:function(){ 287 TweenLite.to(this.button, this.tweenDuration, { 288 x:this.isOn ? this.buttonBounds.on : this.buttonBounds.off, 289 onComplete:this.notify, 290 onCompleteParams:[this] 291 }); 292 } 293 }, 294 switchOff:{ 295 value:function(){ 296 this.isOn = false; 297 this.animate(); 298 } 299 }, 300 switchOn:{ 301 value:function(){ 302 this.isOn = true; 303 this.animate(); 304 } 305 }, 306 notify:{ 307 value:function(self){ 308 self.dispatchEvent("changed"); 309 } 310 }, 311 toString:{ 312 value:function(){ 313 return "[rdc.SwitchDelegate]"; 314 } 315 } 316}) 317 318//Stepper 319 320p = cjs.extend(rdc.StepperDelegate, rdc.ObjectDelegate); 321/* 322 props: range[min|max], initial 323*/ 324Object.defineProperties(p, { 325 initialize:{ 326 value:function(){ 327 rdc.ObjectDelegate.prototype.initialize.call(this); 328 this.field = this.object.getChildAt(1); 329 this.minusButton = this.object.getChildAt(2).delegate; 330 this.plusButton = this.object.getChildAt(3).delegate; 331 332 this.field.text = this.initial; 333 this.minusButton.longPress = true; 334 this.plusButton.longPress = true; 335 this.minusButton.on("released", this.updateValue, this); 336 this.plusButton.on("released", this.updateValue, this); 337 } 338 }, 339 updateValue:{ 340 value:function(e){ 341 var val = this.value; 342 if(e.currentTarget == this.plusButton) 343 { 344 if(val < this.range.max){ 345 this.value = val + 1; 346 } 347 } 348 else{ 349 if(val > this.range.min){ 350 this.value = val - 1; 351 } 352 } 353 } 354 }, 355 value:{ 356 get:function(){ 357 return parseInt(this.field.text); 358 }, 359 set:function(val){ 360 if(this.range && val > this.range.max){ val = this.range.max } 361 else if(this.range && val < this.range.min){ val = this.range.min } 362 this.field.text = val.toString(); 363 } 364 }, 365 reset:{ 366 value:function(){ 367 this.value = this.initial; 368 } 369 }, 370 toString:{ 371 value:function(){ 372 return "[rdc.StepperDelegate]"; 373 } 374 } 375}); 376 377//PickerList 378 379p = cjs.extend(rdc.PickerListDelegate, rdc.ObjectDelegate); 380 381Object.defineProperties(p, { 382 initialize:{ 383 value:function(){ 384 rdc.ObjectDelegate.prototype.initialize.call(this); 385 rdc.PickerListDelegate.shared = this; 386 this.cells = []; 387 var children = this.object.children; 388 for (var i = 0; i < children.length; i++) { 389 if(i == children.length - 1){ 390 this.downButton = children[i].delegate; 391 this.downButton.on("released", this.buttonClicked, this); 392 } 393 else if(i == children.length - 2){ 394 this.upButton = children[i].delegate; 395 this.upButton.on("released", this.buttonClicked, this); 396 } 397 else if(children[i].delegate instanceof rdc.ButtonDelegate){ 398 this.cells.push(children[i].delegate); 399 children[i].delegate.on("released", this.cellSelected, this); 400 } 401 else if(i == 0){
402 this.overlay = children[i]; 403 this.overlay.on("click", this.overlayClicked, this); 404 } 405 else if(i == 1){ 406 children[i].shadow = new createjs.Shadow("#CCCCCC", 0, 0, 40); 407 } 408 } 409 this.isScrollEnabled = true; 410 this.visible = false; 411 } 412 }, 413 buttonClicked:{ 414 value:function(e){ 415 if(!this.isScrollEnabled){ return; } 416 if(e.currentTarget == this.downButton){ 417 if(this.pointer <= this.data.length - this.cells.length){ 418 this.pointer++; 419 if(this.movedUp){ 420 this.swapCells(true); 421 this.updateCells(-1); 422 } 423 this.movedUp = true; 424 this.animateCells(-1); 425 } 426 } 427 else{ 428 if(this.pointer > 0){ 429 this.pointer--; 430 if(!this.movedUp){ 431 this.swapCells(false); 432 this.updateCells(); 433 } 434 this.movedUp = false; 435 this.animateCells(1); 436 } 437 } 438 } 439 }, 440 swapCells:{ 441 value:function(firstToLast){ 442 if(firstToLast){ 443 this.cells[0].object.y = this.cells[this.cells.length - 1].object.y + this.cells[0].boundHeight; 444 this.cells.push(this.cells.shift()); 445 } 446 else{ 447 this.cells[this.cells.length - 1].object.y = this.cells[0].object.y - this.cells[0].boundHeight; 448 this.cells.unshift(this.cells.pop()); 449 } 450 } 451 }, 452 updateCells:{ 453 value:function(step){ 454 var dataIndex; 455 if(step === undefined){step = 0;} 456 for(var i = 0; i < this.cells.length; i++){ 457 if(i > this.data.length - 1){ 458 this.cells[i].visible = false; 459 continue; 460 } 461 else{ 462 this.cells[i].visible = true; 463 } 464 dataIndex = this.pointer + i + step; 465 if(dataIndex == this.selectedIndex){ 466 this.cells[i].label.color = this.colors.selected; 467 } 468 else{ 469 this.cells[i].label.color = this.colors.default; 470 } 471 this.cells[i].data = this.data[dataIndex]; 472 } 473 } 474 }, 475 animateCells:{ 476 value:function(factor){ 477 var cell; 478 var self = this; 479 this.isScrollEnabled = false; 480 for(var i = 0; i < this.cells.length; i++){ 481 cell = this.cells[i]; 482 TweenLite.to(cell.object, .2, { 483 y:cell.object.y + (cell.boundHeight * factor), 484 onComplete:function(){ self.isScrollEnabled = true; } 485 }); 486 } 487 } 488 }, 489 overlayClicked:{ 490 value:function(){ 491 this.close(); 492 this.dispatchEvent(new rdc.DataEvent("select")); 493 } 494 }, 495 cellSelected:{ 496 value:function(e){ 497 this.close(); 498 this.dispatchEvent(new rdc.DataEvent("select", e.currentTarget.data)); 499 } 500 }, 501 open:{ 502 value:function(data, selectedIndex){ 503 this.pointer = 0; 504 this.data = data; 505 this.selectedIndex = selectedIndex; 506 this.updateCells(); 507 this.visible = true; 508 } 509 }, 510 close:{ 511 value:function(){ 512 this.visible = false; 513 if(this.movedUp){ 514 this.swapCells(true); 515 this.movedUp = false; 516 } 517 } 518 }, 519 toString:{ 520 value:function(){ 521 return "[rdc.PickerListDelegate]"; 522 } 523 } 524}); 525 526//PickerCell 527 528p = cjs.extend(rdc.PickerCellDelegate, rdc.ButtonDelegate); 529 530Object.defineProperties(p, { 531 initialize:{ 532 value:function(){ 533 rdc.ButtonDelegate.prototype.initialize.call(this); 534 } 535 }, 536 data:{ 537 set:function(value){ 538 this._data = value; 539 this.label.text = this.data.isLocalized ? rdc.L.get(this.data.text) : this.data.text; 540 }, 541 get:function(){ 542 return this._data; 543 } 544 }, 545 updateLocale:{ 546 value:function(){} 547 } 548}); 549 550//PickerButton 551 552p = cjs.extend(rdc.PickerButtonDelegate, rdc.ButtonDelegate); 553 554Object.defineProperties(p, { 555 initialize:{ 556 value:function(){ 557 rdc.ButtonDelegate.prototype.initialize.call(this); 558 this.selectedIndex = -1; 559 this.prefix = null; 560 this.updateLabel(); 561 } 562 }, 563 pressed:{ 564 value:function(e){ 565 rdc.ButtonDelegate.prototype.pressed.call(this, e); 566 rdc.PickerListDelegate.shared.on("select", this.listOptionSelected, this, true); 567 rdc.PickerListDelegate.shared.open(this.data, this.selectedIndex); 568 } 569 }, 570 listOptionSelected:{ 571 value:function(e){ 572 if(e.data){ 573 this.updateLabel(e.data); 574 this.selectedIndex = this.data.indexOf(e.data); 575 this.dispatchEvent(new rdc.DataEvent("change", e.data)); 576 } 577 } 578 }, 579 updateLabel:{ 580 value:function(value){ 581 if(!value){ 582 this.text = this.prompt; 583 this.selectedIndex = -1; 584 } 585 else{ 586 if(this.localizationID){ 587 var str = value.isLocalized ? rdc.L.get(value.text) : value.text; 588 this.label.text = this.prefix ? rdc.L.get(this.prefix) + str : str; 589 } 590 else{ 591 this.text = this.prefix ? this.prefix + value.text : value.text; 592 } 593 } 594 } 595 }, 596 updateLocale:{ 597 value:function(){ 598 if(this.selectedIndex > -1){ 599 this.updateLabel(this.data[this.selectedIndex]); 600 } 601 else{ 602 this.updateLabel(); 603 } 604 } 605 }, 606 prompt:{ 607 set:function(value){ 608 this._prompt = value; 609 this.updateLabel(); 610 }, 611 get:function(){ 612 return this.localizationID ? rdc.L.get(this._prompt) : this._prompt; 613 } 614 }, 615 selectedIndex:{
616 set:function(value){ 617 this._selectedIndex = value; 618 if(this.selectedIndex < 0){ 619 this.text = this.prompt; 620 } 621 else{ 622 this.updateLabel(this.data[this.selectedIndex]); 623 } 624 }, 625 get:function(){ 626 return this._selectedIndex; 627 } 628 }, 629 selectedItem:{ 630 get:function(){ 631 return this.selectedIndex > -1 ? this.data[this.selectedIndex] : null; 632 } 633 } 634}); 635 636//DataEvent 637 638p = cjs.extend(rdc.DataEvent, cjs.Event); 639 640//TextInput 641 642p = cjs.extend(rdc.InputDelegate, cjs.EventDispatcher); 643 644Object.defineProperties(p, { 645 style:{ 646 set:function(value){ 647 for(var prop in value){ 648 this.input.style[prop] = value[prop]; 649 } 650 }, 651 get:function(){return this.input.style;} 652 }, 653 text:{ 654 set:function(value){ 655 this.input.value = value; 656 }, 657 get:function(){ 658 return this.input.value; 659 } 660 }, 661 visible:{ 662 set:function(value){ 663 this.input.style.display = value ? "block" : "none"; 664 }, 665 get:function(){ 666 return this.input.style.display == "block"; 667 } 668 }, 669 toString:{ 670 value:function(){ 671 return "[rdc.InputDelegate]"; 672 } 673 } 674}); 675 676p = null;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.