xeditableCtrl.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. 'use strict';
  2. /**
  3. * controller for xeditable
  4. */
  5. app.controller('TextSimpleCtrl', ["$scope",
  6. function($scope) {
  7. $scope.example = {
  8. name: 'awesome user'
  9. };
  10. }]);
  11. app.controller('SelectLocalCtrl', ["$scope", "$filter",
  12. function($scope, $filter) {
  13. $scope.example = {
  14. status: 2
  15. };
  16. $scope.statuses = [{
  17. value: 1,
  18. text: 'status1'
  19. }, {
  20. value: 2,
  21. text: 'status2'
  22. }, {
  23. value: 3,
  24. text: 'status3'
  25. }, {
  26. value: 4,
  27. text: 'status4'
  28. }];
  29. $scope.showStatus = function() {
  30. var selected = $filter('filter')($scope.statuses, {
  31. value: $scope.example.status
  32. });
  33. return ($scope.example.status && selected.length) ? selected[0].text : 'Not set';
  34. };
  35. }]);
  36. app.controller('TextareaCtrl', ["$scope",
  37. function($scope) {
  38. $scope.example = {
  39. desc: 'Awesome user \ndescription!'
  40. };
  41. }]);
  42. app.controller('SelectRemoteCtrl', ["$scope", "$filter", "$http",
  43. function($scope, $filter, $http) {
  44. $scope.example = {
  45. group: 4,
  46. groupName: 'admin' // original value
  47. };
  48. $scope.groups = [];
  49. $scope.loadGroups = function() {
  50. return $scope.groups.length ? null : $http.get('assets/api/groups.js').success(function(data) {
  51. $scope.groups = data.groups;
  52. });
  53. };
  54. $scope.$watch('example.group', function(newVal, oldVal) {
  55. if(newVal !== oldVal) {
  56. var selected = $filter('filter')($scope.groups, {
  57. id: $scope.example.group
  58. });
  59. $scope.example.groupName = selected.length ? selected[0].text : null;
  60. }
  61. });
  62. }]);
  63. app.controller('CheckboxCtrl', ["$scope",
  64. function($scope) {
  65. $scope.example = {
  66. remember: true
  67. };
  68. }]);
  69. app.controller('ChecklistCtrl', ["$scope", "$filter",
  70. function($scope, $filter) {
  71. $scope.example = {
  72. status: [2, 3]
  73. };
  74. $scope.statuses = [{
  75. value: 1,
  76. text: 'status1'
  77. }, {
  78. value: 2,
  79. text: 'status2'
  80. }, {
  81. value: 3,
  82. text: 'status3'
  83. }];
  84. $scope.showStatus = function() {
  85. var selected = [];
  86. angular.forEach($scope.statuses, function(s) {
  87. if($scope.example.status.indexOf(s.value) >= 0) {
  88. selected.push(s.text);
  89. }
  90. });
  91. return selected.length ? selected.join(', ') : 'Not set';
  92. };
  93. }]);
  94. app.controller('RadiolistCtrl', ["$scope", "$filter",
  95. function($scope, $filter) {
  96. $scope.example = {
  97. status: 2
  98. };
  99. $scope.statuses = [{
  100. value: 1,
  101. text: 'status1'
  102. }, {
  103. value: 2,
  104. text: 'status2'
  105. }];
  106. $scope.showStatus = function() {
  107. var selected = $filter('filter')($scope.statuses, {
  108. value: $scope.example.status
  109. });
  110. return ($scope.example.status && selected.length) ? selected[0].text : 'Not set';
  111. };
  112. }]);
  113. app.controller('BsdateCtrl', ["$scope",
  114. function($scope) {
  115. $scope.example = {
  116. dob: new Date(1984, 4, 15)
  117. };
  118. }]);
  119. app.controller('TypeaheadCtrl', ["$scope",
  120. function($scope) {
  121. $scope.user = {
  122. state: 'Arizona'
  123. };
  124. $scope.states = ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Dakota', 'North Carolina', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming'];
  125. }]);
  126. app.controller('TextCustomizeCtrl', ["$scope",
  127. function($scope) {
  128. $scope.user = {
  129. name: 'awesome user'
  130. };
  131. }]);
  132. app.controller('TextBtnCtrl', ["$scope",
  133. function($scope) {
  134. $scope.user = {
  135. name: 'awesome user'
  136. };
  137. }]);
  138. app.controller('SelectNobuttonsCtrl', ["$scope", "$filter",
  139. function($scope, $filter) {
  140. $scope.user = {
  141. status: 2
  142. };
  143. $scope.statuses = [{
  144. value: 1,
  145. text: 'status1'
  146. }, {
  147. value: 2,
  148. text: 'status2'
  149. }, {
  150. value: 3,
  151. text: 'status3'
  152. }, {
  153. value: 4,
  154. text: 'status4'
  155. }];
  156. $scope.showStatus = function() {
  157. var selected = $filter('filter')($scope.statuses, {
  158. value: $scope.user.status
  159. });
  160. return ($scope.user.status && selected.length) ? selected[0].text : 'Not set';
  161. };
  162. }]);
  163. app.controller('SelectMultipleCtrl', ["$scope", "$filter",
  164. function($scope, $filter) {
  165. $scope.user = {
  166. status: [2, 4]
  167. };
  168. $scope.statuses = [{
  169. value: 1,
  170. text: 'status1'
  171. }, {
  172. value: 2,
  173. text: 'status2'
  174. }, {
  175. value: 3,
  176. text: 'status3'
  177. }, {
  178. value: 4,
  179. text: 'status4'
  180. }];
  181. $scope.showStatus = function() {
  182. var selected = [];
  183. angular.forEach($scope.statuses, function(s) {
  184. if($scope.user.status.indexOf(s.value) >= 0) {
  185. selected.push(s.text);
  186. }
  187. });
  188. return selected.length ? selected.join(', ') : 'Not set';
  189. };
  190. }]);