Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

Fixes transclusion on angular v1.2.18+ #91

Merged
merged 2 commits into from
Jul 3, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
"test"
],
"dependencies": {
"angular": "1.2.0 - 1.2.17"
"angular": "~1.2"
},
"devDependencies": {
"jquery": "~1.11",
"angular-sanitize": "1.2.0 - 1.2.17",
"angular-mocks": "1.2.0 - 1.2.17"
"angular-sanitize": "~1.2",
"angular-mocks": "~1.2"
}
}
4 changes: 2 additions & 2 deletions examples/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
</script>
<![endif]-->

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular-sanitize.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.18/angular.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.18/angular-sanitize.js"></script>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.css">

<!-- ui-select files -->
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/choices.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
role="menu" aria-labelledby="dLabel"
ng-show="$select.items.length > 0">
<li class="ui-select-choices-row" ng-class="{active: $select.activeIndex === $index}">
<a href="javascript:void(0)" ng-transclude></a>
<a class="ui-select-choices-row-inner" href="javascript:void(0)"></a>
</li>
</ul>
32 changes: 21 additions & 11 deletions src/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,8 @@ angular.module('ui.select', [])
}])

.directive('uiSelectChoices',
['uiSelectConfig', 'RepeatParser', 'uiSelectMinErr',
function(uiSelectConfig, RepeatParser, uiSelectMinErr) {
['uiSelectConfig', 'RepeatParser', 'uiSelectMinErr', '$compile',
function(uiSelectConfig, RepeatParser, uiSelectMinErr, $compile) {

return {
restrict: 'EA',
Expand All @@ -396,17 +396,27 @@ angular.module('ui.select', [])

compile: function(tElement, tAttrs) {
var repeat = RepeatParser.parse(tAttrs.repeat);
return function link(scope, element, attrs, $select, transcludeFn) {

var rows = element.querySelectorAll('.ui-select-choices-row');
if (rows.length !== 1) {
throw uiSelectMinErr('rows', "Expected 1 .ui-select-choices-row but got '{0}'.", rows.length);
}

var rows = tElement.querySelectorAll('.ui-select-choices-row');
if (rows.length !== 1) {
throw uiSelectMinErr('rows', "Expected 1 .ui-select-choices-row but got '{0}'.", rows.length);
}
rows.attr('ng-repeat', RepeatParser.getNgRepeatExpression(repeat.lhs, '$select.items', repeat.trackByExp))
.attr('ng-mouseenter', '$select.activeIndex = $index')
.attr('ng-click', '$select.select(' + repeat.lhs + ')');

rows.attr('ng-repeat', RepeatParser.getNgRepeatExpression(repeat.lhs, '$select.items', repeat.trackByExp))
.attr('ng-mouseenter', '$select.activeIndex = $index')
.attr('ng-click', '$select.select(' + repeat.lhs + ')');

return function link(scope, element, attrs, $select) {
transcludeFn(function(clone) {
var rowsInner = element.querySelectorAll('.ui-select-choices-row-inner');
if (rowsInner.length !== 1)
throw uiSelectMinErr('rows', "Expected 1 .ui-select-choices-row-inner but got '{0}'.", rowsInner.length);

rowsInner.append(clone);
$compile(element)(scope);
});

$select.parseRepeatAttr(attrs.repeat);

scope.$watch('$select.search', function() {
Expand Down Expand Up @@ -455,6 +465,6 @@ angular.module('ui.select', [])
}

return function(matchItem, query) {
return query ? matchItem.replace(new RegExp(escapeRegexp(query), 'gi'), '<span class="ui-select-highlight">$&</span>') : matchItem;
return query && matchItem ? matchItem.replace(new RegExp(escapeRegexp(query), 'gi'), '<span class="ui-select-highlight">$&</span>') : matchItem;
};
});
2 changes: 1 addition & 1 deletion src/select2/choices.tpl.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<ul class="ui-select-choices ui-select-choices-content select2-results">
<li class="ui-select-choices-row" ng-class="{'select2-highlighted': $select.activeIndex === $index}">
<div class="select2-result-label" ng-transclude></div>
<div class="select2-result-label ui-select-choices-row-inner"></div>
</li>
</ul>
2 changes: 1 addition & 1 deletion src/selectize/choices.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="ui-select-choices-content selectize-dropdown-content">
<div class="ui-select-choices-row"
ng-class="{'active': $select.activeIndex === $index}">
<div class="option" data-selectable ng-transclude></div>
<div class="option ui-select-choices-row-inner" data-selectable></div>
</div>
</div>
</div>