Skip to content
This repository

feat #985 MultiAutoComplete: Public methods for highlight class #985

Closed
wants to merge 1 commit into from

3 participants

Srinath M jakub-g Francesco Longo
Srinath M
Collaborator

This pull request adds public methods for adding, removing and getting highlighted suggestions for multiautocomplete widget

src/aria/widgets/form/Input.js
... ...
@@ -364,7 +364,6 @@ Aria.classDefinition({
364 364
                 // environment
365 365
                 cfg.directOnBlurValidation = aria.widgets.environment.WidgetSettings.getWidgetSettings().directOnBlurValidation;
366 366
             }
367  
-
1
Francesco Longo Collaborator
flongo added a note February 21, 2014

If there is no real change, I think it is better to revert this file to its previous version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
src/aria/widgets/form/MultiAutoComplete.js
... ...
@@ -360,6 +360,95 @@ Aria.classDefinition({
360 360
             this.setProperty("value", newSuggestions);
361 361
             this._textInputField.style.width = "0px";
362 362
             this.__resizeInput();
  363
+        },
  364
+        /**
  365
+         * To remove the highlight class from the suggestion(s)
  366
+         * @param {MultiTypes} i It can be an array of indices of suggestions or an index of suggestion. If nothing is
  367
+         * provided it will remove the highlight class from all the highlighted suggestions
  368
+         * @public
  369
+         */
  370
+        removeHighlight : function (i) {
  371
+            var suggestionContainer = this._textInputField.parentNode;
  372
+            var typeUtil = aria.utils.Type;
  373
+            if (!i) {
1
Francesco Longo Collaborator
flongo added a note February 21, 2014

What if i is equal to 0?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
src/aria/widgets/form/MultiAutoComplete.js
((4 lines not shown))
  363
+        },
  364
+        /**
  365
+         * To remove the highlight class from the suggestion(s)
  366
+         * @param {MultiTypes} i It can be an array of indices of suggestions or an index of suggestion. If nothing is
  367
+         * provided it will remove the highlight class from all the highlighted suggestions
  368
+         * @public
  369
+         */
  370
+        removeHighlight : function (i) {
  371
+            var suggestionContainer = this._textInputField.parentNode;
  372
+            var typeUtil = aria.utils.Type;
  373
+            if (!i) {
  374
+                i = this.getHighlight();
  375
+            }
  376
+            if (typeUtil.isArray(i)) {
  377
+                for (var k = 0; k < i.length; k++) {
  378
+                    var suggestionNode = suggestionContainer.children[i[k] - 1];
1
Francesco Longo Collaborator
flongo added a note February 21, 2014

So it is 1-based, right? I am more in favour of a 0-based selection. Whatever you decide to keep, can you please add this information in the jsDoc?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
src/aria/widgets/form/MultiAutoComplete.js
((10 lines not shown))
  369
+         */
  370
+        removeHighlight : function (i) {
  371
+            var suggestionContainer = this._textInputField.parentNode;
  372
+            var typeUtil = aria.utils.Type;
  373
+            if (!i) {
  374
+                i = this.getHighlight();
  375
+            }
  376
+            if (typeUtil.isArray(i)) {
  377
+                for (var k = 0; k < i.length; k++) {
  378
+                    var suggestionNode = suggestionContainer.children[i[k] - 1];
  379
+                    if (suggestionNode) {
  380
+                        this._removeClass(suggestionNode, 'highlight');
  381
+                    }
  382
+                }
  383
+            } else {
  384
+                var suggestionNode = suggestionContainer.children[i - 1];
1
Francesco Longo Collaborator
flongo added a note February 21, 2014

You can also call this.removeHighlight([i]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
src/aria/widgets/form/MultiAutoComplete.js
((35 lines not shown))
  394
+         * @protected
  395
+         */
  396
+        _removeClass : function (suggestionNode, className) {
  397
+            var suggestionNodeClassList = new aria.utils.ClassList(suggestionNode);
  398
+            suggestionNodeClassList.remove('highlight');
  399
+            suggestionNodeClassList.$dispose();
  400
+        },
  401
+
  402
+        /**
  403
+         * To add the highlight class for the suggestion(s)
  404
+         * @param {MultiTypes} i It can be an array of indices of suggestions or an index of suggestion to be
  405
+         * highlighted
  406
+         * @public
  407
+         */
  408
+        addHighlight : function (i) {
  409
+            var suggestionContainer = this._textInputField.parentNode;
1
Francesco Longo Collaborator
flongo added a note February 21, 2014

The same comments as above apply also here. It is just important to be consistent with the indexing strategy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
jakub-g
Collaborator

I'd just like to add that it'll be better to have more meaningful commit messages.

Public methods for adding, removing and getting highlighted suggestions

The commit messages should be meaningful on the repo level, here we know the commit is about highlighted suggestions somewhere. It should be written explicitly that it's about MultiAutoComplete (probably the commit message should start from MultiAutoComplete:)

src/aria/widgets/form/MultiAutoCompleteStyle.tpl.css
... ...
@@ -55,6 +59,17 @@
55 59
         	{call background(skinClass.optionsBackgroundColor,skinClass.closeSpriteURL,"no-repeat -5px -25px")/}
56 60
         }
57 61
 
  62
+        .xMultiAutoComplete_${skinClassName}_options a:hover{
1
Francesco Longo Collaborator
flongo added a note February 21, 2014

If the same order was kept in the close crosses sequence (namely the :hover one on top) there would be no need to define this rule. Also, why is the extension of this image different with respect to the other one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
src/aria/widgets/form/MultiAutoCompleteStyle.tpl.css
... ...
@@ -55,6 +59,17 @@
55 59
         	{call background(skinClass.optionsBackgroundColor,skinClass.closeSpriteURL,"no-repeat -5px -25px")/}
56 60
         }
57 61
 
  62
+        .xMultiAutoComplete_${skinClassName}_options a:hover{
  63
+        	background-position: -5px -5px;
  64
+        }
  65
+
  66
+        .highlight a{
  67
+        	{call background(skinClass.optionsHighlightBackgroundColor,skinClass.closeHighlightSpriteURL,"no-repeat -5px -5px")/}
  68
+        }
  69
+        .highlight a:hover{
  70
+			background-position: -5px -25px;
1
Francesco Longo Collaborator
flongo added a note February 21, 2014

formatting issue here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
src/aria/widgets/form/MultiAutoCompleteStyle.tpl.css
... ...
@@ -45,7 +45,11 @@
45 45
         	border-radius:3px;
46 46
         	margin:2px;
47 47
         }
48  
-
  48
+ 		.highlight{
1
Francesco Longo Collaborator
flongo added a note February 21, 2014

I think that just having .highlight in the selector is a little error-prone as the name is generic. There might be interference. I would rather have .xMultiAutoComplete_${skinClassName}_options.highlight for better scoping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
test/aria/widgets/form/autocomplete/multiautocomplete/MultiAutoCompleteTestSuite.js
... ...
@@ -29,6 +29,7 @@ Aria.classDefinition({
29 29
         this.addTests("test.aria.widgets.form.autocomplete.multiautocomplete.test7.MultiAutoError");
30 30
         this.addTests("test.aria.widgets.form.autocomplete.multiautocomplete.test8.MultiAutoMaxOptions");
31 31
         this.addTests("test.aria.widgets.form.autocomplete.multiautocomplete.test9.MultiAutoBackSpace");
  32
+        this.addTests("test.aria.widgets.form.autocomplete.multiautocomplete.test10.MultiAutoHighlightTest");
1
Francesco Longo Collaborator
flongo added a note February 21, 2014

Is it possible to rename the test folder so that it is not called test10, but has a more specific value. The problem here is that other people working on a MultiAutoComplete issue are using the same folder for their test (I have already seen one).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
test/aria/widgets/form/autocomplete/multiautocomplete/test10/MultiAutoHighlightTest.js
((23 lines not shown))
  23
+            freeText : true
  24
+        };
  25
+
  26
+        this.$BaseMultiAutoCompleteTestCase.constructor.call(this);
  27
+
  28
+    },
  29
+    $prototype : {
  30
+        /**
  31
+         * This method is always the first entry point to a template test Start the test by focusing the first field
  32
+         */
  33
+        runTemplateTest : function () {
  34
+            var widgetInstance = this.getWidgetInstance("MultiAutoId");
  35
+            this.checkSelectedItems(4);
  36
+
  37
+            widgetInstance.addHighlight([1, 3, 4]);
  38
+            this.assertEquals([1, 3, 4].join(','), widgetInstance.getHighlight().join(','), "Highlighted suggestions are not proper");
1
Francesco Longo Collaborator
flongo added a note February 21, 2014

You can also use this.assertJsonEquals instead of having to join the results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Srinath M smadapathi referenced this pull request from a commit in smadapathi/ariatemplates January 28, 2014
Srinath M feat #985 Public methods for adding, removing, getting highlighted
suggestions
176e938
Srinath M smadapathi referenced this pull request from a commit in smadapathi/ariatemplates January 28, 2014
Srinath M feat #985 Public methods for adding, removing, getting highlighted
suggestions
06d0373
Srinath M smadapathi referenced this pull request from a commit in smadapathi/ariatemplates January 28, 2014
Srinath M feat #985 Public methods for adding, removing, getting highlighted
suggestions
b0a3667
src/aria/widgets/form/MultiAutoComplete.js
... ...
@@ -360,6 +360,89 @@ Aria.classDefinition({
360 360
             this.setProperty("value", newSuggestions);
361 361
             this._textInputField.style.width = "0px";
362 362
             this.__resizeInput();
  363
+        },
  364
+        /**
  365
+         * To remove the highlight class from the suggestion(s)
  366
+         * @param {MultiTypes} i It can be an array of indices of suggestions or an index of suggestion. If nothing is
1
jakub-g Collaborator
jakub-g added a note February 24, 2014

Instead of {MultiTypes} I'd put {Array|Integer}. I'd also rename the variable from i to indices.
Same applies to addHighlight

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
src/aria/widgets/form/MultiAutoComplete.js
((15 lines not shown))
  374
+                i = this.getHighlight();
  375
+            }
  376
+            if (typeUtil.isArray(i)) {
  377
+                for (var k = 0; k < i.length; k++) {
  378
+                    var suggestionNode = suggestionContainer.children[i[k] - 1];
  379
+                    if (suggestionNode) {
  380
+                        this._removeClass(suggestionNode, 'highlight');
  381
+                    }
  382
+                }
  383
+            } else {
  384
+                this.removeHighlight([i]);
  385
+            }
  386
+        },
  387
+        /**
  388
+         * To remove class from DomElement
  389
+         * @param {aria.utils.HTML} suggestionNode
1
jakub-g Collaborator
jakub-g added a note February 24, 2014

I think it should be HTMLElement instead of aria.utils.HTML, right?
Same applies to addClass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
jakub-g
Collaborator

Please update the commit message (not only the pull request title) to include MultiAutoComplete keyword in it.

Srinath M smadapathi referenced this pull request from a commit in smadapathi/ariatemplates January 28, 2014
Srinath M feat #985 Public methods for highlight class for MultiAutoComplete wi…
…dget
804ed1b
jakub-g jakub-g commented on the diff February 24, 2014
src/aria/widgets/form/MultiAutoComplete.js
((58 lines not shown))
  417
+                this.addHighlight([indices]);
  418
+            }
  419
+        },
  420
+        /**
  421
+         * To add class for DomElement
  422
+         * @param {HTMLElement} suggestionNode
  423
+         * @param {String} className
  424
+         * @protected
  425
+         */
  426
+        _addClass : function (suggestionNode, className) {
  427
+            var suggestionNodeClassList = new aria.utils.ClassList(suggestionNode);
  428
+            suggestionNodeClassList.add(className);
  429
+            suggestionNodeClassList.$dispose();
  430
+        },
  431
+        /**
  432
+         * Returns an array of indices of suggestions which have highlight class.
1
jakub-g Collaborator
jakub-g added a note February 24, 2014

Missing @return {Array} jsdoc annotation here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
jakub-g
Collaborator

The pull request is out of sync with master, please rebase it after all the fixes are put in place.

Srinath M smadapathi referenced this pull request from a commit in smadapathi/ariatemplates January 28, 2014
Srinath M feat #985 Public methods for highlight class for MultiAutoComplete wi…
…dget
9ad66d1
Srinath M smadapathi referenced this pull request from a commit in smadapathi/ariatemplates January 28, 2014
Srinath M feat #985 Public methods for highlight class for MultiAutoComplete wi…
…dget
67a0b46
jakub-g jakub-g referenced this pull request from a commit in jakub-g/ariatemplates January 28, 2014
Srinath M feat #985 MultiAutoComplete: public methods for highlighting
Close #985.
d31b18d
Srinath M smadapathi closed this in d31b18d February 25, 2014
carlo-mr carlo-mr referenced this pull request from a commit in carlo-mr/ariatemplates January 28, 2014
Srinath M feat #985 MultiAutoComplete: public methods for highlighting
Close #985.
ef18e75
divdavem referenced this pull request from a commit in divdavem/ariatemplates March 06, 2014
feat #985 Adding missing properties in AriaSkinBeans
In commit d31b18d, some properties
were added to the skin, but were not added to AriaSkinBeans.
This commit adds these properties to AriaSkinBeans.
93d2205
divdavem referenced this pull request from a commit in divdavem/ariatemplates March 06, 2014
fix #1014 Adding MultiAutoComplete highlight properties in AriaSkinBeans
In commit d31b18d (corresponding to #985),
some properties were added to the skin, but were not added to AriaSkinBeans.
This commit adds these properties to AriaSkinBeans.
1c0a1d1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Feb 25, 2014
Srinath M feat #985 Public methods for highlight class for MultiAutoComplete wi…
…dget
9c5bf0d
This page is out of date. Refresh to see the latest.
7  src/aria/css/atskin.js
@@ -1339,7 +1339,12 @@ Aria.classDefinition({
1339 1339
                     optionsBorderColor : "#AAAAAA",
1340 1340
                     closeSpriteURL : "atskin/sprites/closemark.gif",
1341 1341
                     closeSpriteHeight : 10,
1342  
-                    closeSpriteWidth : 9
  1342
+                    closeSpriteWidth : 9,
  1343
+                    optionsHighlightBackgroundColor : "#FFCC66",
  1344
+                    optionsHighlightColor : "#333",
  1345
+                    optionsHighlightBorderWidth : 1,
  1346
+                    optionsHighlightBorderColor : "#AAAAAA",
  1347
+                    closeHighlightSpriteURL : "atskin/sprites/closemark_highlight.gif"
1343 1348
                 }
1344 1349
             },
1345 1350
             ErrorList : {
BIN  src/aria/css/atskin/sprites/closemark_highlight.gif
85  src/aria/widgets/form/MultiAutoComplete.js
@@ -366,6 +366,91 @@ Aria.classDefinition({
366 366
          */
367 367
         getValidationPopupReference : function () {
368 368
             return this.getTextInputField();
  369
+        },
  370
+        /**
  371
+         * To remove the highlight class from the suggestion(s)
  372
+         * @param {Array|Integer} indices It can be an array of indices of suggestions or an index of suggestion. If
  373
+         * nothing is provided it will remove the highlight class from all the highlighted suggestions. Indexing starts
  374
+         * with 1.
  375
+         * @public
  376
+         */
  377
+        removeHighlight : function (indices) {
  378
+            var suggestionContainer = this._textInputField.parentNode;
  379
+            var typeUtil = aria.utils.Type;
  380
+            if (typeof indices === "undefined") {
  381
+                indices = this.getHighlight();
  382
+            }
  383
+            if (typeUtil.isArray(indices)) {
  384
+                for (var k = 0; k < indices.length; k++) {
  385
+                    var suggestionNode = suggestionContainer.children[indices[k] - 1];
  386
+                    if (suggestionNode) {
  387
+                        this._removeClass(suggestionNode, 'highlight');
  388
+                    }
  389
+                }
  390
+            } else {
  391
+                this.removeHighlight([indices]);
  392
+            }
  393
+        },
  394
+        /**
  395
+         * To remove class from DomElement
  396
+         * @param {HTMLElement} suggestionNode
  397
+         * @param {String} className
  398
+         * @protected
  399
+         */
  400
+        _removeClass : function (suggestionNode, className) {
  401
+            var suggestionNodeClassList = new aria.utils.ClassList(suggestionNode);
  402
+            suggestionNodeClassList.remove(className);
  403
+            suggestionNodeClassList.$dispose();
  404
+        },
  405
+
  406
+        /**
  407
+         * To add the highlight class for the suggestion(s)
  408
+         * @param {Array|Integer} indices It can be an array of indices of suggestions or an index of suggestion to be
  409
+         * highlighted. Indexing starts with 1.
  410
+         * @public
  411
+         */
  412
+        addHighlight : function (indices) {
  413
+            var suggestionContainer = this._textInputField.parentNode;
  414
+            var typeUtil = aria.utils.Type;
  415
+            if (typeUtil.isArray(indices)) {
  416
+                for (var k = 0; k < indices.length; k++) {
  417
+                    var suggestionNode = suggestionContainer.children[indices[k] - 1];
  418
+                    if (suggestionNode) {
  419
+                        this._addClass(suggestionNode, 'highlight');
  420
+                    }
  421
+                }
  422
+            } else {
  423
+                this.addHighlight([indices]);
  424
+            }
  425
+        },
  426
+        /**
  427
+         * To add class for DomElement
  428
+         * @param {HTMLElement} suggestionNode
  429
+         * @param {String} className
  430
+         * @protected
  431
+         */
  432
+        _addClass : function (suggestionNode, className) {
  433
+            var suggestionNodeClassList = new aria.utils.ClassList(suggestionNode);
  434
+            suggestionNodeClassList.add(className);
  435
+            suggestionNodeClassList.$dispose();
  436
+        },
  437
+        /**
  438
+         * Returns an array of indices of suggestions which have highlight class.
  439
+         * @public
  440
+         * @return {Array}
  441
+         */
  442
+        getHighlight : function () {
  443
+            var suggestionContainer = this._textInputField.parentNode;
  444
+            var highlightedArray = [];
  445
+            for (var i = 0; i < suggestionContainer.children.length - 1; i++) {
  446
+                var suggestionNode = suggestionContainer.children[i];
  447
+                var suggestionNodeClassList = new aria.utils.ClassList(suggestionNode);
  448
+                if (suggestionNodeClassList.contains("highlight")) {
  449
+                    highlightedArray.push(i + 1);
  450
+                }
  451
+                suggestionNodeClassList.$dispose();
  452
+            }
  453
+            return highlightedArray;
369 454
         }
370 455
     }
371 456
 });
95  src/aria/widgets/form/MultiAutoCompleteStyle.tpl.css
@@ -18,57 +18,82 @@
18 18
     $extends : "aria.widgets.form.TextInputStyle"
19 19
 }}
20 20
     {var skinnableClassName="MultiAutoComplete"/}
21  
-     {macro main()}
22  
- 		.xMultiAutoComplete_list{
  21
+
  22
+    {macro main()}
  23
+        .xMultiAutoComplete_list{
23 24
             position:relative;
24 25
             overflow:hidden;
25 26
         }
26 27
         .xMultiAutoComplete_list input{
27  
- 			margin-top:2px;
28  
- 			min-width:40px;
29  
- 			vertical-align:middle !important;
30  
- 			width:40px;
  28
+            margin-top:2px;
  29
+            min-width:40px;
  30
+            vertical-align:middle !important;
  31
+            width:40px;
31 32
         }
  33
+        {call startLooping()/}
  34
+    {/macro}
32 35
 
33  
-	 {call startLooping()/}
34  
- 	{/macro}
35 36
     {macro writeSkinClass(info)}
36  
-         {var skinClassName=info.skinClassName/}
37  
-         {var skinClass=info.skinClass/}
  37
+        {var skinClassName=info.skinClassName/}
  38
+        {var skinClass=info.skinClass/}
38 39
 
39  
-       .xMultiAutoComplete_${skinClassName}_options{
40  
-        	display:inline-block;
41  
-        	position:relative;
42  
-        	border: ${skinClass.optionsBorderWidth}px solid ${skinClass.optionsBorderColor};
43  
-        	background-color: ${skinClass.optionsBackgroundColor};
44  
-        	color:${skinClass.optionsColor};
45  
-        	border-radius:3px;
46  
-        	margin:2px;
  40
+        .xMultiAutoComplete_${skinClassName}_options{
  41
+            display:inline-block;
  42
+            position:relative;
  43
+            border: ${skinClass.optionsBorderWidth}px solid ${skinClass.optionsBorderColor};
  44
+            background-color: ${skinClass.optionsBackgroundColor};
  45
+            color:${skinClass.optionsColor};
  46
+            border-radius:3px;
  47
+            margin:2px;
47 48
         }
48  
-
49  
-
50 49
         .xMultiAutoComplete_${skinClassName}_options a{
51  
-        	height:${skinClass.closeSpriteHeight}px;
52  
-        	width:${skinClass.closeSpriteWidth}px;
53  
-        	display:inline-block;
54  
-        	padding-left:2px;
55  
-        	{call background(skinClass.optionsBackgroundColor,skinClass.closeSpriteURL,"no-repeat -5px -25px")/}
  50
+            height:${skinClass.closeSpriteHeight}px;
  51
+            width:${skinClass.closeSpriteWidth}px;
  52
+            display:inline-block;
  53
+            padding-left:2px;
  54
+            {call background(skinClass.optionsBackgroundColor, skinClass.closeSpriteURL, "no-repeat -5px -25px")/}
56 55
         }
57 56
 
58 57
         .xMultiAutoComplete_${skinClassName}_options span{
59  
-        	margin:2px 5px;
60  
-        	display:inline-block;
61  
-        	cursor:pointer;
  58
+            margin:2px 5px;
  59
+            display:inline-block;
  60
+            cursor:pointer;
62 61
         }
63 62
         .xMultiAutoComplete_${skinClassName}_options span.ellipsisClass{
64  
-        	white-space:nowrap;
65  
-			overflow:hidden;
66  
-			text-overflow:ellipsis;
67  
-			vertical-align:middle;
68  
-			line-height:18px;
  63
+            white-space:nowrap;
  64
+            overflow:hidden;
  65
+            text-overflow:ellipsis;
  66
+            vertical-align:middle;
  67
+            line-height:18px;
  68
+        }
  69
+        .xMultiAutoComplete_${skinClassName}_options a:hover{
  70
+            background-position: -5px -5px;
  71
+        }
  72
+        .xMultiAutoComplete_${skinClassName}_options.highlight{
  73
+            border: ${skinClass.optionsHighlightBorderWidth}px solid ${skinClass.optionsHighlightBorderColor};
  74
+            background-color: ${skinClass.optionsHighlightBackgroundColor};
  75
+            color:${skinClass.optionsHighlightColor};
  76
+        }
  77
+
  78
+        .xMultiAutoComplete_${skinClassName}_options.highlight a{
  79
+            {call background(skinClass.optionsHighlightBackgroundColor, skinClass.closeHighlightSpriteURL, "no-repeat -5px -5px")/}
  80
+        }
  81
+
  82
+        .xMultiAutoComplete_${skinClassName}_options.highlight a:hover{
  83
+            background-position: -5px -25px;
  84
+        }
  85
+        .xMultiAutoComplete_${skinClassName}_options span{
  86
+            margin:2px 5px;
  87
+            display:inline-block;
  88
+            cursor:pointer;
69 89
         }
70  
-         .xMultiAutoComplete_${skinClassName}_options a:hover{
71  
-        	background-position: -5px -5px;
  90
+        .xMultiAutoComplete_${skinClassName}_options span.ellipsisClass{
  91
+            white-space:nowrap;
  92
+            overflow:hidden;
  93
+            text-overflow:ellipsis;
  94
+            vertical-align:middle;
  95
+            line-height:18px;
72 96
         }
  97
+
73 98
      {/macro}
74 99
 {/CSSTemplate}
11  test/aria/widgets/form/autocomplete/multiautocomplete/BaseMultiAutoCompleteTestCase.js
@@ -130,6 +130,17 @@ Aria.classDefinition({
130 130
 
131 131
         _getSelectedItemElement : function (index) {
132 132
             return this._getContainer().childNodes[index];
  133
+        },
  134
+        _getWidgetInstance : function () {
  135
+            return this.getWidgetInstance("MultiAutoId");
  136
+        },
  137
+        checkHighlightedElementsIndices : function (expectedHighlightedArray) {
  138
+            var widgetInstance = this._getWidgetInstance();
  139
+            var actualHighlightedArray = widgetInstance.getHighlight();
  140
+            this.assertJsonEquals(expectedHighlightedArray, actualHighlightedArray, "Expected higlighted elements indices are ["
  141
+                    + expectedHighlightedArray
  142
+                    + "] but actual highlighted elements indices are ["
  143
+                    + actualHighlightedArray + "]");
133 144
         }
134 145
 
135 146
     }
1  test/aria/widgets/form/autocomplete/multiautocomplete/MultiAutoCompleteTestSuite.js
@@ -29,6 +29,7 @@ Aria.classDefinition({
29 29
         this.addTests("test.aria.widgets.form.autocomplete.multiautocomplete.test7.MultiAutoError");
30 30
         this.addTests("test.aria.widgets.form.autocomplete.multiautocomplete.test8.MultiAutoMaxOptions");
31 31
         this.addTests("test.aria.widgets.form.autocomplete.multiautocomplete.test9.MultiAutoBackSpace");
  32
+        this.addTests("test.aria.widgets.form.autocomplete.multiautocomplete.testHighlightMethods.MultiAutoHighlightTest");
32 33
         this.addTests("test.aria.widgets.form.autocomplete.multiautocomplete.duplicateValuesAfterError.DuplicateValuesAfterError");
33 34
     }
34 35
 });
61  test/aria/widgets/form/autocomplete/multiautocomplete/testHighlightMethods/MultiAutoHighlightTest.js
... ...
@@ -0,0 +1,61 @@
  1
+/*
  2
+ * Copyright 2013 Amadeus s.a.s.
  3
+ * Licensed under the Apache License, Version 2.0 (the "License");
  4
+ * you may not use this file except in compliance with the License.
  5
+ * You may obtain a copy of the License at
  6
+ *
  7
+ *    http://www.apache.org/licenses/LICENSE-2.0
  8
+ *
  9
+ * Unless required by applicable law or agreed to in writing, software
  10
+ * distributed under the License is distributed on an "AS IS" BASIS,
  11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12
+ * See the License for the specific language governing permissions and
  13
+ * limitations under the License.
  14
+ */
  15
+
  16
+Aria.classDefinition({
  17
+    $classpath : "test.aria.widgets.form.autocomplete.multiautocomplete.testHighlightMethods.MultiAutoHighlightTest",
  18
+    $extends : "test.aria.widgets.form.autocomplete.multiautocomplete.BaseMultiAutoCompleteTestCase",
  19
+    $constructor : function () {
  20
+
  21
+        this.data = {
  22
+            ac_airline_values : ["India", "Singapore", "America", "France"],
  23
+            freeText : true
  24
+        };
  25
+
  26
+        this.$BaseMultiAutoCompleteTestCase.constructor.call(this);
  27
+
  28
+    },
  29
+    $prototype : {
  30
+        /**
  31
+         * This method is always the first entry point to a template test Start the test by focusing the first field
  32
+         */
  33
+        runTemplateTest : function () {
  34
+            var widgetInstance = this.getWidgetInstance("MultiAutoId");
  35
+            this.checkSelectedItems(4);
  36
+
  37
+            widgetInstance.addHighlight([1, 3, 4]);
  38
+            this.checkHighlightedElementsIndices([1, 3, 4]);
  39
+            // remove highlight with index
  40
+            widgetInstance.removeHighlight(3);
  41
+
  42
+            // nothing should happen here
  43
+            widgetInstance.removeHighlight(0);
  44
+            this.checkHighlightedElementsIndices([1, 4]);
  45
+            // add highlight with index
  46
+            widgetInstance.addHighlight(2);
  47
+            this.checkHighlightedElementsIndices([1, 2, 4]);
  48
+
  49
+            // remove highlight with array of indices
  50
+            widgetInstance.removeHighlight([2, 4]);
  51
+            this.checkHighlightedElementsIndices([1]);
  52
+
  53
+            // add highlight with array of indices
  54
+            widgetInstance.addHighlight([2, 3, 4]);
  55
+            // remove highlight with no argument
  56
+            widgetInstance.removeHighlight();
  57
+            this.checkHighlightedElementsIndices([]);
  58
+            this.end();
  59
+        }
  60
+    }
  61
+});
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.