Skip to content
This repository was archived by the owner on Dec 16, 2019. It is now read-only.

ability to add icons in header #264

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css" media="screen" />
<link rel="stylesheet" type="text/css" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" />
<link href='https://fonts.googleapis.com/css?family=Architects+Daughter' rel='stylesheet' type='text/css'>
<link href='https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css' rel='stylesheet' type='text/css'>

<script>
var staticPath = '/angularjs-dropdown-multiselect/';
Expand Down
14 changes: 13 additions & 1 deletion pages/javascripts/pages/home/ExampleCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ angular.module('exampleApp').controller('ExampleCtrl', ['$scope', function($scop
{id: 1, label: "David"},
{id: 2, label: "Jhon"},
{id: 3, label: "Danny"}];
$scope.example2settings = {displayProp: 'id'};
$scope.example2settings = {displayProp: 'id',
showCheckAll: false,
showUncheckAll:false};


$scope.example3model = [];
Expand Down Expand Up @@ -53,12 +55,22 @@ angular.module('exampleApp').controller('ExampleCtrl', ['$scope', function($scop
{id: 3, label: "Danny"}];
$scope.example7settings = {externalIdProp: ''};

/**************************************/
$scope.example8model = [];
$scope.example8data = [
{id: 1, label: "David"},
{id: 2, label: "Jhon"},
{id: 3, label: "Danny"}];
$scope.example8settings = {
showCheckAll:false,
showUncheckAll:false,
static:0,
headerclass:"fa fa-coffee"
};

$scope.example8customTexts = {buttonDefaultText: 'categories'};

/**************************************/
$scope.example9model = [];
$scope.example9data = [
{id: 1, label: "David"},
Expand Down
12 changes: 11 additions & 1 deletion pages/javascripts/pages/home/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -599,10 +599,20 @@ <h3>Code</h3>
<h3>Demo</h3>
<div class="well">
<div>
<div ng-dropdown-multiselect options="example8data" selected-model="example8model" checkboxes="true"></div>

<!--********************************************************************************************************************-->

<div ng-dropdown-multiselect options="example8data" selected-model="example8model" checkboxes="true"
extra-settings="example8settings" translation-texts="example8customTexts"
></div>

<!--********************************************************************************************************************-->

</div>
</div>
</div>


<div class="col-xs-12 col-sm-6">
<h3>The model:</h3>
<pre>{{example8model|json}}</pre>
Expand Down
15 changes: 11 additions & 4 deletions src/angularjs-dropdown-multiselect.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ directiveModule.directive('ngDropdownMultiselect', ['$filter', '$document', '$co
var groups = attrs.groupBy ? true : false;

var template = '<div class="multiselect-parent btn-group dropdown-multiselect">';
template += '<button type="button" class="dropdown-toggle" ng-class="settings.buttonClasses" ng-click="toggleDropdown()">{{getButtonText()}}&nbsp;<span class="caret"></span></button>';
template += '<button type="button" class="dropdown-toggle" ng-class="settings.buttonClasses" ng-click="toggleDropdown()">{{getButtonText()}}<i class={{settings.headerclass}}></i>&nbsp;<span class="caret"></span></button>';
template += '<ul class="dropdown-menu dropdown-menu-form" ng-style="{display: open ? \'block\' : \'none\', height : settings.scrollable ? settings.scrollableHeight : \'auto\' }" style="overflow: scroll" >';
template += '<li ng-hide="!settings.showCheckAll || settings.selectionLimit > 0"><a data-ng-click="selectAll()"><span class="glyphicon glyphicon-ok"></span> {{texts.checkAll}}</a>';
template += '<li ng-show="settings.showUncheckAll"><a data-ng-click="deselectAll();"><span class="glyphicon glyphicon-remove"></span> {{texts.uncheckAll}}</a></li>';
Expand All @@ -39,7 +39,7 @@ directiveModule.directive('ngDropdownMultiselect', ['$filter', '$document', '$co
template += '<a role="menuitem" tabindex="-1" ng-click="setSelectedItem(getPropertyForObject(option,settings.idProp))">';

if (checkboxes) {
template += '<div class="checkbox"><label><input class="checkboxInput" type="checkbox" ng-click="checkboxClick($event, getPropertyForObject(option,settings.idProp))" ng-checked="isChecked(getPropertyForObject(option,settings.idProp))" /> {{getPropertyForObject(option, settings.displayProp)}}</label></div></a>';
template += '<div class="checkbox"><label>{{getPropertyForObject(option, settings.displayProp)}} <input class="checkboxInput" type="checkbox" ng-click="checkboxClick($event, getPropertyForObject(option,settings.idProp))" ng-checked="isChecked(getPropertyForObject(option,settings.idProp))" /> </label></div></a>';
} else {
template += '<span data-ng-class="{\'glyphicon glyphicon-ok\': isChecked(getPropertyForObject(option,settings.idProp))}"></span> {{getPropertyForObject(option, settings.displayProp)}}</a>';
}
Expand Down Expand Up @@ -205,11 +205,18 @@ directiveModule.directive('ngDropdownMultiselect', ['$filter', '$document', '$co
totalSelected = angular.isDefined($scope.selectedModel) ? $scope.selectedModel.length : 0;
}

if (totalSelected === 0) {
if("headerclass" in $scope.settings){

}else{
if (totalSelected === 0) {
return $scope.texts.buttonDefaultText;
} else if($scope.settings.static === 0){
return $scope.texts.buttonDefaultText;
} else {
return totalSelected + ' ' + $scope.texts.dynamicButtonTextSuffix;
return totalSelected + ' ' + $scope.texts.dynamicButtonTextSuffix;
}
}

}
} else {
return $scope.texts.buttonDefaultText;
Expand Down