瀏覽代碼

Initial support for persisting selections

master
Chris Smith 13 年之前
父節點
當前提交
e73ad50331
共有 3 個文件被更改,包括 16 次插入2 次删除
  1. 3
    0
      .gitmodules
  2. 1
    0
      externals/jquery.history
  3. 12
    2
      index.html

+ 3
- 0
.gitmodules 查看文件

1
 [submodule "externals/flot"]
1
 [submodule "externals/flot"]
2
 	path = externals/flot
2
 	path = externals/flot
3
 	url = https://github.com/FooBarWidget/flot.git
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

1
+Subproject commit 09cdb9b6a13924152b67d89da57bb912f04fb0fc

+ 12
- 2
index.html 查看文件

6
   <script src="externals/flot/jquery.flot.js" type="text/javascript"></script>
6
   <script src="externals/flot/jquery.flot.js" type="text/javascript"></script>
7
   <script src="externals/flot/jquery.flot.pie.js" type="text/javascript"></script>
7
   <script src="externals/flot/jquery.flot.pie.js" type="text/javascript"></script>
8
   <script src="externals/flot/jquery.flot.selection.js" type="text/javascript"></script>
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
   <script src="data.php" type="text/javascript"></script>
10
   <script src="data.php" type="text/javascript"></script>
10
   <script type="text/javascript">
11
   <script type="text/javascript">
11
    var previousPoint = null;
12
    var previousPoint = null;
147
      var startDate = parseInt(ranges.xaxis.from.toFixed());
148
      var startDate = parseInt(ranges.xaxis.from.toFixed());
148
      var endDate = parseInt(ranges.xaxis.to.toFixed());
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
     $('#history').bind('plotclick', function(event, pos, item) {
154
     $('#history').bind('plotclick', function(event, pos, item) {
154
      if (item) {
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
      $('#historytable .data').hide();
161
      $('#historytable .data').hide();
161
      $('#historytable .category' + item.series.label.replace(/[^a-zA-Z]*/g, '')).show();
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
   </script>
174
   </script>
165
   <style type="text/css">
175
   <style type="text/css">

Loading…
取消
儲存