Ver código fonte

Initial support for persisting selections

master
Chris Smith 13 anos atrás
pai
commit
e73ad50331
3 arquivos alterados com 16 adições e 2 exclusões
  1. 3
    0
      .gitmodules
  2. 1
    0
      externals/jquery.history
  3. 12
    2
      index.html

+ 3
- 0
.gitmodules Ver arquivo

@@ -1,3 +1,6 @@
1 1
 [submodule "externals/flot"]
2 2
 	path = externals/flot
3 3
 	url = https://github.com/FooBarWidget/flot.git
4
+[submodule "externals/jquery.history"]
5
+	path = externals/jquery.history
6
+	url = https://github.com/tkyk/jquery-history-plugin.git

+ 1
- 0
externals/jquery.history

@@ -0,0 +1 @@
1
+Subproject commit 09cdb9b6a13924152b67d89da57bb912f04fb0fc

+ 12
- 2
index.html Ver arquivo

@@ -6,6 +6,7 @@
6 6
   <script src="externals/flot/jquery.flot.js" type="text/javascript"></script>
7 7
   <script src="externals/flot/jquery.flot.pie.js" type="text/javascript"></script>
8 8
   <script src="externals/flot/jquery.flot.selection.js" type="text/javascript"></script>
9
+  <script src="externals/jquery.history/jquery.history.js" type="text/javascript"></script>
9 10
   <script src="data.php" type="text/javascript"></script>
10 11
   <script type="text/javascript">
11 12
    var previousPoint = null;
@@ -147,12 +148,12 @@
147 148
      var startDate = parseInt(ranges.xaxis.from.toFixed());
148 149
      var endDate = parseInt(ranges.xaxis.to.toFixed());
149 150
     
150
-     showSelectedMonths(startDate, endDate, 0); 
151
+     $.history.load('start:' + startDate + ';end:' + endDate + ';type:expenses'); 
151 152
     });
152 153
 
153 154
     $('#history').bind('plotclick', function(event, pos, item) {
154 155
      if (item) {
155
-      showSelectedMonths(item.datapoint[0], item.datapoint[0], item.seriesIndex == 0, item.seriesIndex == 1);
156
+      $.history.load('start:' + item.datapoint[0] + ';end:' + item.datapoint[0] + ';type:' + (item.seriesIndex == 0 ? 'income' : 'expenses'));
156 157
      }
157 158
     });
158 159
 
@@ -160,6 +161,15 @@
160 161
      $('#historytable .data').hide();
161 162
      $('#historytable .category' + item.series.label.replace(/[^a-zA-Z]*/g, '')).show();
162 163
     });
164
+
165
+    $.history.init(function(hash) {
166
+     var match = /start:([0-9]+);end:([0-9]+);type:(income|expenses)/.exec(hash);
167
+
168
+     if (match != null) {
169
+      showSelectedMonths(parseInt(match[1]), parseInt(match[2]), match[3] == 'income', match[3] == 'expenses');
170
+      plots.history.setSelection({ xaxis: { from: parseInt(match[1]), to: parseInt(match[2]) }});
171
+     }
172
+    });
163 173
    });
164 174
   </script>
165 175
   <style type="text/css">

Carregando…
Cancelar
Salvar