+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.
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;