mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-23 06:37:15 +00:00
search preview modal do not duplicate anymore but still needs improvements
This commit is contained in:
parent
f29620cf96
commit
74b337f1a1
1 changed files with 17 additions and 8 deletions
|
@ -132,6 +132,10 @@ $(document).ready(function(){
|
|||
|
||||
<!-- Dynamically update the modal -->
|
||||
<script type="text/javascript">
|
||||
// static data
|
||||
var alert_message = '<div class="alert alert-info alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><strong>No more data.</strong>The full paste is displayed.</div>';
|
||||
|
||||
|
||||
// On click, get html content from url and update the corresponding modal
|
||||
$("[data-toggle='modal']").on("click", function (event) {
|
||||
event.preventDefault();
|
||||
|
@ -139,26 +143,30 @@ $(document).ready(function(){
|
|||
var url = " {{ url_for('showpreviewpaste') }}?paste=" + $(this).attr('data-path') + "&num=" + $(this).attr('data-num');
|
||||
$.get(url, function (data) {
|
||||
$("#mymodalbody").html(data);
|
||||
|
||||
var button = '<button type="button" id="load-more-button" class="btn btn-info btn-xs pull-left" data-url="' + $(modal).attr('data-path') +'" data-toggle="tooltip" data-placement="bottom" title="Load more content"><span class="glyphicon glyphicon-download"></span></button>';
|
||||
var button = '<button type="button" id="load-more-button" class="btn btn-info btn-xs center-block" data-url="' + $(modal).attr('data-path') +'" data-toggle="tooltip" data-placement="bottom" title="Load more content"><span class="glyphicon glyphicon-download"></span></button>';
|
||||
$("#mymodalbody").children(".panel-default").append(button);
|
||||
|
||||
$("#button_show_path").attr('href', $(modal).attr('data-url'));
|
||||
$("#button_show_path").show('fast');
|
||||
|
||||
var index_preview = 0 // used for load more preview
|
||||
var index_preview = 1 // used for load more preview
|
||||
|
||||
// On load more content click, replace paste content
|
||||
$("#load-more-button").on("click", function (event) {
|
||||
$.get("{{ url_for('getmoredata') }}"+"?paste="+$(modal).attr('data-path')+"&index="+index_preview, function(data, status){
|
||||
index_preview++;
|
||||
console.log($("#mymodalbody").find("#panel-body"));
|
||||
if (data != "") {
|
||||
var new_content = $('<p><xmp>'+data+'</xmp></p>').hide();
|
||||
$("#mymodalbody").find("#panel-body").append(new_content);
|
||||
new_content.show('fast');
|
||||
} else { // no more data
|
||||
var new_content = $(alert_message).hide();
|
||||
$("#mymodalbody").find("#panel-body").append(new_content);
|
||||
new_content.show('fast');
|
||||
$("#load-more-button").hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -166,6 +174,7 @@ $(document).ready(function(){
|
|||
$("#mymodal").on('hidden.bs.modal', function () {
|
||||
$("#mymodalbody").html("<p>Loading paste information...</p>");
|
||||
$("#button_show_path").attr('href', '');
|
||||
$("#button_show_path").hide();
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue