mirror of
https://github.com/apache/archiva.git
synced 2025-02-21 17:35:19 +00:00
use a dialog confirm based on bootstrap modal, jqueryui was a bit ugly
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1225532 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
49be96fe11
commit
457e5894be
@ -16,12 +16,14 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
require(["text!archiva/templates/menu.html","text!archiva/templates/topbar.html","text!archiva/templates/message.html"],
|
||||
function(menu,topbar,message) {
|
||||
require(["text!archiva/templates/menu.html","text!archiva/templates/topbar.html","text!archiva/templates/message.html",
|
||||
"text!archiva/templates/modal.html"],
|
||||
function(menu,topbar,message,modal) {
|
||||
|
||||
// template loading
|
||||
$.tmpl( menu, $.i18n.map ).appendTo("#html-fragments");
|
||||
$.tmpl( topbar, $.i18n.map ).appendTo("#html-fragments");
|
||||
$.tmpl( modal, $.i18n.map ).appendTo("#html-fragments");
|
||||
$("#html-fragments").append(message);
|
||||
$.log("main-tmpl.js menu loaded");
|
||||
}
|
||||
|
@ -26,6 +26,9 @@ <h4 class="brand"><a href="index.html">Archiva</a></h4>
|
||||
<span class="label notice">${register}</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" onclick="openDialogConfirm(function(){alert('ok')}, 'okMessage', 'cancelMessage', 'title')">test</a>
|
||||
</li>
|
||||
</ul>
|
||||
<form class="pull-right" action="">
|
||||
<input type="text" placeholder="Search" />
|
||||
|
@ -102,4 +102,78 @@ clearForm=function(selectorStr){
|
||||
$(this).val("");
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* open a confirm dialog based on bootstrap modal
|
||||
* @param okFn callback function to call on ok confirm
|
||||
* @param okMessage
|
||||
* @param cancelMessage
|
||||
* @param title
|
||||
*/
|
||||
openDialogConfirm=function(okFn, okMessage, cancelMessage, title,bodyText){
|
||||
if (window.modalConfirmDialog==null) {
|
||||
window.modalConfirmDialog = $("#dialog-confirm-modal").modal({backdrop:'static',show:false});
|
||||
window.modalConfirmDialog.bind('hidden', function () {
|
||||
$("#dialog-confirm-modal-header-title").html("");
|
||||
$("#dialog-confirm-modal-body-text").html("");
|
||||
})
|
||||
$("#dialog-confirm-modal-cancel").on("click", function(){
|
||||
window.modalConfirmDialog.modal('hide');
|
||||
});
|
||||
}
|
||||
$("#dialog-confirm-modal-header-title").html(title);
|
||||
$("#dialog-confirm-modal-body-text").html(bodyText);
|
||||
if (okMessage){
|
||||
$("#dialog-confirm-modal-ok").html(okMessage);
|
||||
}
|
||||
if (cancelMessage){
|
||||
$("#dialog-confirm-modal-cancel").html(cancelMessage);
|
||||
}
|
||||
window.modalConfirmDialog.modal('show');
|
||||
|
||||
// unbind previous events !!
|
||||
$("#dialog-confirm-modal-ok").off( );
|
||||
$("#dialog-confirm-modal-ok").on("click", okFn);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* return a small spinner html img element
|
||||
*/
|
||||
smallSpinnerImg=function(){
|
||||
return "<img id=\"login-spinner\" src=\"images/small-spinner.gif\"/>";
|
||||
};
|
||||
|
||||
closeDialogConfirm=function(){
|
||||
window.modalConfirmDialog.modal('hide');
|
||||
}
|
||||
|
||||
closeDialogConfirmui=function(){
|
||||
$("#dialog-confirm" ).dialog("close");
|
||||
}
|
||||
|
||||
/**
|
||||
* open a confirm dialog with jqueryui
|
||||
* @param okFn callback function to call on ok confirm
|
||||
* @param okMessage
|
||||
* @param cancelMessage
|
||||
* @param title
|
||||
*/
|
||||
openDialogConfirmui=function(okFn, okMessage, cancelMessage, title){
|
||||
$("#dialog-confirm" ).dialog({
|
||||
resizable: false,
|
||||
title: title,
|
||||
modal: true,
|
||||
show: 'slide',
|
||||
buttons: [{
|
||||
text: okMessage,
|
||||
click: okFn},
|
||||
{
|
||||
text: cancelMessage,
|
||||
click:function() {
|
||||
$(this).dialog( "close" );
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
@ -52,42 +52,6 @@ $(function() {
|
||||
//nothing
|
||||
});
|
||||
|
||||
/**
|
||||
* return a small spinner html img element
|
||||
*/
|
||||
smallSpinnerImg=function(){
|
||||
return "<img id=\"login-spinner\" src=\"images/small-spinner.gif\"/>";
|
||||
};
|
||||
|
||||
/**
|
||||
* open a confirm dialog
|
||||
* @param okFn callback function to call on ok confirm
|
||||
* @param okMessage
|
||||
* @param cancelMessage
|
||||
* @param title
|
||||
*/
|
||||
openDialogConfirm=function(okFn, okMessage, cancelMessage, title){
|
||||
$("#dialog-confirm" ).dialog({
|
||||
resizable: false,
|
||||
title: title,
|
||||
modal: true,
|
||||
show: 'slide',
|
||||
buttons: [{
|
||||
text: okMessage,
|
||||
click: okFn},
|
||||
{
|
||||
text: cancelMessage,
|
||||
click:function() {
|
||||
$(this).dialog( "close" );
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
closeDialogConfirm=function(){
|
||||
$("#dialog-confirm" ).dialog("close");
|
||||
}
|
||||
|
||||
/**
|
||||
* return a user see user.js if user logged otherwise null
|
||||
*/
|
||||
|
@ -23,7 +23,7 @@ <h3>${$.i18n.prop('login.section.title')}</h3>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer" id="modal-login-footer">
|
||||
<button class="btn primary" onclick="return login();" id="modal-login-ok">${login}</button>
|
||||
<button class="btn primary" onclick="return login();" id="modal-login-ok">${login}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -132,7 +132,7 @@ $(function() {
|
||||
|
||||
this.deleteUser=function() {
|
||||
clearUserMessages();
|
||||
// FIXME i18n
|
||||
|
||||
var currentUser = this;
|
||||
openDialogConfirm(function(){
|
||||
$.ajax("restServices/redbackServices/userService/deleteUser/"+currentUser.username(), {
|
||||
|
Loading…
x
Reference in New Issue
Block a user