2011-01-11 Ojan Vafai <ojan@chromium.org>
authorojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Jan 2011 23:56:50 +0000 (23:56 +0000)
committerojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Jan 2011 23:56:50 +0000 (23:56 +0000)
        Reviewed by Adam Barth.

        remember diffstate for review tool
        https://bugs.webkit.org/show_bug.cgi?id=52253

        If you use the global sidebyside/unified links, store the diff type
        in localstorage. Then, onload, use that diff type. That way, people
        who prefer one diff type or the other can always get that by default.

        * code-review.js:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75565 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Websites/bugs.webkit.org/ChangeLog
Websites/bugs.webkit.org/code-review.js

index 8e3b1dc654428078fedff6add1a146ff8cb384ea..18f13d6addfd58d1c4a1100117affe3c8372a5c4 100644 (file)
@@ -1,3 +1,16 @@
+2011-01-11  Ojan Vafai  <ojan@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        remember diffstate for review tool
+        https://bugs.webkit.org/show_bug.cgi?id=52253
+
+        If you use the global sidebyside/unified links, store the diff type
+        in localstorage. Then, onload, use that diff type. That way, people
+        who prefer one diff type or the other can always get that by default.
+
+        * code-review.js:
+
 2011-01-11  Ojan Vafai  <ojan@chromium.org>
 
         Reviewed by Adam Barth.
index 09727d9b6f636c077d69486f5b11b0173cce9401..b7f19737d9886fd013f3c5913ce5bfa625a782cf 100644 (file)
 
   function convertDiff(difftype, convert_link) {
     var file_diffs = $(convert_link).parents('.FileDiff');
-    if (!file_diffs.size())
+    if (!file_diffs.size()) {
+      localStorage.setItem('code-review-diffstate', difftype);
       file_diffs = $('.FileDiff');
+    }
 
-    file_diffs.each(function() {
-      convertFileDiff(difftype, this);
-    });
+    convertAllFileDiffs(difftype, file_diffs);
   }
 
   function getWebKitSourceFile(file_name, onLoad, expand_bar) {
     $(resize_iframe[0].contentWindow).bind('resize', onBodyResize);
 
     updateToolbarAnchorState();
+    loadDiffState();
   });
 
+  function loadDiffState() {
+    var diffstate = localStorage.getItem('code-review-diffstate');
+    if (diffstate != 'sidebyside' && diffstate != 'unified')
+      return;
+
+    convertAllFileDiffs(diffstate, $('.FileDiff'));
+  }
+
   function isDiffSideBySide(file_diff) {
     return diffState(file_diff) == 'sidebyside';
   }
     }
   }
 
+  function convertAllFileDiffs(diff_type, file_diffs) {
+    file_diffs.each(function() {
+      convertFileDiff(diff_type, this);
+    });
+  }
+
   function convertFileDiff(diff_type, file_diff) {
     if (diffState(file_diff) == diff_type)
       return;