You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by va...@apache.org on 2016/10/19 12:46:01 UTC
[3/3] ode-console git commit: resolve license issue for st-select and
add some comments.
resolve license issue for st-select and add some comments.
Project: http://git-wip-us.apache.org/repos/asf/ode-console/repo
Commit: http://git-wip-us.apache.org/repos/asf/ode-console/commit/9b0a8d60
Tree: http://git-wip-us.apache.org/repos/asf/ode-console/tree/9b0a8d60
Diff: http://git-wip-us.apache.org/repos/asf/ode-console/diff/9b0a8d60
Branch: refs/heads/master
Commit: 9b0a8d60e38c28d4596d606b664a0421f9dbcb0f
Parents: b39327b
Author: Tammo van Lessen <va...@apache.org>
Authored: Wed Oct 19 14:31:03 2016 +0200
Committer: Tammo van Lessen <va...@apache.org>
Committed: Wed Oct 19 14:40:53 2016 +0200
----------------------------------------------------------------------
src/app/st-select.directive.js | 60 ++++++++++++++++++++-----------------
1 file changed, 32 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ode-console/blob/9b0a8d60/src/app/st-select.directive.js
----------------------------------------------------------------------
diff --git a/src/app/st-select.directive.js b/src/app/st-select.directive.js
index 3954afe..a030f9b 100644
--- a/src/app/st-select.directive.js
+++ b/src/app/st-select.directive.js
@@ -1,62 +1,66 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
+/*
+ Copyright 2013 Daniel Unfried
+ Modifications 2015 Apache ODE team
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
- /* https://github.com/wldaunfr/ng-selectall/blob/develop/src/selectall.directive.js */
-
'use strict';
+/* See https://github.com/wldaunfr/ng-selectall/blob/develop/src/selectall.directive.js */
angular.module('odeConsole')
.directive('selectAllCheckbox', ['$filter', function($filter) {
return {
restrict: 'E',
template: '<input type="checkbox">',
replace: true,
- link: function(scope, element, iAttrs) {
+ link: function(scope, element, attrs) {
+ // set checked and indeterminate state
function changeState(checked, indet) {
element.prop('checked', checked).prop('indeterminate', indet);
}
+ // update item checkboxes
function updateItems() {
- angular.forEach(scope.$eval(iAttrs.items), function(el) {
- el[iAttrs.prop] = element.prop('checked');
+ angular.forEach(scope.$eval(attrs.items), function(el) {
+ el[attrs.prop] = element.prop('checked');
});
}
element.bind('change', function() {
+ // update items on change
scope.$apply(function() { updateItems(); });
});
- scope.$watch(iAttrs.items, function(newValue) {
+ scope.$watch(attrs.items, function(newValue) {
var checkedItems = $filter('filter')(newValue, function(el) {
- return el[iAttrs.prop];
+ return el[attrs.prop];
});
switch(checkedItems ? checkedItems.length : 0) {
- case 0: // none selected
+ case 0:
+ // none selected (not checked, not indeterminate)
changeState(false, false);
break;
- case newValue.length: // all selected
+ case newValue.length:
+ // all selected (checked, not indeterminate)
changeState(true, false);
break;
- default: // some selected
+ default:
+ // some selected (not checked, indeterminate)
changeState(false, true);
}
}, true);
scope.$on('$destroy', function() {
element.off('change');
});
+ // initially update items
updateItems();
}
};