diff --git a/components/orderlist/orderlist.ts b/components/orderlist/orderlist.ts
index af58d2811fd..b17a34f472a 100644
--- a/components/orderlist/orderlist.ts
+++ b/components/orderlist/orderlist.ts
@@ -1,4 +1,4 @@
-import {Component,ElementRef,DoCheck,Input,Output,ContentChild,TemplateRef} from 'angular2/core';
+import {Component,ElementRef,DoCheck,Input,Output,ContentChild,TemplateRef,EventEmitter} from 'angular2/core';
import {Button} from '../button/button';
import {DomHandler} from '../dom/domhandler';
@@ -8,10 +8,10 @@ import {DomHandler} from '../dom/domhandler';
-
-
-
-
+
+
+
+
@@ -39,6 +39,8 @@ export class OrderList {
@Input() listStyle: string;
@Input() responsive: boolean;
+
+ @Output() onReorder: EventEmitter
= new EventEmitter();
@ContentChild(TemplateRef) itemTemplate: TemplateRef;
@@ -105,75 +107,91 @@ export class OrderList {
}
}
- moveUp(listElement) {
+ moveUp(event,listElement) {
let selectedElements = this.getSelectedListElements(listElement);
- for(let i = 0; i < selectedElements.length; i++) {
- let selectedElement = selectedElements[i];
- let selectedElementIndex: number = this.domHandler.index(selectedElement);
+ if(selectedElements.length) {
+ for(let i = 0; i < selectedElements.length; i++) {
+ let selectedElement = selectedElements[i];
+ let selectedElementIndex: number = this.domHandler.index(selectedElement);
- if(selectedElementIndex != 0) {
- let movedItem = this.value[selectedElementIndex];
- let temp = this.value[selectedElementIndex-1];
- this.value[selectedElementIndex-1] = movedItem;
- this.value[selectedElementIndex] = temp;
- this.domHandler.scrollInView(listElement, listElement.children[selectedElementIndex - 1]);
- }
- else {
- break;
+ if(selectedElementIndex != 0) {
+ let movedItem = this.value[selectedElementIndex];
+ let temp = this.value[selectedElementIndex-1];
+ this.value[selectedElementIndex-1] = movedItem;
+ this.value[selectedElementIndex] = temp;
+ this.domHandler.scrollInView(listElement, listElement.children[selectedElementIndex - 1]);
+ }
+ else {
+ break;
+ }
}
+
+ this.onReorder.emit(event);
}
}
- moveTop(listElement) {
+ moveTop(event,listElement) {
let selectedElements = this.getSelectedListElements(listElement);
- for(let i = 0; i < selectedElements.length; i++) {
- let selectedElement = selectedElements[i];
- let selectedElementIndex: number = this.domHandler.index(selectedElement);
+ if(selectedElements.length) {
+ for(let i = 0; i < selectedElements.length; i++) {
+ let selectedElement = selectedElements[i];
+ let selectedElementIndex: number = this.domHandler.index(selectedElement);
- if(selectedElementIndex != 0) {
- let movedItem = this.value.splice(selectedElementIndex,1)[0];
- this.value.unshift(movedItem);
- listElement.scrollTop = 0;
- }
- else {
- break;
+ if(selectedElementIndex != 0) {
+ let movedItem = this.value.splice(selectedElementIndex,1)[0];
+ this.value.unshift(movedItem);
+ listElement.scrollTop = 0;
+ }
+ else {
+ break;
+ }
}
+
+ this.onReorder.emit(event);
}
}
- moveDown(listElement) {
+ moveDown(event,listElement) {
let selectedElements = this.getSelectedListElements(listElement);
- for(let i = selectedElements.length - 1; i >= 0; i--) {
- let selectedElement = selectedElements[i];
- let selectedElementIndex: number = this.domHandler.index(selectedElement);
+ if(selectedElements.length) {
+ for(let i = selectedElements.length - 1; i >= 0; i--) {
+ let selectedElement = selectedElements[i];
+ let selectedElementIndex: number = this.domHandler.index(selectedElement);
- if(selectedElementIndex != (this.value.length - 1)) {
- let movedItem = this.value[selectedElementIndex];
- let temp = this.value[selectedElementIndex+1];
- this.value[selectedElementIndex+1] = movedItem;
- this.value[selectedElementIndex] = temp;
- this.domHandler.scrollInView(listElement, listElement.children[selectedElementIndex + 1]);
- }
- else {
- break;
+ if(selectedElementIndex != (this.value.length - 1)) {
+ let movedItem = this.value[selectedElementIndex];
+ let temp = this.value[selectedElementIndex+1];
+ this.value[selectedElementIndex+1] = movedItem;
+ this.value[selectedElementIndex] = temp;
+ this.domHandler.scrollInView(listElement, listElement.children[selectedElementIndex + 1]);
+ }
+ else {
+ break;
+ }
}
+
+ this.onReorder.emit(event);
}
}
- moveBottom(listElement) {
+ moveBottom(event,listElement) {
let selectedElements = this.getSelectedListElements(listElement);
- for(let i = selectedElements.length - 1; i >= 0; i--) {
- let selectedElement = selectedElements[i];
- let selectedElementIndex: number = this.domHandler.index(selectedElement);
+ if(selectedElements.length) {
+ for(let i = selectedElements.length - 1; i >= 0; i--) {
+ let selectedElement = selectedElements[i];
+ let selectedElementIndex: number = this.domHandler.index(selectedElement);
- if(selectedElementIndex != (this.value.length - 1)) {
- let movedItem = this.value.splice(selectedElementIndex,1)[0];
- this.value.push(movedItem);
- listElement.scrollTop = listElement.scrollHeight;
- }
- else {
- break;
+ if(selectedElementIndex != (this.value.length - 1)) {
+ let movedItem = this.value.splice(selectedElementIndex,1)[0];
+ this.value.push(movedItem);
+ listElement.scrollTop = listElement.scrollHeight;
+ }
+ else {
+ break;
+ }
}
+
+ this.onReorder.emit(event);
}
}
diff --git a/showcase/demo/orderlist/orderlistdemo.html b/showcase/demo/orderlist/orderlistdemo.html
index 2a751e24a59..c69b2cfc871 100644
--- a/showcase/demo/orderlist/orderlistdemo.html
+++ b/showcase/demo/orderlist/orderlistdemo.html
@@ -125,6 +125,26 @@ Attributes
+
+
Events
+
+
+
+
+ Name |
+ Parameters |
+ Description |
+
+
+
+
+ onReorder |
+ event: browser event |
+ Callback to invoke when list is reordered. |
+
+
+
+
Styling
Following is the list of structural style classes, for theming classes visit theming page.