Built motion from commit 54a160d.|0.0.140
[motion.git] / public / bower_components / angular-smart-table / smart-table.js
index 871bb9c..e0246d4 100644 (file)
@@ -1,5 +1,5 @@
 /** 
-* @version 2.1.5
+* @version 2.1.8
 * @license MIT
 */
 (function (ng, undefined){
@@ -8,7 +8,7 @@
 ng.module('smart-table', []).run(['$templateCache', function ($templateCache) {
     $templateCache.put('template/smart-table/pagination.html',
         '<nav ng-if="numPages && pages.length >= 2"><ul class="pagination">' +
-        '<li ng-repeat="page in pages" ng-class="{active: page==currentPage}"><a ng-click="selectPage(page)">{{page}}</a></li>' +
+        '<li ng-repeat="page in pages" ng-class="{active: page==currentPage}"><a href="javascript: void(0);" ng-click="selectPage(page)">{{page}}</a></li>' +
         '</ul></nav>');
 }]);
 
@@ -31,6 +31,7 @@ ng.module('smart-table')
     sort: {
       ascentClass: 'st-sort-ascent',
       descentClass: 'st-sort-descent',
+      descendingFirst: false,
       skipNatural: false,
       delay:300
     },
@@ -344,6 +345,7 @@ ng.module('smart-table')
         var stateClasses = [classAscent, classDescent];
         var sortDefault;
         var skipNatural = attr.stSkipNatural !== undefined ? attr.stSkipNatural : stConfig.sort.skipNatural;
+        var descendingFirst = attr.stDescendingFirst !== undefined ? attr.stDescendingFirst : stConfig.sort.descendingFirst;
         var promise = null;
         var throttle = attr.stDelay || stConfig.sort.delay;
 
@@ -353,7 +355,12 @@ ng.module('smart-table')
 
         //view --> table state
         function sort () {
-          index++;
+          if (descendingFirst) {
+            index = index === 0 ? 2 : index - 1;
+          } else {
+            index++;
+          }
+
           var func;
           predicate = ng.isFunction(getter(scope)) || ng.isArray(getter(scope)) ? getter(scope) : attr.stSort;
           if (index % 3 === 0 && !!skipNatural !== true) {
@@ -369,7 +376,7 @@ ng.module('smart-table')
             $timeout.cancel(promise);
           }
           if (throttle < 0) {
-            scope.$apply(func);
+            func();
           } else {
             promise = $timeout(func, throttle);
           }
@@ -377,7 +384,7 @@ ng.module('smart-table')
 
         element.bind('click', function sortClick () {
           if (predicate) {
-            sort();
+            scope.$apply(sort);
           }
         });