Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Merge pull request #29 from carlosbaraza/master
Browse files Browse the repository at this point in the history
Remove some trailing spaces
  • Loading branch information
ssorallen committed Feb 3, 2015
2 parents f718f66 + 822b725 commit 8c2bc5b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 44 deletions.
52 changes: 26 additions & 26 deletions core-selector.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@

/**
* Specifies the CSS class to be used to add to the selected element.
*
*
* @attribute selectedClass
* @type string
* @default 'core-selected'
Expand Down Expand Up @@ -162,7 +162,7 @@
* an array of selected elements.
* Note that you should not use this to set the selection. Instead use
* `selected`.
*
*
* @attribute selectedItem
* @type Object
* @default null
Expand All @@ -172,9 +172,9 @@
/**
* In single selection, this returns the model associated with the
* selected element.
* Note that you should not use this to set the selection. Instead use
* Note that you should not use this to set the selection. Instead use
* `selected`.
*
*
* @attribute selectedModel
* @type Object
* @default null
Expand All @@ -193,7 +193,7 @@
selectedIndex: -1,

/**
* Nodes with local name that are in the list will not be included
* Nodes with local name that are in the list will not be included
* in the selection items. In the following example, `items` returns four
* `core-item`'s and doesn't include `h3` and `hr`.
*
Expand All @@ -213,17 +213,17 @@
excludedLocalNames: '',

/**
* The target element that contains items. If this is not set
* The target element that contains items. If this is not set
* core-selector is the container.
*
*
* @attribute target
* @type Object
* @default null
*/
target: null,

/**
* This can be used to query nodes from the target node to be used for
* This can be used to query nodes from the target node to be used for
* selection items. Note this only works if `target` is set
* and is not `core-selector` itself.
*
Expand All @@ -236,7 +236,7 @@
* <label><input type="radio" name="color" value="blue"> Blue</label> <br>
* <p>color = {{color}}</p>
* </form>
*
*
* @attribute itemsSelector
* @type string
* @default ''
Expand Down Expand Up @@ -264,7 +264,7 @@
notap: false,

defaultExcludedLocalNames: 'template',

observe: {
'selected multi': 'selectedChanged'
},
Expand All @@ -288,8 +288,8 @@
if (!this.target) {
return [];
}
var nodes = this.target !== this ? (this.itemsSelector ?
this.target.querySelectorAll(this.itemsSelector) :
var nodes = this.target !== this ? (this.itemsSelector ?
this.target.querySelectorAll(this.itemsSelector) :
this.target.children) : this.$.items.getDistributedNodes();
return Array.prototype.filter.call(nodes, this.itemFilter);
},
Expand Down Expand Up @@ -332,7 +332,7 @@

/**
* Returns the selected item(s). If the `multi` property is true,
* this will return an array, otherwise it will return
* this will return an array, otherwise it will return
* the selected item or undefined if there is no selection.
*/
get selection() {
Expand All @@ -348,7 +348,7 @@
this.updateSelected();
}
},

