scinote-web/app/assets/javascripts/repositories/index.js

60 lines
1.5 KiB
JavaScript
Raw Normal View History

(function() {
'use strict';
2017-06-14 15:11:20 +08:00
function loadRepositoryTab() {
var param, pane;
$('#repository-tabs a').on("click", function(e) {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
pane = $(this);
$.ajax({
2017-06-14 16:55:24 +08:00
url: pane.attr('data-url'),
2017-06-14 15:11:20 +08:00
type: 'GET',
dataType: 'json',
2017-06-14 16:55:24 +08:00
success: function(data) {
var tabBody = $(pane.context.hash).find('.tab-content-body');
2017-06-14 15:11:20 +08:00
tabBody.html(data.html);
pane.tab('show');
},
error: function (error) {
// TODO
}
});
});
// on page load
if( param = getParam('repository') ){
// load selected tab
$('a[href="#custom_repo_' + param + '"]').click();
}
else {
// load first tab content
$('#repository-tabs a:first').click();
}
// clean tab content
$('a[data-toggle="tab"]').on('hide.bs.tab', function (e) {
$(".tab-content-body").html("");
})
}
2017-06-14 16:55:24 +08:00
function showParsedRecords() {
$('#form-records-file').bind('ajax:success', function(evt, data, status, xhr) {
debugger;
});
}
$('.delete-repo-option').initializeModal('#delete-repo-modal');
$('.rename-repo-option').initializeModal('#rename-repo-modal');
2017-06-08 00:43:48 +08:00
$('.copy-repo-option').initializeModal('#copy-repo-modal');
2017-06-06 21:50:43 +08:00
$('.create-repository').initializeModal('#create-repo-modal');
2017-06-08 17:44:24 +08:00
2017-06-14 15:11:20 +08:00
$(document).ready(function() {
loadRepositoryTab();
2017-06-14 16:55:24 +08:00
showParsedRecords();
2017-06-08 17:44:24 +08:00
});
2017-06-14 15:11:20 +08:00
})();