Advertisement
KeplerBR

[roBrowser] Don't add the same SkillDescription twice

Sep 12th, 2014
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.46 KB | None | 0 0
  1.  src/UI/Components/ShortCut/ShortCut.js                 |  9 +++++++--
  2.  src/UI/Components/SkillDescription/SkillDescription.js | 13 +++++++++++++
  3.  src/UI/Components/SkillList/SkillList.js               |  7 +++++++
  4.  3 files changed, 27 insertions(+), 2 deletions(-)
  5.  
  6. diff --git a/src/UI/Components/ShortCut/ShortCut.js b/src/UI/Components/ShortCut/ShortCut.js
  7. index ba61833..5b74c56 100644
  8. --- a/src/UI/Components/ShortCut/ShortCut.js
  9. +++ b/src/UI/Components/ShortCut/ShortCut.js
  10. @@ -455,8 +455,13 @@ define(function(require)
  11.  
  12.         // Display skill informations
  13.         if (element.isSkill) {
  14. -           SkillDescription.append();
  15. -           SkillDescription.setSkill( _list[index].ID );
  16. +           if (SkillDescription.uid === _list[index].ID) {
  17. +               SkillDescription.remove();
  18. +           }
  19. +           else {
  20. +               SkillDescription.append();
  21. +               SkillDescription.setSkill( _list[index].ID );
  22. +           }
  23.         }
  24.  
  25.         // Display item informations
  26. diff --git a/src/UI/Components/SkillDescription/SkillDescription.js b/src/UI/Components/SkillDescription/SkillDescription.js
  27. index 4775206..b5279fe 100644
  28. --- a/src/UI/Components/SkillDescription/SkillDescription.js
  29. +++ b/src/UI/Components/SkillDescription/SkillDescription.js
  30. @@ -33,6 +33,11 @@ define(function(require)
  31.  
  32.  
  33.     /**
  34. +    * @var {number} SkillDescription unique id
  35. +    */
  36. +   SkillDescription.uid = -1;
  37. +
  38. +   /**
  39.      * Once append to the DOM
  40.      */
  41.     SkillDescription.onKeyDown = function onKeyDown( event )
  42. @@ -57,6 +62,13 @@ define(function(require)
  43.         events.unshift( events.pop() );
  44.     };
  45.  
  46. +   /**
  47. +    * Once removed from html
  48. +    */
  49. +   SkillDescription.onRemove = function onRemove()
  50. +   {
  51. +       this.uid = -1;
  52. +   };
  53.  
  54.     /**
  55.      * Initialize UI
  56. @@ -78,6 +90,7 @@ define(function(require)
  57.      */
  58.     SkillDescription.setSkill = function setSkill( id )
  59.     {
  60. +       this.uid = id;
  61.         this.ui.find('.content').text(SkillDB[id] || '...');
  62.  
  63.         this.ui.css({
  64. diff --git a/src/UI/Components/SkillList/SkillList.js b/src/UI/Components/SkillList/SkillList.js
  65. index 5147059..6025577 100644
  66. --- a/src/UI/Components/SkillList/SkillList.js
  67. +++ b/src/UI/Components/SkillList/SkillList.js
  68. @@ -521,6 +521,13 @@ define(function(require)
  69.  
  70.         skill = getSkillById(parseInt(main.data('index'), 10));
  71.  
  72. +       // Don't add the same UI twice, remove it
  73. +       if (SkillDescription.uid === skill.SKID) {
  74. +           SkillDescription.remove();
  75. +           return false;
  76. +       }
  77. +      
  78. +       // Add ui to window
  79.         SkillDescription.append();
  80.         SkillDescription.setSkill(skill.SKID);
  81.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement