Skip to content

Commit 54541e3

Browse files
committed
#1 Move fetchAjaxContentByModal to Bootstrap Modal Wrapper plugin and update version prior to publish
1 parent 97cdf57 commit 54541e3

File tree

2 files changed

+10
-53
lines changed

2 files changed

+10
-53
lines changed

js/bootstrap-actionable.js

Lines changed: 8 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
var defaults = {
2121
loadingHtml: "Loading ...",
2222
ajaxHttpMethod: "GET",
23+
dataType: "HTML",
2324
ajaxContainerReady: "ajax-container-ready"
2425
};
2526

@@ -38,7 +39,13 @@
3839
var actionScope = $(this).attr("actionScope") ? $(this).attr("actionScope") : "html";
3940
if (actionType === "ajax-model") {
4041
var href = $(this).attr("href") ? $(this).attr("href") : $(this).attr("actionLink");
41-
$this.fetchAjaxContentByModal(href);
42+
BootstrapModalWrapperFactory.createAjaxModal({
43+
message: $this.options.loadingHtml,
44+
dataType: $this.options.dataType,
45+
httpMethod: $this.options.ajaxHttpMethod,
46+
ajaxContainerReadyEventName: $this.options.ajaxContainerReady,
47+
url: href
48+
});
4249
} else if (actionType === "action-ref") {
4350
var actionRefName = $(this).attr("action-ref-by-name") ? $(this).attr("action-ref-by-name") : "";
4451
if ($(actionScope + " [action-name='" + actionRefName + "']").length > 0)
@@ -59,55 +66,5 @@
5966
}
6067
});
6168
};
62-
63-
BootstrapActionable.prototype.fetchAjaxContentByModal = function (remoteUrl, passData) {
64-
var $this = this;
65-
var ajaxModalContainer = BootstrapModalWrapperFactory.createModal({
66-
message: $this.options.loadingHtml,
67-
closable: false,
68-
closeByBackdrop: false,
69-
closeByKeyboard: false
70-
});
71-
ajaxModalContainer.originalModal.removeClass("fade");
72-
ajaxModalContainer.originalModal.find(".modal-dialog").css({transition: 'all .3s'});
73-
74-
ajaxModalContainer.show();
75-
76-
if (passData === undefined) {
77-
passData = {};
78-
}
79-
80-
passData["ajaxModalId"] = ajaxModalContainer.options.id;
81-
82-
$.ajax({
83-
type: $this.options.ajaxHttpMethod,
84-
dataType: "html",
85-
url: remoteUrl,
86-
data: {},
87-
success: function (response, textStatus, jqXHR) {
88-
// make sure the modal dialog is open before update
89-
// its body with ajax response and triggering javaTmpAjaxContainerReady event.
90-
var timeOut = 700;
91-
function runWhenDialogOpen() {
92-
// console.log("time out [" + Math.round(timeOut / 2) + "], isOpen [" + ajaxModalContainer.isOpen + "], is show [" + ajaxModalContainer.originalModal.hasClass("show") + "]");
93-
if (ajaxModalContainer.isOpen) {
94-
ajaxModalContainer.updateSize("modal-lg");
95-
setTimeout(function () {
96-
ajaxModalContainer.updateMessage(response);
97-
setTimeout(function () {
98-
$("#" + ajaxModalContainer.options.id).trigger($this.options.ajaxContainerReady, [ajaxModalContainer]);
99-
}, 0);
100-
}, 350);
101-
} else {
102-
timeOut = timeOut <= 50 ? 50 : Math.round(timeOut / 2);
103-
setTimeout(runWhenDialogOpen, timeOut);
104-
105-
}
106-
}
107-
runWhenDialogOpen();
108-
}
109-
});
110-
};
111-
11269
return new BootstrapActionable();
11370
}));

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bootstrap-actionable",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "Actionable plugin is a small Javascript code that help implement click actions for a and button tags by declarative way and provide functionalities to load AJAX content in Bootstrap Modal Wrapper instance.",
55
"keywords": [
66
"bootstrap",
@@ -26,7 +26,7 @@
2626
"jquery": "^3.3.1",
2727
"popper.js": "^1.13.0",
2828
"bootstrap": "^4.0.0",
29-
"bootstrap-modal-wrapper": "^1.0.6"
29+
"bootstrap-modal-wrapper": "^1.0.10"
3030
},
3131
"scripts": {},
3232
"repository": {

0 commit comments

Comments
 (0)