Skip to content

Commit a16d307

Browse files
author
Dean Sofer
committed
Added sortable demo
1 parent 2f3b9ac commit a16d307

File tree

2 files changed

+102
-1
lines changed

2 files changed

+102
-1
lines changed

index.html

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
<li><a scrollto href="#directives-select2">Select2</a></li>
7777
<li><a scrollto href="#directives-showhide">Show / Hide / Toggle</a></li>
7878
<li><a scrollto href="#directives-tinymce">TinyMCE</a></li>
79+
<li><a scrollto href="#directives-sortable">Sortable</a></li>
7980
<li><a scrollto href="#directives-currency">Currency</a></li>
8081
</ul>
8182
</li>
@@ -967,9 +968,100 @@ <h3>How?</h3>
967968
</div>
968969
</div>
969970

970-
971971
</section>
972972

973+
<section id="directives-sortable" ng-controller="SortableCtrl">
974+
<div class="page-header">
975+
<h1>Sortable</h1>
976+
</div>
977+
<div class="row">
978+
<div class="span6">
979+
<h3>What?</h3>
980+
981+
<div class="row">
982+
<div class="span3">
983+
<p>Drag and drop the parents and children</p>
984+
<div class="well">
985+
<h3>Destroy Families</h3>
986+
<p>You're not fit to be a mother!</p>
987+
<ul ui-sortable ng-model="parents">
988+
<li ng-repeat="parent in parents">
989+
<ul>
990+
<h5>{{parent.name}}</h5>
991+
<ul class="children" ui-sortable="{connectWith:'.children'}" ng-model="parent.children">
992+
<li ng-repeat="child in parent.children">{{child}}</li>
993+
</ul>
994+
</ul>
995+
</li>
996+
</ul>
997+
</div>
998+
</div>
999+
<div class="span3">
1000+
<pre>Parents: {{parents|json}}</pre>
1001+
</div>
1002+
</div>
1003+
</div>
1004+
<div class="span6">
1005+
<h3>How?</h3>
1006+
<pre class="prettyprint linenums" ng-non-bindable>
1007+
&lt;script&gt;
1008+
$scope.parents = [
1009+
{ name: 'Anna',
1010+
children: ['Alvin', 'Becky' ,'Charlie'] },
1011+
{ name: 'Barney',
1012+
children: ['Dorothy', 'Eric'] },
1013+
{ name: 'Chris',
1014+
children: ['Frank', 'Gary', 'Henry'] }
1015+
];
1016+
&lt;/script&gt;
1017+
1018+
&lt;ul <strong>ui-sortable ng-model=&quot;parents&quot;</strong>&gt;
1019+
&lt;li ng-repeat=&quot;parent in parents&quot;&gt;
1020+
&lt;h3&gt;{{parent.name}}&lt;/h3&gt;
1021+
&lt;ul <strong>class=&quot;children&quot;
1022+
ui-sortable=&quot;{connectWith:&#39;.children&#39;}&quot;
1023+
ng-model=&quot;parent.children&quot;&gt;</strong>
1024+
&lt;li ng-repeat=&quot;child in parent.children&quot;&gt;
1025+
{{child}}
1026+
&lt;/li&gt;
1027+
&lt;/ul&gt;
1028+
&lt;/li&gt;
1029+
&lt;/ul&gt;</pre>
1030+
</div>
1031+
</div>
1032+
<div class="row">
1033+
<div class="span6">
1034+
<div class="row">
1035+
<div class="span3">
1036+
<div class="well">
1037+
<h3>Static Items</h3>
1038+
<ul ng-model="items" ui-sortable>
1039+
<li>First</li>
1040+
<li>Second</li>
1041+
<li>Third</li>
1042+
</ul>
1043+
</div>
1044+
</div>
1045+
<div class="span3">
1046+
<pre>Static Items: {{items|json}}</pre>
1047+
</div>
1048+
</div>
1049+
</div>
1050+
<div class="span6">
1051+
<pre class="prettyprint linenums" ng-non-bindable>
1052+
&lt;script&gt;
1053+
$scope.items = ['One', 'Two', 'Three'];
1054+
&lt;/script&gt;
1055+
1056+
&lt;ul ng-model=&quot;items&quot; ui-sortable&gt;
1057+
&lt;li&gt;First&lt;/li&gt;
1058+
&lt;li&gt;Second&lt;/li&gt;
1059+
&lt;li&gt;Third&lt;/li&gt;
1060+
&lt;/ul&gt;</pre>
1061+
</div>
1062+
</div>
1063+
</section>
1064+
9731065
<section id="directives-currency" ng-controller="CurrencyCtrl">
9741066
<div class="page-header">
9751067
<h1>Currency</h1>

js/app.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,15 @@ function ValidateCtrl($scope) {
9393
};
9494
}
9595

96+
function SortableCtrl($scope) {
97+
$scope.parents = [
98+
{ name: 'Anna', children: ['Alvin', 'Becky' ,'Charlie'] },
99+
{ name: 'Barney', children: ['Dorothy', 'Eric'] },
100+
{ name: 'Chris', children: ['Frank', 'Gary', 'Henry'] }
101+
];
102+
$scope.items = ['One', 'Two', 'Three'];
103+
}
104+
96105
function ScrollfixCtrl($scope) {
97106
$scope.scrollfix = -50;
98107
}

0 commit comments

Comments
 (0)