updateSelected: function() {
this.validateSelected();
if (this.multi) {
Expand All @@ -363,7 +363,7 @@

validateSelected: function() {
// convert to an array for multi-selection
if (this.multi && !Array.isArray(this.selected) &&
if (this.multi && !Array.isArray(this.selected) &&
this.selected != null) {
this.selected = [this.selected];
// use the first selected in the array for single-selection
Expand All @@ -373,7 +373,7 @@
this.selected = s;
}
},

processSplices: function(splices) {
for (var i = 0, splice; splice = splices[i]; i++) {
for (var j = 0; j < splice.removed.length; j++) {
Expand All @@ -398,7 +398,7 @@
var item = this.valueToItem(value);
this.$.selection.select(item);
},

setValueSelected: function(value, isSelected) {
var item = this.valueToItem(value);
if (isSelected ^ this.$.selection.isSelected(item)) {
Expand All @@ -417,12 +417,12 @@
} else {
this.selectedModel = null;
}
this.selectedIndex = this.selectedItem ?
this.selectedIndex = this.selectedItem ?
parseInt(this.valueToIndex(this.selected)) : -1;
},

valueToItem: function(value) {
return (value === null || value === undefined) ?
return (value === null || value === undefined) ?
null : this.items[this.valueToIndex(value)];
},

Expand Down Expand Up @@ -506,15 +506,15 @@
target = target.parentNode;
}
},

selectIndex: function(index) {
var item = this.items[index];
if (item) {
this.selected = this.valueForNode(item) || index;
return item;
}
},

/**
* Selects the previous item. This should be used in single selection only.
*
Expand All @@ -524,11 +524,11 @@
* @returns the previous item or undefined if there is none
*/
selectPrevious: function(wrapped) {
var i = wrapped && !this.selectedIndex ?
var i = wrapped && !this.selectedIndex ?
this.items.length - 1 : this.selectedIndex - 1;
return this.selectIndex(i);
},

/**
* Selects the next item. This should be used in single selection only.
*
Expand All @@ -538,11 +538,11 @@
* @returns the next item or undefined if there is none
*/
selectNext: function(wrapped) {
var i = wrapped && this.selectedIndex >= this.items.length - 1 ?
var i = wrapped && this.selectedIndex >= this.items.length - 1 ?
0 : this.selectedIndex + 1;
return this.selectIndex(i);
}

});
</script>
</polymer-element>
24 changes: 12 additions & 12 deletions demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,29 @@
margin: 0;
padding: 0;
}

.list > * {
height: 40px;
line-height: 40px;
padding: 0 20px;
border-bottom: 1px solid #ccc;
}

.list > *.core-selected {
background: #333;
}

li {
height: 30px;
}

li.core-selected:after {
content: "\2713";
position: absolute;
padding-left: 10px;
}
</style>

<h2>basic</h2>
<core-selector class="list" selected="0">
<div>Item 0</div>
Expand All @@ -58,7 +58,7 @@ <h2>basic</h2>
<div>Item 3</div>
<div>Item 4</div>
</core-selector>

<h2>multi-selection</h2>
<core-selector class="list" selected="{{multiSelected}}" multi>
<div>Item 0</div>
Expand All @@ -67,7 +67,7 @@ <h2>multi-selection</h2>
<div>Item 3</div>
<div>Item 4</div>
</core-selector>

<h2>list</h2>
<core-selector target="{{$.list}}" selected="0"></core-selector>
<ul id="list">
Expand All @@ -77,18 +77,18 @@ <h2>list</h2>
<li>Item 3</li>
<li>Item 4</li>
</ul>

<h2>binding of a group of radio buttons to a variable</h2>
<core-selector target="{{$.myForm}}" itemsSelector="input[type=radio]"
selected="{{color}}" valueattr="value" selectedProperty="checked"
<core-selector target="{{$.myForm}}" itemsSelector="input[type=radio]"
selected="{{color}}" valueattr="value" selectedProperty="checked"
activateEvent="change"></core-selector>
<form id="myForm">
<label><input type="radio" name="color" value="red"> Red</label> <br>
<label><input type="radio" name="color" value="green"> Green</label> <br>
<label><input type="radio" name="color" value="blue"> Blue</label> <br>
<p>color = {{color}}</p>
</form>

</template>

<script>
Expand All @@ -100,7 +100,7 @@ <h2>binding of a group of radio buttons to a variable</h2>
});
</script>
</polymer-element>

<selector-examples></selector-examples>
</body>
</html>
10 changes: 5 additions & 5 deletions test/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
</test-core-selector>

<script>

var s = document.querySelector('test-core-selector');

suite('content', function() {

test('get selected', function(done) {
asyncPlatformFlush(function() {
// check selected class
Expand All @@ -65,11 +65,11 @@
done();
});
});

test('get items', function() {
assert.equal(s.$.selector.items.length, s.children.length);
});

test('activate event', function(done) {
s.children[2].dispatchEvent(new CustomEvent('tap', {bubbles: true}));
asyncPlatformFlush(function() {
Expand All @@ -78,7 +78,7 @@
done();
});
});

test('add item dynamically', function(done) {
var item = document.createElement('div');
item.id = 'item4';
Expand Down
2 changes: 1 addition & 1 deletion test/multi.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
});
});
});

test('toggle multi to false', function(done) {
// set selected
s.selected = [0, 2];
Expand Down

0 comments on commit 8c2bc5b

Please sign in to comment.