Skip to content

Commit 2618354

Browse files
author
Mesut Talebi
committed
Updated Modal html to able to handle bootstrap 4 modal
1 parent 96d0f10 commit 2618354

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+51
-6532
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
/.vs/config/applicationhost.config
66
/.vs/Mt.BootstrapLazyload.js/v14/.suo
77
/Mt.BootstrapLazyload.js.sln
8+
/.vs

Scripts/MT.BootstrapLazyloader.js

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Nuget Package: MT.BootstrapLazyLoader.js
3-
Version: 1.3.0
3+
Version: 1.4.0
44
55
Created By: Mesut Talebi (mesut.talebi@gmail.com)
66
@@ -29,7 +29,7 @@ var MTLazyloader = function () {
2929
//Get Id Of Current Handler to set as Modal Id, the id of modal will be #HandlerId + Modal
3030
var currHandleId = modalId;
3131

32-
if (currHandleId == undefined || currHandleId == null) {
32+
if (currHandleId === undefined || currHandleId === null) {
3333
currHandleId = "LazyloadModal";
3434
} else {
3535
currHandleId += "Modal";
@@ -38,48 +38,46 @@ var MTLazyloader = function () {
3838
var disableClose = parDisableClose;
3939

4040
var modalContentId = '#LazyloadModalContent';
41-
if (contentId != undefined && contentId != null) {
41+
if (contentId !== undefined && contentId !== null) {
4242
modalContentId = "#" + contentId;
4343
}
44-
44+
var modalHeader = header;
45+
var modalClass = size;
46+
var callback = parCallback;
4547

4648
var modalHtml = "<!--Lazyloaded Modal -->" +
47-
"<div class='modal fade' id='" + currHandleId + "' role='dialog' aria-labelledby='" + currHandleId + "'>" +
48-
"<div class='modal-dialog' role='document'>" +
49-
"<div class='modal-content'>" +
49+
"<div class='modal " + (MTLazyloadBootstrapVersion !== 4 ? "fade" : "") + "' id='" + currHandleId + "' role='dialog' aria-labelledby='" + currHandleId + "'>" +
50+
"<div class='modal-dialog " + modalClass + "' role='document'>" +
51+
"<div class='modal-content'>" +
5052
"<div class='modal-header'>";
5153

52-
if (disableClose == undefined || disableClose === 'false' || disableClose == null) {
54+
if (MTLazyloadBootstrapVersion === 4) {
55+
modalHtml += "<h5 class='modal-title'>" + modalHeader + "</h5>";
56+
}
57+
58+
if (disableClose === undefined || disableClose === 'false') {
5359
modalHtml += "<button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button>";
5460
}
5561

56-
modalHtml += "<h4 class='modal-title' id='LazyloadModalLabel'>Modal Header</h4>" +
57-
"</div>" +
62+
if (MTLazyloadBootstrapVersion !== 4) {
63+
modalHtml += "<h4 class='modal-title' id='LazyloadModalLabel'>" + modalHeader + "</h4>";
64+
}
65+
66+
modalHtml += "</div>" +
5867
"<div id='" + modalContentId.substr(1) + "'></div>" +
5968
"</div>" +
6069
"</div>" +
6170
"</div>";
62-
63-
64-
65-
var modalHeader = header;
66-
var modalClass = size;
67-
var callback = parCallback;
68-
69-
70-
71+
7172
var modal = $('#' + currHandleId);
72-
if (modal.length == 0) {
73+
if (modal.length === 0) {
7374
$('body').append(modalHtml);
7475

7576
modal = $('#' + currHandleId);
7677
}
7778
else {
7879
$('body').append(modal);
79-
}
80-
81-
$(modal).find('.modal-header .modal-title').html(modalHeader);
82-
$(modal).find('.modal-dialog').removeAttr("class").addClass('modal-dialog').addClass(modalClass);
80+
}
8381

8482
//Ajax Get
8583
$(modal).find(modalContentId).html('');
@@ -110,6 +108,8 @@ var MTLazyloader = function () {
110108
}
111109
}();
112110

111+
var MTLazyloadBootstrapVersion = 3;
112+
113113
$(function () {
114114
$(document).on('shown.bs.tab', '.nav-tabs.lazyload a[data-toggle="tab"]:not(.loaded)', function (e) {
115115
var loader = '<div class="text-center"><i class="fa fa-spin fa-spinner fa-2x text-muted"></i></div>';
@@ -169,10 +169,10 @@ $(function () {
169169
}
170170
});
171171

172-
$(document).on('click', '.lazyload.showModal', function (e) {
172+
$(document).on('click', '.lazyload.showModal', function (e) {
173173
var currHandle = $(this);
174174
var url = $(currHandle).data('url');
175-
if ($(this).prop("tagName") == "A" && url == undefined) {
175+
if ($(this).prop("tagName") === "A" && url === undefined) {
176176
e.preventDefault();
177177
url = $(currHandle).attr('href');
178178
}
@@ -182,41 +182,44 @@ $(function () {
182182
//Get Id Of Current Handler to set as Modal Id, the id of modal will be #HandlerId + Modal
183183
var currHandleId = $(currHandle).attr('id');
184184

185-
if (currHandleId == undefined) {
185+
if (currHandleId === undefined) {
186186
currHandleId = "LazyloadModal";
187187
} else {
188188
currHandleId += "Modal";
189189
}
190-
191-
190+
192191
var disableClose = $(currHandle).data('closedisabled');
192+
var modalHeader = $(currHandle).data('header');
193+
var modalClass = $(currHandle).data('size');
193194

194195
var modalHtml = "<!--Lazyloaded Modal -->" +
195-
"<div class='modal fade' id='" + currHandleId + "' role='dialog' aria-labelledby='" + currHandleId + "'>" +
196-
"<div class='modal-dialog' role='document'>" +
196+
"<div class='modal " + (MTLazyloadBootstrapVersion !== 4 ? "fade" : "") + "' id='" + currHandleId + "' role='dialog' aria-labelledby='" + currHandleId + "'>" +
197+
"<div class='modal-dialog " + modalClass + "' role='document'>" +
197198
"<div class='modal-content'>" +
198199
"<div class='modal-header'>";
199200

200-
if (disableClose == undefined || disableClose === 'false') {
201+
if (MTLazyloadBootstrapVersion === 4) {
202+
modalHtml += "<h5 class='modal-title'>" + modalHeader + "</h5>";
203+
}
204+
205+
if (disableClose === undefined || disableClose === 'false') {
201206
modalHtml += "<button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button>";
202207
}
203208

204-
modalHtml += "<h4 class='modal-title' id='LazyloadModalLabel'>Modal Header</h4>" +
205-
"</div>" +
206-
"<div id='LazyloadModalContent'></div>" +
209+
if (MTLazyloadBootstrapVersion !== 4) {
210+
modalHtml += "<h4 class='modal-title' id='LazyloadModalLabel'>" + modalHeader + "</h4>";
211+
}
212+
213+
modalHtml +="</div>" +
214+
"<div id='LazyloadModalContent'></div>" +
207215
"</div>" +
208216
"</div>" +
209217
"</div>";
210-
211-
212-
213-
var modalHeader = $(currHandle).data('header');
214-
var modalClass = $(currHandle).data('size');
218+
215219
var callback = $(currHandle).data('callback');
216220

217-
218221
var modal = $('#' + currHandleId);
219-
if (modal.length == 0) {
222+
if (modal.length === 0) {
220223
$('body').append(modalHtml);
221224

222225
modal = $('#' + currHandleId);
@@ -225,15 +228,15 @@ $(function () {
225228
$('body').append(modal);
226229
}
227230

228-
$(modal).find('.modal-header #LazyloadModalLabel').html(modalHeader);
229-
$(modal).find('.modal-dialog').removeAttr("class").addClass('modal-dialog').addClass(modalClass);
231+
//$(modal).find('.modal-header #LazyloadModalLabel').html(modalHeader);
232+
//$(modal).find('.modal-dialog').removeAttr("class").addClass('modal-dialog').addClass(modalClass);
230233

231234
//Ajax Get
232235
$(modal).find('#LazyloadModalContent').html('');
233236
$(currHandle).append(loader);
234237
$.get(url, function (data) {
235238
$(modal).find('#LazyloadModalContent').html(data);
236-
if (disableClose == undefined) {
239+
if (disableClose === undefined) {
237240
$(modal).modal('show');
238241
}
239242
else {

bower.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mt-bootstraplazyloader",
3-
"version": "1.3.0",
3+
"version": "1.4.0",
44
"homepage": "https://github.com/mesuttalebi/MT.BootstrapLazyloader.js",
55
"authors": [
66
"mesut talebi <mesut.talebi@gmail.com>"
@@ -9,8 +9,7 @@
99
"main": "Scripts/MT.BootstrapLazyloader.js",
1010
"keywords": [
1111
"bootstrap",
12-
"lazylaod",
13-
"lazyload",
12+
"lazylaod",
1413
"modal",
1514
"bootstrap-tabs",
1615
"bootstrap-modal",

bower_components/font-awsome/.bower.json

Lines changed: 0 additions & 36 deletions
This file was deleted.

bower_components/font-awsome/.gitignore

Lines changed: 0 additions & 33 deletions
This file was deleted.

bower_components/font-awsome/.npmignore

Lines changed: 0 additions & 42 deletions
This file was deleted.

bower_components/font-awsome/HELP-US-OUT.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.

bower_components/font-awsome/bower.json

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)