diff.js revision 28c081bad540f7e3eb8abd2a5a9a1b6fc706f558
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* See LICENSE.txt included in this distribution for the specific
* language governing permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at LICENSE.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/*
* This file contains JavaScript code used by diff.jsp.
*/
(function(window, $){
/*
* DiffJumper module
*
* called for example like
* $("#difftable").diffTable(options)
* where options are
* {
* $parent: // jQuery object for common anchestor of all diff features
* $content: // jQuery object which is anchestor and scrollable - fixing animation
* chunkSelector: // String describing chunk selection
* addSelector: // String describing added lines
* delSelector: // String describin deleted lines
* $toggleButton: // jQuery object of button to toggle the jumper window
* animationDuration: // duration of toggling the jumper window
* }
*/
var inner = {
initialized: false,
currentIndex: -1,
$changes: $(),
options: {},
defaults: {
$parent: $("#difftable"),
chunkSelector: ".chunk",
addSelector: ".a",
delSelector: ".d",
$toggleButton: $("#toggle-jumper"),
animationDuration: 500
},
/*
* Whole panel looks like this in code
* Other css rules are described in style.css
* <div class="diff_navigation">
* <div class="header">
* <span class="prev summary">4/30 chunks</span>
* <a href="#" class="minimize">_</a>
* </div>
* <div class="controls">
* <a href="#" class="prev"><< Previous</a>
* <a href="#" class="next">Next >></a>
* </div>
* <div class="progress">
* </div>
* <div class="errors">
* </div>
* </div>
*/
$panel: null,
$summary: null,
$errors: null,
$progress: null,
},
prevHandler: function (e) {
e.preventDefault()
inner.initChanges();
return false
}
inner.currentIndex --;
return false
},
nextHandler: function(e) {
e.preventDefault()
inner.initChanges();
return false
}
inner.currentIndex ++;
return false
},
createPanel: function(){
.appendTo($("body"))
.addClass("diff_navigation_style")
.addClass("diff_navigation")
.hide()
},
createHeader: function() {
var $cancel = $("<a href='#' class='minimize'>_</a>")
.click(function(e){
opacity: 0
});
});
.bind("diff.summary.refresh", function (e) {
});
var $controls = $("<div class=\"header\"></div>")
},
createButtons: function() {
var $prev = $("<a href='#' class='prev' title='Jump to previous chunk (shortcut b)'><< Previous</a>")
var $next = $("<a href='#' class='next' title='Jump to next chunk (shortcut n)'>Next >></a>")
var $controls = $("<div class=\"controls\"></div>")
},
createErrors: function(){
var $errors = $("<div class=\"errors\"></div>")
}
},
createProgress: function(){
var $progress = $("<div class=\"progress\"></div>")
}
},
initChanges: function(){
return
// get all changes
},
init: function(){
inner.createPanel();
// set initial position by the toggle button
opacity: 0
}).hide();
});
// bind animation features
inner.initChanges();
if(flag == "showing") {
opacity: 0
$(this).data("animation-in-progress", null );
});
} else {
opacity: 1
$(this).data("animation-in-progress", null );
})
}
return false
});
}
}
if (inner.initialized)
return
// bind n and b to special events
switch(key) {
case 110: // n
inner.nextHandler(e)
break;
case 98: // b
inner.prevHandler(e)
break;
default:
}
});
inner.initialized = true
return this
}
return this.each(function(){
});
}
// Code to be called when the DOM for diff.jsp is ready.
$("#difftable").diffTable();
});