From 0aa48d0503c69c9ebc1d2bb209bfbec10e8bed64 Mon Sep 17 00:00:00 2001 From: Bryan Berry Date: Wed, 17 Feb 2010 09:39:34 +0000 Subject: initial commit. Lesson English_Animal_Identification is current template --- (limited to 'docs/symbols/src/js_ui.feedback.js.html') diff --git a/docs/symbols/src/js_ui.feedback.js.html b/docs/symbols/src/js_ui.feedback.js.html new file mode 100755 index 0000000..4347818 --- /dev/null +++ b/docs/symbols/src/js_ui.feedback.js.html @@ -0,0 +1,144 @@ +
  1 /**
+  2 * @fileOverview a scoreboard widget
+  3 * @author Bryan Berry <bryan@olenepal.org> 
+  4 *  uses MIT License
+  5 */
+  6 
+  7 
+  8 
+  9 (function($){
+ 10 
+ 11      // This is a dummy function, just here as placeholder to
+ 12      // to make the jsdoc tool happy
+ 13      /** @name $.ui.feedback
+ 14       * @namespace Feedback widget
+ 15       */
+ 16      $.ui.feedback = function(){};
+ 17 
+ 18      $.widget('ui.feedback',
+ 19 	      /** @lends $.ui.feedback.prototype */
+ 20 	      {
+ 21 		  /** Displays the correct icon in the center of the screen
+ 22 		   *  and plays the sound "correct" if loaded
+ 23 		   */
+ 24 		  correct: function(){
+ 25 		      var $correct = this.$correct.css('display','block');
+ 26 		      setTimeout ( function() {
+ 27 				       $correct.fadeOut(500);
+ 28 				   }, 500);
+ 29 		      if (Karma && Karma.audio && Karma.audio.correct){
+ 30 			  Karma.audio.correct.play();
+ 31 		      }
+ 32 		      
+ 33 		  },
+ 34 		  /** Displays the incorrect icon in the center of the screen
+ 35 		   *  and plays the sound "incorrect" if loaded
+ 36 		   */
+ 37 		  incorrect: function(){
+ 38 		      
+ 39 		      var $incorrect = this.$incorrect.css('display','block');
+ 40 		      setTimeout ( function() {
+ 41 				       $incorrect.fadeOut(500);
+ 42 				   }, 500);
+ 43 
+ 44 		      //this.$incorrect.css('display','block').fadeOut(3000);
+ 45 		      if (Karma && Karma.audio && Karma.audio.incorrect){
+ 46 			  Karma.audio.incorrect.play();
+ 47 		      }
+ 48 		      
+ 49 		  },
+ 50 		  /** Display a happy face and text that says "You win!"
+ 51 		   * 
+ 52 		   */
+ 53 		  win: function(){
+ 54 		      this.$win.show();
+ 55 		      this.$overlay.show();
+ 56 		  },
+ 57 		  /** Display an unhappy face and text that says "You lose!"
+ 58 		   * 
+ 59 		   */
+ 60 		  lose: function(){
+ 61 		      this.$lose.show();
+ 62 		      this.$overlay.show();
+ 63 		  },
+ 64 		  _init : function(){
+ 65 		      var self = this;
+ 66 		      
+ 67 		      this.element
+ 68 			  .addClass('ui-feedback')
+ 69 			  .css({position:'absolute', 
+ 70 				top: '40%', left: '40%'});
+ 71 		      
+ 72 		      this.$correct = $('<div></div>')
+ 73 			  .addClass('ui-feedback-correct')
+ 74 			  .appendTo(this.element);
+ 75 
+ 76 		      this.$incorrect = $('<div></div>')
+ 77 			  .addClass('ui-feedback-incorrect')
+ 78 			  .appendTo(this.element);
+ 79 		      
+ 80 		      this.$win = $("<div class='ui-feedback-over'>" +
+ 81 				     "<div class='ui-feedback-win'></div>" +
+ 82 				     "<div class='ui-feedback-txt'>You win!" +
+ 83 				     "</div></div>")
+ 84 				    .click(
+ 85 					function(){
+ 86 					    self.$win.hide();
+ 87 					    self.$overlay.hide();
+ 88 					}
+ 89 				    )
+ 90 				    .appendTo(this.element);
+ 91 
+ 92 		      this.$lose = $("<div class='ui-feedback-over'>" +
+ 93 				     "<div class='ui-feedback-lose'></div>" +
+ 94 				     "<div class='ui-feedback-txt'>You lose!" +
+ 95 				     "</div></div>")
+ 96 				     .click(
+ 97 					 function(){
+ 98 					     self.$lose.hide();
+ 99 					     self.$overlay.hide();
+100 					 }
+101 				     )
+102 				     .appendTo(this.element);
+103 		      
+104 		      this.$overlay = $('<div></div>')
+105 			  .addClass('ui-feedback-overlay')
+106 			  .appendTo($('body'));
+107 
+108 		      
+109 
+110 		      $('body')
+111 			  .bind('feedbackCorrect', function(){
+112 				    self.correct();
+113 				})
+114 			  .bind('feedbackIncorrect', function(){
+115 				    self.incorrect();
+116 				});
+117 		     
+118 		  },
+119 		  /** Removes the feedback widget and all related data from the DOM */
+120 		  destroy : function(){
+121 		      this.element.remove();
+122 		      $.widget.prototype.destroy.apply(this, arguments);
+123 		  }
+124 
+125 		  
+126 	      });
+127 
+128 	      $.ui.feedback.getter = [];
+129 		
+130 		/** Default settings for the feedback widget
+131 		 * @namespace Default settings for the feedback widget
+132 		 * @extends $.ui.feedback
+133 		 */			   
+134 	      $.ui.feedback.defaults = {
+135 	      };
+136 
+137  })(jQuery);
\ No newline at end of file -- cgit v0.9.1