1// Name: Rating.RatingBehavior.debug.js 2// Assembly: AjaxControlToolkit 3// Version: 4.1.7.1213 4// FileVersion: 4.1.7.1213 5// (c) 2010 CodePlex Foundation 6 7 8 9/// <reference name="MicrosoftAjax.debug.js" /> 10/// <reference path="../ExtenderBase/BaseScripts.js" /> 11 12(function() { 13var scriptName = "ExtendedRating"; 14 15function execute() { 16 17Type.registerNamespace('Sys.Extended.UI'); 18 19Sys.Extended.UI.RatingBehavior = function(element) { 20 /// <summary> 21 /// The RatingBehavior creates a sequence of stars used to rate an item 22 /// </summary> 23 /// <param name="element" type="Sys.UI.DomElement" domElement="true"> 24 /// DOM element associated with the behavior 25 /// </param> 26 Sys.Extended.UI.RatingBehavior.initializeBase(this, [element]); 27 this._starCssClass = "rating_star"; 28 this._filledStarCssClass = "rating_filled"; 29 this._emptyStarCssClass = "rating_empty"; 30 this._waitingStarCssClass = null; 31 this._isServerControl = false; 32 this._readOnly = false; 33 this._ratingValue = 0; 34 this._currentRating = 0; 35 this._maxRatingValue = 5; 36 this._tag = ""; 37 this._ratingDirection = 0; 38 this._stars = null; 39 this._callbackID = null; 40 this._mouseOutHandler = Function.createDelegate(this, this._onMouseOut); 41 this._starClickHandler = Function.createDelegate(this, this._onStarClick); 42 this._starMouseOverHandler = Function.createDelegate(this, this._onStarMouseOver); 43 this._keyDownHandler = Function.createDelegate(this, this._onKeyDownBack); 44 this._autoPostBack = false; 45} 46Sys.Extended.UI.RatingBehavior.prototype = { 47 initialize : function() { 48 /// <summary> 49 /// Initialize the behavior 50 /// </summary> 51 Sys.Extended.UI.RatingBehavior.callBaseMethod(this, 'initialize'); 52 var elt = this.get_element(); 53 this._stars = []; 54 for (var i = 1; i <= this._maxRatingValue; i++) { 55 starElement = $get(elt.id + '_Star_' + i); 56 starElement.value = i; 57 Array.add(this._stars, starElement); 58 $addHandler(starElement, 'click', this._starClickHandler); 59 $addHandler(starElement, 'mouseover', this._starMouseOverHandler); 60 } 61 $addHandler(elt, 'mouseout', this._mouseOutHandler); 62 $addHandler(elt, "keydown", this._keyDownHandler); 63 this._update(); 64 }, 65 66 dispose : function() { 67 /// <summary> 68 /// Dispose the behavior 69 /// </summary> 70 71 var elt = this.get_element(); 72 if (this._stars) { 73 for (var i = 0; i < this._stars.length; i++) { 74 var starElement = this._stars[i]; 75 $removeHandler(starElement, 'click', this._starClickHandler); 76 $removeHandler(starElement, 'mouseover', this._starMouseOverHandler); 77 } 78 this._stars = null; 79 } 80 $removeHandler(elt, 'mouseout', this._mouseOutHandler); 81 $removeHandler(elt, "keydown", this._keyDownHandler); 82 Sys.Extended.UI.RatingBehavior.callBaseMethod(this, 'dispose'); 83 }, 84 85 _onError : function(message, context) { 86 /// <summary> 87 /// Error handler for the callback 88 /// </summary> 89 /// <param name="message" type="String"> 90 /// Error message 91 /// </param> 92 /// <param name="context" type="Object"> 93 /// Context 94 /// </param> 95 alert(String.format(Sys.Extended.UI.Resources.Rating_CallbackError, message)); 96 }, 97 98 _receiveServerData : function(arg, context) { 99 /// <summary> 100 /// Handler for successful return from callback 101 /// </summary> 102 /// <param name="arg" type="Object"> 103 /// Argument 104 /// </param> 105 /// <param name="context" type="Object"> 106 /// Context 107 /// </param> 108 context._waitingMode(false); 109 context.raiseEndClientCallback(arg); 110 }, 111 112 _onMouseOut : function(e) { 113 /// <summary> 114 /// Handler for a star's mouseout event 115 /// </summary> 116 /// <param name="e" type="Sys.UI.DomEvent"> 117 /// Event info 118 /// </param> 119 120 if (this._readOnly) { 121 return; 122 }
123 this._currentRating = this._ratingValue; 124 this._update(); 125 this.raiseMouseOut(this._currentRating); 126 }, 127 128 _onStarClick : function(e) { 129 /// <summary> 130 /// Handler for a star's click event 131 /// </summary> 132 /// <param name="e" type="Sys.UI.DomEvent"> 133 /// Event info 134 /// </param> 135 if (this._readOnly) { 136 return; 137 } 138 if (this._ratingValue != this._currentRating) { 139 this.set_Rating(this._currentRating); 140 } 141 }, 142 143 _onStarMouseOver : function(e) { 144 /// <summary> 145 /// Handler for a star's mouseover event 146 /// </summary> 147 /// <param name="e" type="Sys.UI.DomEvent"> 148 /// Event info 149 /// </param> 150 if (this._readOnly) { 151 return; 152 } 153 if (this._ratingDirection == 0) { 154 this._currentRating = e.target.value; 155 } else { 156 this._currentRating = this._maxRatingValue + 1 - e.target.value; 157 } 158 this._update(); 159 this.raiseMouseOver(this._currentRating); 160 }, 161 162 163 _onKeyDownBack : function(ev){ 164 /// <summary> 165 /// Handler for a star's keyDown event 166 /// </summary> 167 /// <param name="ev" type="Sys.UI.DomEvent"> 168 /// Event info 169 /// </param> 170 if (this._readOnly) { 171 return; 172 } 173 var k = ev.keyCode ? ev.keyCode : ev.rawEvent.keyCode; 174 if ( (k == Sys.UI.Key.right) || (k == Sys.UI.Key.up) ) { 175 this._currentRating = Math.min(this._currentRating + 1, this._maxRatingValue); 176 this.set_Rating(this._currentRating); 177 ev.preventDefault(); 178 ev.stopPropagation(); 179 } else if ( (k == Sys.UI.Key.left) || (k == Sys.UI.Key.down) ) { 180 this._currentRating = Math.max(this._currentRating - 1, 1); 181 this.set_Rating(this._currentRating); 182 ev.preventDefault(); 183 ev.stopPropagation(); 184 } 185 }, 186 187 _waitingMode : function(activated) { 188 /// <summary> 189 /// Update the display to indicate whether or not we are waiting 190 /// </summary> 191 /// <param name="activated" type="Boolean"> 192 /// Whether or not we are waiting 193 /// </param> 194 195 for (var i = 0; i < this._maxRatingValue; i++) { 196 var starElement; 197 if (this._ratingDirection == 0) { 198 starElement = this._stars[i]; 199 } else { 200 starElement = this._stars[this._maxRatingValue - i - 1]; 201 } 202 if (this._currentRating > i) { 203 if (this._waitingStarCssClass) { 204 if (activated) { 205 Sys.UI.DomElement.removeCssClass(starElement, this._filledStarCssClass); 206 Sys.UI.DomElement.addCssClass(starElement, this._waitingStarCssClass); 207 } 208 else { 209 Sys.UI.DomElement.removeCssClass(starElement, this._waitingStarCssClass); 210 Sys.UI.DomElement.addCssClass(starElement, this._filledStarCssClass); 211 } 212 } 213 } 214 else { 215 if (this._waitingStarCssClass) { 216 Sys.UI.DomElement.removeCssClass(starElement, this._waitingStarCssClass); 217 } 218 Sys.UI.DomElement.removeCssClass(starElement, this._filledStarCssClass); 219 Sys.UI.DomElement.addCssClass(starElement, this._emptyStarCssClass); 220 } 221 } 222 }, 223 224 _update : function() { 225 /// <summary> 226 /// Update the display 227 /// </summary> 228 var elt = this.get_element(); 229 $get(elt.id + "_A").title = this._currentRating; 230 231 for (var i = 0; i < this._maxRatingValue; i++) { 232 var starElement; 233 if (this._ratingDirection == 0) { 234 starElement = this._stars[i]; 235 } else { 236 starElement = this._stars[this._maxRatingValue - i - 1]; 237 } 238 239 if (this._currentRating > i) { 240 Sys.UI.DomElement.removeCssClass(starElement, this._emptyStarCssClass); 241 Sys.UI.DomElement.addCssClass(starElement, this._filledStarCssClass); 242 } 243 else { 244 Sys.UI.DomElement.removeCssClass(starElement, this._filledStarCssClass); 245 Sys.UI.DomElement.addCssClass(starElement, this._emptyStarCssClass); 246 } 247 } 248 }, 249 250 add_Rated : function(handler) { 251 /// <summary> 252 /// Add a handler to the rated event 253 /// </summary> 254 /// <param name="handler" type="Function"> 255 /// Handler 256 /// </param> 257 this.get_events().addHandler("Rated", handler); 258 }, 259 remove_Rated : function(handler) { 260 /// <summary> 261 /// Remove a handler from the rated event 262 /// </summary> 263 /// <param name="handler" type="Function"> 264 /// Handler 265 /// </param> 266 this.get_events().removeHandler("Rated", handler); 267 }, 268 raiseRated : function(rating) { 269 /// <summary> 270 /// Raise the rated event 271 /// </summary> 272 /// <param name="rating" type="Number" integer="true"> 273 /// Rating 274 /// </param> 275 var handler = this.get_events().getHandler("Rated"); 276 if (handler) { 277 handler(this, new Sys.Extended.UI.RatingEventArgs(rating)); 278 } 279 }, 280 281 add_MouseOver : function(handler) { 282 /// <summary> 283 /// Add a handler to the MouseMove event 284 /// </summary> 285 /// <param name="handler" type="Function"> 286 /// Handler 287 /// </param> 288 this.get_events().addHandler("MouseOver", handler); 289 }, 290 remove_MouseOver : function(handler) { 291 /// <summary> 292 /// Remove a handler from the MouseOver event 293 /// </summary> 294 /// <param name="handler" type="Function"> 295 /// Handler 296 /// </param> 297 this.get_events().removeHandler("MouseOver", handler); 298 }, 299 raiseMouseOver : function(rating_tmp) { 300 /// <summary> 301 /// Raise the MouseOver event 302 /// </summary> 303 /// <param name="eventArgs" type=""> 304 /// eventArgs 305 /// </param> 306 var handler = this.get_events().getHandler("MouseOver"); 307 if (handler) { 308 handler(this, new Sys.Extended.UI.RatingEventArgs(rating_tmp)); 309 } 310 }, 311 312 add_MouseOut : function(handler) { 313 /// <summary> 314 /// Add a handler to the MouseOut event 315 /// </summary> 316 /// <param name="handler" type="Function"> 317 /// Handler 318 /// </param> 319 this.get_events().addHandler("MouseOut", handler); 320 }, 321 remove_MouseOut : function(handler) { 322 /// <summary> 323 /// Remove a handler from the MouseOut event 324 /// </summary> 325 /// <param name="handler" type="Function"> 326 /// Handler 327 /// </param> 328 this.get_events().removeHandler("MouseOut", handler); 329 }, 330 raiseMouseOut : function(rating_old) { 331 /// <summary> 332 /// Raise the MouseOut event 333 /// </summary> 334 /// <param name="eventArgs" type=""> 335 /// eventArgs 336 /// </param> 337 var handler = this.get_events().getHandler("MouseOut"); 338 if (handler) { 339 handler(this, new Sys.Extended.UI.RatingEventArgs(rating_old)); 340 } 341 }, 342 343 add_EndClientCallback : function(handler) { 344 /// <summary> 345 /// Add a handler to the EndClientCallback event 346 /// </summary> 347 /// <param name="handler" type="Function"> 348 /// Handler 349 /// </param> 350 this.get_events().addHandler("EndClientCallback", handler); 351 }, 352 remove_EndClientCallback : function(handler) { 353 /// <summary> 354 /// Remove a handler from the EndClientCallback event 355 /// </summary> 356 /// <param name="handler" type="Function"> 357 /// Handler 358 /// </param> 359 this.get_events().removeHandler("EndClientCallback", handler); 360 }, 361 raiseEndClientCallback : function(result) { 362 /// <summary> 363 /// Raise the EndClientCallback event 364 /// </summary> 365 /// <param name="result" type="String"> 366 /// Callback result 367 /// </param> 368 var handler = this.get_events().getHandler("EndClientCallback"); 369 if (handler) { 370 handler(this, new Sys.Extended.UI.RatingCallbackResultEventArgs(result)); 371 } 372 }, 373 374 get_AutoPostBack : function() { 375 return this._autoPostBack; 376 }, 377 378 set_AutoPostBack : function(value) { 379 this._autoPostBack = value; 380 }, 381 382 get_Stars : function() { 383 /// <value type="Array" elementType="Sys.UI.DomElement" elementDomElement="true"> 384 /// Elements for the displayed stars 385 /// </value> 386 return this._stars; 387 }, 388 389 get_Tag : function() { 390 /// <value type="String"> 391 /// A custom parameter to pass to the ClientCallBack 392 /// </value> 393 return this._tag; 394 }, 395 set_Tag : function(value) { 396 if (this._tag != value) { 397 this._tag = value; 398 this.raisePropertyChanged('Tag'); 399 } 400 }, 401 402 get_CallbackID : function() { 403 /// <value type="String"> 404 /// ID of the ClientCallBack 405 /// </value> 406 return this._callbackID; 407 }, 408 set_CallbackID : function(value) { 409 this._callbackID = value; 410 }, 411 412 get_RatingDirection : function() { 413 /// <value type="Number" integer="true"> 414 /// RatingDirection - Orientation of the stars (LeftToRightTopToBottom or RightToLeftBottomToTop) 415 /// </value> 416 /// TODO: We should create an enum for this 417 return this._ratingDirection; 418 }, 419 set_RatingDirection : function(value) { 420 if (this._ratingDirection != value) { 421 this._ratingDirection = value; 422 if (this.get_isInitialized()) { 423 this._update(); 424 } 425 this.raisePropertyChanged('RatingDirection'); 426 } 427 }, 428 429 get_EmptyStarCssClass : function() { 430 /// <value type="String"> 431 /// CSS class for a star in empty mode 432 /// </value> 433 return this._emptyStarCssClass; 434 }, 435 set_EmptyStarCssClass : function(value) { 436 if (this._emptyStarCssClass != value) { 437 this._emptyStarCssClass = value; 438 this.raisePropertyChanged('EmptyStarCssClass'); 439 } 440 }, 441 442 get_FilledStarCssClass : function() { 443 /// <value type="String"> 444 /// CSS class for star in filled mode 445 /// </value> 446 return this._filledStarCssClass; 447 }, 448 set_FilledStarCssClass : function(value) { 449 if (this._filledStarCssClass != value) { 450 this._filledStarCssClass = value; 451 this.raisePropertyChanged('FilledStarCssClass'); 452 } 453 }, 454 455 get_WaitingStarCssClass : function() { 456 /// <value type="String">
457 /// CSS class for a star in waiting mode 458 /// </value> 459 return this._waitingStarCssClass; 460 }, 461 set_WaitingStarCssClass : function(value) { 462 if (this._waitingStarCssClass != value) { 463 this._waitingStarCssClass = value; 464 this.raisePropertyChanged('WaitingStarCssClass'); 465 } 466 }, 467 468 get_Rating : function() { 469 /// <value type="Number" integer="true"> 470 /// Current rating value 471 /// </value> 472 var hiddenValue = Sys.Extended.UI.RatingBehavior.callBaseMethod(this, 'get_ClientState'); 473 if (hiddenValue !== null && hiddenValue.length) { 474 this._ratingValue = hiddenValue 475 } 476 if (this._ratingValue == '') 477 this._ratingValue = null; 478 return this._ratingValue; 479 }, 480 set_Rating : function(value) { 481 if (this._ratingValue != value) { 482 this._ratingValue = value; 483 this._currentRating = value; 484 if (this.get_isInitialized()) { 485 if ((value < 0) || (value > this._maxRatingValue)) { 486 return; 487 } 488 489 this._update(); 490 491 Sys.Extended.UI.RatingBehavior.callBaseMethod(this, 'set_ClientState', [ this._ratingValue ]); 492 this.raisePropertyChanged('Rating'); 493 this.raiseRated(this._currentRating); 494 495 if (this._isServerControl) { 496 this._waitingMode(true); 497 498 var args = this._currentRating + ";" + this._tag; 499 var id = this._callbackID; 500 501 if (this._autoPostBack) { 502 __doPostBack(id, args); 503 } 504 else { 505 WebForm_DoCallback(id, args, this._receiveServerData, this, this._onError, true) 506 } 507 } 508 } 509 } 510 }, 511 512 get_MaxRating : function() { 513 /// <value type="Number" integer="true"> 514 /// Maximum rating value 515 /// </value> 516 return this._maxRatingValue; 517 }, 518 set_MaxRating : function(value) { 519 if (this._maxRatingValue != value) { 520 this._maxRatingValue = value; 521 this.raisePropertyChanged('MaxRating'); 522 } 523 }, 524 525 get_ReadOnly : function() { 526 /// <value type="Boolean"> 527 /// Whether or not the rating can be changed 528 /// </value> 529 return this._readOnly; 530 }, 531 set_ReadOnly : function(value) { 532 if (this._readOnly != value) { 533 this._readOnly = value; 534 this.raisePropertyChanged('ReadOnly'); 535 } 536 }, 537 538 get_StarCssClass : function() { 539 /// <value type="String"> 540 /// CSS class for a visible star 541 /// </value> 542 return this._starCssClass; 543 }, 544 set_StarCssClass : function(value) { 545 if (this._starCssClass != value) { 546 this._starCssClass = value; 547 this.raisePropertyChanged('StarCssClass'); 548 } 549 } 550} 551Sys.Extended.UI.RatingBehavior.registerClass('Sys.Extended.UI.RatingBehavior', Sys.Extended.UI.BehaviorBase); 552Sys.registerComponent(Sys.Extended.UI.RatingBehavior, { name: "rating" }); 553 554Sys.Extended.UI.RatingEventArgs = function(rating) { 555 /// <summary> 556 /// Event arguments for the RatingBehavior's rated event 557 /// </summary> 558 /// <param name="rating" type="Number" integer="true"> 559 /// Rating 560 /// </param> 561 Sys.Extended.UI.RatingEventArgs.initializeBase(this); 562 563 this._rating = rating; 564} 565Sys.Extended.UI.RatingEventArgs.prototype = { 566 get_Rating : function() { 567 /// <value type="Number" integer="true"> 568 /// Rating 569 /// </value> 570 return this._rating; 571 } 572} 573Sys.Extended.UI.RatingEventArgs.registerClass('Sys.Extended.UI.RatingEventArgs', Sys.EventArgs); 574 575 576Sys.Extended.UI.RatingCallbackResultEventArgs = function(result) { 577 /// <summary> 578 /// Event arguments for the RatingBehavior's EndClientCallback event 579 /// </summary> 580 /// <param name="result" type="Object"> 581 /// Callback result 582 /// </param> 583 Sys.Extended.UI.RatingCallbackResultEventArgs.initializeBase(this); 584 585 this._result = result; 586} 587Sys.Extended.UI.RatingCallbackResultEventArgs.prototype = { 588 get_CallbackResult : function() { 589 /// <value type="Object"> 590 /// Callback result 591 /// </value> 592 return this._result; 593 } 594} 595Sys.Extended.UI.RatingCallbackResultEventArgs.registerClass('Sys.Extended.UI.RatingCallbackResultEventArgs', Sys.EventArgs); 596 597} // execute 598 599if (window.Sys && Sys.loader) { 600 Sys.loader.registerScript(scriptName, ["ExtendedBase"], execute); 601} 602else { 603 execute(); 604} 605 606})();
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.