mirror of https://github.com/gophish/gophish
Fixing scrollbar on nested modals. Fixes #598
parent
26d2ca7344
commit
015ea9bc2d
|
@ -1 +1 @@
|
||||||
function save(e){var a={};a.name=$("#name").val(),editor=CKEDITOR.instances.html_editor,a.html=editor.getData(),a.capture_credentials=$("#capture_credentials_checkbox").prop("checked"),a.capture_passwords=$("#capture_passwords_checkbox").prop("checked"),a.redirect_url=$("#redirect_url_input").val(),e!=-1?(a.id=pages[e].id,api.pageId.put(a).success(function(e){successFlash("Page edited successfully!"),load(),dismiss()})):api.pages.post(a).success(function(e){successFlash("Page added successfully!"),load(),dismiss()}).error(function(e){modalError(e.responseJSON.message)})}function dismiss(){$("#modal\\.flashes").empty(),$("#name").val(""),$("#html_editor").val(""),$("#url").val(""),$("#redirect_url_input").val(""),$("#modal").find("input[type='checkbox']").prop("checked",!1),$("#capture_passwords").hide(),$("#redirect_url").hide(),$("#modal").modal("hide")}function deletePage(e){confirm("Delete "+pages[e].name+"?")&&api.pageId.delete(pages[e].id).success(function(e){successFlash(e.message),load()})}function importSite(){url=$("#url").val(),url?api.clone_site({url:url,include_resources:!1}).success(function(e){console.log($("#html_editor")),$("#html_editor").val(e.html),$("#importSiteModal").modal("hide")}).error(function(e){modalError(e.responseJSON.message)}):modalError("No URL Specified!")}function edit(e){$("#modalSubmit").unbind("click").click(function(){save(e)}),$("#html_editor").ckeditor();var a={};e!=-1&&(a=pages[e],$("#name").val(a.name),$("#html_editor").val(a.html),$("#capture_credentials_checkbox").prop("checked",a.capture_credentials),$("#capture_passwords_checkbox").prop("checked",a.capture_passwords),$("#redirect_url_input").val(a.redirect_url),a.capture_credentials&&($("#capture_passwords").show(),$("#redirect_url").show()))}function copy(e){$("#modalSubmit").unbind("click").click(function(){save(-1)}),$("#html_editor").ckeditor();var a=pages[e];$("#name").val("Copy of "+a.name),$("#html_editor").val(a.html)}function load(){$("#pagesTable").hide(),$("#emptyMessage").hide(),$("#loading").show(),api.pages.get().success(function(e){pages=e,$("#loading").hide(),pages.length>0?($("#pagesTable").show(),pagesTable=$("#pagesTable").DataTable({destroy:!0,columnDefs:[{orderable:!1,targets:"no-sort"}]}),pagesTable.clear(),$.each(pages,function(e,a){pagesTable.row.add([escapeHtml(a.name),moment(a.modified_date).format("MMMM Do YYYY, h:mm:ss a"),"<div class='pull-right'><span data-toggle='modal' data-target='#modal'><button class='btn btn-primary' data-toggle='tooltip' data-placement='left' title='Edit Page' onclick='edit("+e+")'> <i class='fa fa-pencil'></i> </button></span>\t\t <span data-toggle='modal' data-target='#modal'><button class='btn btn-primary' data-toggle='tooltip' data-placement='left' title='Copy Page' onclick='copy("+e+")'> <i class='fa fa-copy'></i> </button></span> <button class='btn btn-danger' data-toggle='tooltip' data-placement='left' title='Delete Page' onclick='deletePage("+e+")'> <i class='fa fa-trash-o'></i> </button></div>"]).draw()}),$('[data-toggle="tooltip"]').tooltip()):$("#emptyMessage").show()}).error(function(){$("#loading").hide(),errorFlash("Error fetching pages")})}var pages=[];$(document).ready(function(){$(".modal").on("hidden.bs.modal",function(e){$(this).removeClass("fv-modal-stack"),$("body").data("fv_open_modals",$("body").data("fv_open_modals")-1)}),$(".modal").on("shown.bs.modal",function(e){"undefined"==typeof $("body").data("fv_open_modals")&&$("body").data("fv_open_modals",0),$(this).hasClass("fv-modal-stack")||($(this).addClass("fv-modal-stack"),$("body").data("fv_open_modals",$("body").data("fv_open_modals")+1),$(this).css("z-index",1040+10*$("body").data("fv_open_modals")),$(".modal-backdrop").not(".fv-modal-stack").css("z-index",1039+10*$("body").data("fv_open_modals")),$(".modal-backdrop").not("fv-modal-stack").addClass("fv-modal-stack"))}),$.fn.modal.Constructor.prototype.enforceFocus=function(){$(document).off("focusin.bs.modal").on("focusin.bs.modal",$.proxy(function(e){this.$element[0]===e.target||this.$element.has(e.target).length||$(e.target).closest(".cke_dialog, .cke").length||this.$element.trigger("focus")},this))},$("#modal").on("hidden.bs.modal",function(e){dismiss()}),$("#capture_credentials_checkbox").change(function(){$("#capture_passwords").toggle(),$("#redirect_url").toggle()}),load()});
|
function save(e){var a={};a.name=$("#name").val(),editor=CKEDITOR.instances.html_editor,a.html=editor.getData(),a.capture_credentials=$("#capture_credentials_checkbox").prop("checked"),a.capture_passwords=$("#capture_passwords_checkbox").prop("checked"),a.redirect_url=$("#redirect_url_input").val(),e!=-1?(a.id=pages[e].id,api.pageId.put(a).success(function(e){successFlash("Page edited successfully!"),load(),dismiss()})):api.pages.post(a).success(function(e){successFlash("Page added successfully!"),load(),dismiss()}).error(function(e){modalError(e.responseJSON.message)})}function dismiss(){$("#modal\\.flashes").empty(),$("#name").val(""),$("#html_editor").val(""),$("#url").val(""),$("#redirect_url_input").val(""),$("#modal").find("input[type='checkbox']").prop("checked",!1),$("#capture_passwords").hide(),$("#redirect_url").hide(),$("#modal").modal("hide")}function deletePage(e){confirm("Delete "+pages[e].name+"?")&&api.pageId.delete(pages[e].id).success(function(e){successFlash(e.message),load()})}function importSite(){url=$("#url").val(),url?api.clone_site({url:url,include_resources:!1}).success(function(e){console.log($("#html_editor")),$("#html_editor").val(e.html),$("#importSiteModal").modal("hide")}).error(function(e){modalError(e.responseJSON.message)}):modalError("No URL Specified!")}function edit(e){$("#modalSubmit").unbind("click").click(function(){save(e)}),$("#html_editor").ckeditor();var a={};e!=-1&&(a=pages[e],$("#name").val(a.name),$("#html_editor").val(a.html),$("#capture_credentials_checkbox").prop("checked",a.capture_credentials),$("#capture_passwords_checkbox").prop("checked",a.capture_passwords),$("#redirect_url_input").val(a.redirect_url),a.capture_credentials&&($("#capture_passwords").show(),$("#redirect_url").show()))}function copy(e){$("#modalSubmit").unbind("click").click(function(){save(-1)}),$("#html_editor").ckeditor();var a=pages[e];$("#name").val("Copy of "+a.name),$("#html_editor").val(a.html)}function load(){$("#pagesTable").hide(),$("#emptyMessage").hide(),$("#loading").show(),api.pages.get().success(function(e){pages=e,$("#loading").hide(),pages.length>0?($("#pagesTable").show(),pagesTable=$("#pagesTable").DataTable({destroy:!0,columnDefs:[{orderable:!1,targets:"no-sort"}]}),pagesTable.clear(),$.each(pages,function(e,a){pagesTable.row.add([escapeHtml(a.name),moment(a.modified_date).format("MMMM Do YYYY, h:mm:ss a"),"<div class='pull-right'><span data-toggle='modal' data-target='#modal'><button class='btn btn-primary' data-toggle='tooltip' data-placement='left' title='Edit Page' onclick='edit("+e+")'> <i class='fa fa-pencil'></i> </button></span>\t\t <span data-toggle='modal' data-target='#modal'><button class='btn btn-primary' data-toggle='tooltip' data-placement='left' title='Copy Page' onclick='copy("+e+")'> <i class='fa fa-copy'></i> </button></span> <button class='btn btn-danger' data-toggle='tooltip' data-placement='left' title='Delete Page' onclick='deletePage("+e+")'> <i class='fa fa-trash-o'></i> </button></div>"]).draw()}),$('[data-toggle="tooltip"]').tooltip()):$("#emptyMessage").show()}).error(function(){$("#loading").hide(),errorFlash("Error fetching pages")})}var pages=[];$(document).ready(function(){$(".modal").on("hidden.bs.modal",function(e){$(this).removeClass("fv-modal-stack"),$("body").data("fv_open_modals",$("body").data("fv_open_modals")-1)}),$(".modal").on("shown.bs.modal",function(e){"undefined"==typeof $("body").data("fv_open_modals")&&$("body").data("fv_open_modals",0),$(this).hasClass("fv-modal-stack")||($(this).addClass("fv-modal-stack"),$("body").data("fv_open_modals",$("body").data("fv_open_modals")+1),$(this).css("z-index",1040+10*$("body").data("fv_open_modals")),$(".modal-backdrop").not(".fv-modal-stack").css("z-index",1039+10*$("body").data("fv_open_modals")),$(".modal-backdrop").not("fv-modal-stack").addClass("fv-modal-stack"))}),$.fn.modal.Constructor.prototype.enforceFocus=function(){$(document).off("focusin.bs.modal").on("focusin.bs.modal",$.proxy(function(e){this.$element[0]===e.target||this.$element.has(e.target).length||$(e.target).closest(".cke_dialog, .cke").length||this.$element.trigger("focus")},this))},$(document).on("hidden.bs.modal",".modal",function(){$(".modal:visible").length&&$(document.body).addClass("modal-open")}),$("#modal").on("hidden.bs.modal",function(e){dismiss()}),$("#capture_credentials_checkbox").change(function(){$("#capture_passwords").toggle(),$("#redirect_url").toggle()}),load()});
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -17,7 +17,7 @@ function save(idx) {
|
||||||
if (idx != -1) {
|
if (idx != -1) {
|
||||||
page.id = pages[idx].id
|
page.id = pages[idx].id
|
||||||
api.pageId.put(page)
|
api.pageId.put(page)
|
||||||
.success(function(data) {
|
.success(function (data) {
|
||||||
successFlash("Page edited successfully!")
|
successFlash("Page edited successfully!")
|
||||||
load()
|
load()
|
||||||
dismiss()
|
dismiss()
|
||||||
|
@ -25,12 +25,12 @@ function save(idx) {
|
||||||
} else {
|
} else {
|
||||||
// Submit the page
|
// Submit the page
|
||||||
api.pages.post(page)
|
api.pages.post(page)
|
||||||
.success(function(data) {
|
.success(function (data) {
|
||||||
successFlash("Page added successfully!")
|
successFlash("Page added successfully!")
|
||||||
load()
|
load()
|
||||||
dismiss()
|
dismiss()
|
||||||
})
|
})
|
||||||
.error(function(data) {
|
.error(function (data) {
|
||||||
modalError(data.responseJSON.message)
|
modalError(data.responseJSON.message)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ function dismiss() {
|
||||||
function deletePage(idx) {
|
function deletePage(idx) {
|
||||||
if (confirm("Delete " + pages[idx].name + "?")) {
|
if (confirm("Delete " + pages[idx].name + "?")) {
|
||||||
api.pageId.delete(pages[idx].id)
|
api.pageId.delete(pages[idx].id)
|
||||||
.success(function(data) {
|
.success(function (data) {
|
||||||
successFlash(data.message)
|
successFlash(data.message)
|
||||||
load()
|
load()
|
||||||
})
|
})
|
||||||
|
@ -67,19 +67,19 @@ function importSite() {
|
||||||
url: url,
|
url: url,
|
||||||
include_resources: false
|
include_resources: false
|
||||||
})
|
})
|
||||||
.success(function(data) {
|
.success(function (data) {
|
||||||
console.log($("#html_editor"))
|
console.log($("#html_editor"))
|
||||||
$("#html_editor").val(data.html)
|
$("#html_editor").val(data.html)
|
||||||
$("#importSiteModal").modal("hide")
|
$("#importSiteModal").modal("hide")
|
||||||
})
|
})
|
||||||
.error(function(data) {
|
.error(function (data) {
|
||||||
modalError(data.responseJSON.message)
|
modalError(data.responseJSON.message)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function edit(idx) {
|
function edit(idx) {
|
||||||
$("#modalSubmit").unbind('click').click(function() {
|
$("#modalSubmit").unbind('click').click(function () {
|
||||||
save(idx)
|
save(idx)
|
||||||
})
|
})
|
||||||
$("#html_editor").ckeditor()
|
$("#html_editor").ckeditor()
|
||||||
|
@ -99,7 +99,7 @@ function edit(idx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function copy(idx) {
|
function copy(idx) {
|
||||||
$("#modalSubmit").unbind('click').click(function() {
|
$("#modalSubmit").unbind('click').click(function () {
|
||||||
save(-1)
|
save(-1)
|
||||||
})
|
})
|
||||||
$("#html_editor").ckeditor()
|
$("#html_editor").ckeditor()
|
||||||
|
@ -116,7 +116,7 @@ function load() {
|
||||||
$("#emptyMessage").hide()
|
$("#emptyMessage").hide()
|
||||||
$("#loading").show()
|
$("#loading").show()
|
||||||
api.pages.get()
|
api.pages.get()
|
||||||
.success(function(ps) {
|
.success(function (ps) {
|
||||||
pages = ps
|
pages = ps
|
||||||
$("#loading").hide()
|
$("#loading").hide()
|
||||||
if (pages.length > 0) {
|
if (pages.length > 0) {
|
||||||
|
@ -129,7 +129,7 @@ function load() {
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
pagesTable.clear()
|
pagesTable.clear()
|
||||||
$.each(pages, function(i, page) {
|
$.each(pages, function (i, page) {
|
||||||
pagesTable.row.add([
|
pagesTable.row.add([
|
||||||
escapeHtml(page.name),
|
escapeHtml(page.name),
|
||||||
moment(page.modified_date).format('MMMM Do YYYY, h:mm:ss a'),
|
moment(page.modified_date).format('MMMM Do YYYY, h:mm:ss a'),
|
||||||
|
@ -149,22 +149,22 @@ function load() {
|
||||||
$("#emptyMessage").show()
|
$("#emptyMessage").show()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.error(function() {
|
.error(function () {
|
||||||
$("#loading").hide()
|
$("#loading").hide()
|
||||||
errorFlash("Error fetching pages")
|
errorFlash("Error fetching pages")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function () {
|
||||||
// Setup multiple modals
|
// Setup multiple modals
|
||||||
// Code based on http://miles-by-motorcycle.com/static/bootstrap-modal/index.html
|
// Code based on http://miles-by-motorcycle.com/static/bootstrap-modal/index.html
|
||||||
$('.modal').on('hidden.bs.modal', function(event) {
|
$('.modal').on('hidden.bs.modal', function (event) {
|
||||||
$(this).removeClass('fv-modal-stack');
|
$(this).removeClass('fv-modal-stack');
|
||||||
$('body').data('fv_open_modals', $('body').data('fv_open_modals') - 1);
|
$('body').data('fv_open_modals', $('body').data('fv_open_modals') - 1);
|
||||||
});
|
});
|
||||||
$('.modal').on('shown.bs.modal', function(event) {
|
$('.modal').on('shown.bs.modal', function (event) {
|
||||||
// Keep track of the number of open modals
|
// Keep track of the number of open modals
|
||||||
if (typeof($('body').data('fv_open_modals')) == 'undefined') {
|
if (typeof ($('body').data('fv_open_modals')) == 'undefined') {
|
||||||
$('body').data('fv_open_modals', 0);
|
$('body').data('fv_open_modals', 0);
|
||||||
}
|
}
|
||||||
// if the z-index of this modal has been set, ignore.
|
// if the z-index of this modal has been set, ignore.
|
||||||
|
@ -179,10 +179,10 @@ $(document).ready(function() {
|
||||||
$('.modal-backdrop').not('.fv-modal-stack').css('z-index', 1039 + (10 * $('body').data('fv_open_modals')));
|
$('.modal-backdrop').not('.fv-modal-stack').css('z-index', 1039 + (10 * $('body').data('fv_open_modals')));
|
||||||
$('.modal-backdrop').not('fv-modal-stack').addClass('fv-modal-stack');
|
$('.modal-backdrop').not('fv-modal-stack').addClass('fv-modal-stack');
|
||||||
});
|
});
|
||||||
$.fn.modal.Constructor.prototype.enforceFocus = function() {
|
$.fn.modal.Constructor.prototype.enforceFocus = function () {
|
||||||
$(document)
|
$(document)
|
||||||
.off('focusin.bs.modal') // guard against infinite focus loop
|
.off('focusin.bs.modal') // guard against infinite focus loop
|
||||||
.on('focusin.bs.modal', $.proxy(function(e) {
|
.on('focusin.bs.modal', $.proxy(function (e) {
|
||||||
if (
|
if (
|
||||||
this.$element[0] !== e.target && !this.$element.has(e.target).length
|
this.$element[0] !== e.target && !this.$element.has(e.target).length
|
||||||
// CKEditor compatibility fix start.
|
// CKEditor compatibility fix start.
|
||||||
|
@ -193,10 +193,14 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
}, this));
|
}, this));
|
||||||
};
|
};
|
||||||
$('#modal').on('hidden.bs.modal', function(event) {
|
// Scrollbar fix - https://stackoverflow.com/questions/19305821/multiple-modals-overlay
|
||||||
|
$(document).on('hidden.bs.modal', '.modal', function () {
|
||||||
|
$('.modal:visible').length && $(document.body).addClass('modal-open');
|
||||||
|
});
|
||||||
|
$('#modal').on('hidden.bs.modal', function (event) {
|
||||||
dismiss()
|
dismiss()
|
||||||
});
|
});
|
||||||
$("#capture_credentials_checkbox").change(function() {
|
$("#capture_credentials_checkbox").change(function () {
|
||||||
$("#capture_passwords").toggle()
|
$("#capture_passwords").toggle()
|
||||||
$("#redirect_url").toggle()
|
$("#redirect_url").toggle()
|
||||||
})
|
})
|
||||||
|
|
|
@ -266,6 +266,10 @@ $(document).ready(function () {
|
||||||
}
|
}
|
||||||
}, this));
|
}, this));
|
||||||
};
|
};
|
||||||
|
// Scrollbar fix - https://stackoverflow.com/questions/19305821/multiple-modals-overlay
|
||||||
|
$(document).on('hidden.bs.modal', '.modal', function () {
|
||||||
|
$('.modal:visible').length && $(document.body).addClass('modal-open');
|
||||||
|
});
|
||||||
$('#modal').on('hidden.bs.modal', function (event) {
|
$('#modal').on('hidden.bs.modal', function (event) {
|
||||||
dismiss()
|
dismiss()
|
||||||
});
|
});
|
||||||
|
|
|
@ -344,6 +344,10 @@ $(document).ready(function () {
|
||||||
}
|
}
|
||||||
}, this));
|
}, this));
|
||||||
};
|
};
|
||||||
|
// Scrollbar fix - https://stackoverflow.com/questions/19305821/multiple-modals-overlay
|
||||||
|
$(document).on('hidden.bs.modal', '.modal', function () {
|
||||||
|
$('.modal:visible').length && $(document.body).addClass('modal-open');
|
||||||
|
});
|
||||||
$('#modal').on('hidden.bs.modal', function (event) {
|
$('#modal').on('hidden.bs.modal', function (event) {
|
||||||
dismiss()
|
dismiss()
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue