mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 15:07:13 +08:00
List items with or without binding
This commit is contained in:
28
dist/ionic-angular.js
vendored
28
dist/ionic-angular.js
vendored
@ -87,7 +87,7 @@ angular.module('ionic.service.modal', ['ionic.service'])
|
|||||||
var element = $compile(templateString)(scope);
|
var element = $compile(templateString)(scope);
|
||||||
$document[0].body.appendChild(element[0]);
|
$document[0].body.appendChild(element[0]);
|
||||||
|
|
||||||
var modal = ionic.views.Modal({el: element[0] });
|
var modal = new ionic.views.Modal({el: element[0] });
|
||||||
scope.modal = modal;
|
scope.modal = modal;
|
||||||
return modal;
|
return modal;
|
||||||
},
|
},
|
||||||
@ -182,22 +182,6 @@ angular.module('ionic.ui.content', [])
|
|||||||
;
|
;
|
||||||
angular.module('ionic.ui.list', ['ionic.service'])
|
angular.module('ionic.ui.list', ['ionic.service'])
|
||||||
|
|
||||||
.directive('list', function() {
|
|
||||||
return {
|
|
||||||
restrict: 'E',
|
|
||||||
replace: true,
|
|
||||||
transclude: true,
|
|
||||||
scope: {
|
|
||||||
isEditing: '='
|
|
||||||
},
|
|
||||||
template: '<ul class="list" ng-class="{\'list-editing\': isEditing}" ng-transclude></ul>',
|
|
||||||
link: function($scope, $element, $attr) {
|
|
||||||
var lv = new ionic.views.List({el: $element[0]});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
.directive('listItem', function() {
|
.directive('listItem', function() {
|
||||||
return {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
@ -218,10 +202,11 @@ angular.module('ionic.ui.list', ['ionic.service'])
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
.directive('listItems', function() {
|
.directive('list', function() {
|
||||||
return {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
replace: true,
|
replace: true,
|
||||||
|
transclude: true,
|
||||||
scope: {
|
scope: {
|
||||||
isEditing: '=',
|
isEditing: '=',
|
||||||
items: '='
|
items: '='
|
||||||
@ -229,10 +214,15 @@ angular.module('ionic.ui.list', ['ionic.service'])
|
|||||||
template: '<ul class="list" ng-class="{\'list-editing\': isEditing}">' +
|
template: '<ul class="list" ng-class="{\'list-editing\': isEditing}">' +
|
||||||
'<list-item ng-repeat="item in items" canDelete="item.canDelete" canSwipe="item.canSwipe">' +
|
'<list-item ng-repeat="item in items" canDelete="item.canDelete" canSwipe="item.canSwipe">' +
|
||||||
' {{item.text}}' +
|
' {{item.text}}' +
|
||||||
|
' <i class="{{item.icon}}" ng-if="item.icon"></i>' +
|
||||||
'</list-item>' +
|
'</list-item>' +
|
||||||
'</ul>',
|
'</ul>',
|
||||||
link: function($scope, $element, $attr) {
|
compile: function(element, attr, transclude) {
|
||||||
|
return function($scope, $element, $attr) {
|
||||||
var lv = new ionic.views.List({el: $element[0]});
|
var lv = new ionic.views.List({el: $element[0]});
|
||||||
|
|
||||||
|
$element.append(transclude($scope));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
2
dist/ionic-ios7.css
vendored
2
dist/ionic-ios7.css
vendored
@ -1074,6 +1074,8 @@ a.list-item {
|
|||||||
z-index: 1;
|
z-index: 1;
|
||||||
padding: 15px 15px;
|
padding: 15px 15px;
|
||||||
-webkit-transition: left 0.2s ease-in-out; }
|
-webkit-transition: left 0.2s ease-in-out; }
|
||||||
|
.list-item-content > i:last-child {
|
||||||
|
float: right; }
|
||||||
|
|
||||||
.list-item-edit {
|
.list-item-edit {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|||||||
2
dist/ionic.css
vendored
2
dist/ionic.css
vendored
@ -1162,6 +1162,8 @@ a.list-item {
|
|||||||
z-index: 1;
|
z-index: 1;
|
||||||
padding: 15px 15px;
|
padding: 15px 15px;
|
||||||
-webkit-transition: left 0.2s ease-in-out; }
|
-webkit-transition: left 0.2s ease-in-out; }
|
||||||
|
.list-item-content > i:last-child {
|
||||||
|
float: right; }
|
||||||
|
|
||||||
.list-item-edit {
|
.list-item-edit {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|||||||
26
js/ext/angular/src/directive/ionicList.js
vendored
26
js/ext/angular/src/directive/ionicList.js
vendored
@ -1,21 +1,5 @@
|
|||||||
angular.module('ionic.ui.list', ['ionic.service'])
|
angular.module('ionic.ui.list', ['ionic.service'])
|
||||||
|
|
||||||
.directive('list', function() {
|
|
||||||
return {
|
|
||||||
restrict: 'E',
|
|
||||||
replace: true,
|
|
||||||
transclude: true,
|
|
||||||
scope: {
|
|
||||||
isEditing: '='
|
|
||||||
},
|
|
||||||
template: '<ul class="list" ng-class="{\'list-editing\': isEditing}" ng-transclude></ul>',
|
|
||||||
link: function($scope, $element, $attr) {
|
|
||||||
var lv = new ionic.views.List({el: $element[0]});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
.directive('listItem', function() {
|
.directive('listItem', function() {
|
||||||
return {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
@ -36,10 +20,11 @@ angular.module('ionic.ui.list', ['ionic.service'])
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
.directive('listItems', function() {
|
.directive('list', function() {
|
||||||
return {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
replace: true,
|
replace: true,
|
||||||
|
transclude: true,
|
||||||
scope: {
|
scope: {
|
||||||
isEditing: '=',
|
isEditing: '=',
|
||||||
items: '='
|
items: '='
|
||||||
@ -47,10 +32,15 @@ angular.module('ionic.ui.list', ['ionic.service'])
|
|||||||
template: '<ul class="list" ng-class="{\'list-editing\': isEditing}">' +
|
template: '<ul class="list" ng-class="{\'list-editing\': isEditing}">' +
|
||||||
'<list-item ng-repeat="item in items" canDelete="item.canDelete" canSwipe="item.canSwipe">' +
|
'<list-item ng-repeat="item in items" canDelete="item.canDelete" canSwipe="item.canSwipe">' +
|
||||||
' {{item.text}}' +
|
' {{item.text}}' +
|
||||||
|
' <i class="{{item.icon}}" ng-if="item.icon"></i>' +
|
||||||
'</list-item>' +
|
'</list-item>' +
|
||||||
'</ul>',
|
'</ul>',
|
||||||
link: function($scope, $element, $attr) {
|
compile: function(element, attr, transclude) {
|
||||||
|
return function($scope, $element, $attr) {
|
||||||
var lv = new ionic.views.List({el: $element[0]});
|
var lv = new ionic.views.List({el: $element[0]});
|
||||||
|
|
||||||
|
$element.append(transclude($scope));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
2
js/ext/angular/src/service/ionicModal.js
vendored
2
js/ext/angular/src/service/ionicModal.js
vendored
@ -17,7 +17,7 @@ angular.module('ionic.service.modal', ['ionic.service'])
|
|||||||
var element = $compile(templateString)(scope);
|
var element = $compile(templateString)(scope);
|
||||||
$document[0].body.appendChild(element[0]);
|
$document[0].body.appendChild(element[0]);
|
||||||
|
|
||||||
var modal = ionic.views.Modal({el: element[0] });
|
var modal = new ionic.views.Modal({el: element[0] });
|
||||||
scope.modal = modal;
|
scope.modal = modal;
|
||||||
return modal;
|
return modal;
|
||||||
},
|
},
|
||||||
|
|||||||
11
js/ext/angular/test/directive/ionicList.unit.js
Normal file
11
js/ext/angular/test/directive/ionicList.unit.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
describe('Ionic List', function() {
|
||||||
|
var modal, q;
|
||||||
|
|
||||||
|
beforeEach(module('ionic.ui.list'));
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should init', function() {
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -73,8 +73,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</list>
|
</list>
|
||||||
<list-items items="items" is-editing="isEditingItems">
|
<list items="items" is-editing="isEditingItems">
|
||||||
</list-items>
|
</list>
|
||||||
<button ng-click="edit()" class="button button-success">Edit</button>
|
<button ng-click="edit()" class="button button-success">Edit</button>
|
||||||
</content>
|
</content>
|
||||||
|
|
||||||
@ -84,14 +84,44 @@
|
|||||||
angular.module('navTest', ['ionic.ui.list'])
|
angular.module('navTest', ['ionic.ui.list'])
|
||||||
|
|
||||||
.controller('TestCtrl', function($scope) {
|
.controller('TestCtrl', function($scope) {
|
||||||
$scope.items = [{
|
$scope.items = [
|
||||||
|
{
|
||||||
text: 'Item 1',
|
text: 'Item 1',
|
||||||
canDelete: true,
|
canDelete: true,
|
||||||
canSwipe: true,
|
canSwipe: true,
|
||||||
|
icon: 'icon-chevron-right',
|
||||||
buttons: [{
|
buttons: [{
|
||||||
text: 'Kill'
|
text: 'Kill'
|
||||||
}]
|
}]
|
||||||
}];
|
},
|
||||||
|
{
|
||||||
|
text: 'Item 2',
|
||||||
|
canDelete: true,
|
||||||
|
canSwipe: true,
|
||||||
|
icon: 'icon-chevron-right',
|
||||||
|
buttons: [{
|
||||||
|
text: 'Kill'
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Item 3',
|
||||||
|
canDelete: true,
|
||||||
|
canSwipe: true,
|
||||||
|
icon: 'icon-chevron-right',
|
||||||
|
buttons: [{
|
||||||
|
text: 'Kill'
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Item 4',
|
||||||
|
canDelete: true,
|
||||||
|
canSwipe: true,
|
||||||
|
icon: 'icon-chevron-right',
|
||||||
|
buttons: [{
|
||||||
|
text: 'Kill'
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
];
|
||||||
$scope.edit = function() {
|
$scope.edit = function() {
|
||||||
$scope.isEditingItems = !$scope.isEditingItems;
|
$scope.isEditingItems = !$scope.isEditingItems;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,17 +1,38 @@
|
|||||||
describe('Ionic Modal', function() {
|
describe('Ionic Modal', function() {
|
||||||
var modal, q;
|
var modal, q;
|
||||||
|
|
||||||
beforeEach(module('ionic.ui.modal'));
|
beforeEach(module('ionic.service.modal'));
|
||||||
|
|
||||||
beforeEach(inject(function(Modal, $q) {
|
beforeEach(inject(function(Modal, $q, $templateCache) {
|
||||||
q = $q;
|
q = $q;
|
||||||
modal = Modal;
|
modal = Modal;
|
||||||
|
|
||||||
|
$templateCache.put('modal.html', '<div class="modal"></div>');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
iit('Should show', function() {
|
it('Should show for static template', function() {
|
||||||
var template = '<div class="modal"></div>';
|
var template = '<div class="modal"></div>';
|
||||||
var deferred = q.defer();
|
var modalInstance = modal.fromTemplate(template);
|
||||||
modal.fromTemplate(template);
|
modalInstance.show();
|
||||||
deferred.resolve(true);
|
expect(modalInstance.el.classList.contains('modal')).toBe(true);
|
||||||
|
expect(modalInstance.el.classList.contains('active')).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
iit('Should show for dynamic template', function() {
|
||||||
|
var template = '<div class="modal"></div>';
|
||||||
|
|
||||||
|
var done = false;
|
||||||
|
|
||||||
|
var modalInstance = modal.fromTemplateUrl('modal.html', function(modalInstance) {
|
||||||
|
done = true;
|
||||||
|
modalInstance.show();
|
||||||
|
expect(modalInstance.el.classList.contains('modal')).toBe(true);
|
||||||
|
expect(modalInstance.el.classList.contains('active')).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
waitsFor(function() {
|
||||||
|
return done;
|
||||||
|
}, "Modal should be loaded", 100);
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -108,6 +108,11 @@ a.list-item {
|
|||||||
padding: 15px 15px;
|
padding: 15px 15px;
|
||||||
|
|
||||||
-webkit-transition: left 0.2s ease-in-out;
|
-webkit-transition: left 0.2s ease-in-out;
|
||||||
|
|
||||||
|
// Align icons to the right
|
||||||
|
> i:last-child {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.list-item-edit {
|
.list-item-edit {
|
||||||
|
|||||||
Reference in New Issue
Block a user