-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring js and add support for Modal Ajax
- Loading branch information
1 parent
d72c470
commit 13cf80a
Showing
4 changed files
with
134 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
fieldset.collapse-wrapper legend a { display: inline-block; width: 100%; color: black; } | ||
fieldset.collapse-wrapper legend a { display: inline-block; width: 100%; color: black; } | ||
fieldset.collapse-wrapper fieldset.collapse-wrapper { margin-left: 15px; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,114 @@ | ||
$(document.body).on('show.bs.collapse', '.collapse-wrapper', function(e) { | ||
if (!$(e.target).parent().is($(this))) { | ||
return; | ||
} | ||
|
||
var title = $('legend', $(this)).first(); | ||
var titleLink = $('legend > a', $(this)).first(); | ||
titleLink.html(titleLink.html().replace(title.attr('data-closed-indicator').replace(/"/g, '"').replace(/&/g, '&'), title.attr('data-opened-indicator').replace(/"/g, '"').replace(/&/g, '&'))); | ||
|
||
titleLink.html( | ||
titleLink.html().replace( | ||
title.attr('data-closed-indicator'), | ||
title.attr('data-opened-indicator') | ||
) | ||
); | ||
}); | ||
$(document.body).on('hidden.bs.collapse', '.collapse-wrapper', function(e) { | ||
if (!$(e.target).parent().is($(this))) { | ||
return; | ||
} | ||
|
||
var title = $('legend', $(this)).first(); | ||
var titleLink = $('legend > a', $(this)).first(); | ||
titleLink.html(titleLink.html().replace(title.attr('data-opened-indicator').replace(/"/g, '"').replace(/&/g, '&'), title.attr('data-closed-indicator').replace(/"/g, '"').replace(/&/g, '&'))); | ||
|
||
titleLink.html( | ||
titleLink.html().replace( | ||
title.attr('data-opened-indicator'), | ||
title.attr('data-closed-indicator') | ||
) | ||
); | ||
}); | ||
|
||
$(document.body).on('show.bs.tab', '[data-toggle="tab"]', function(e) { | ||
var targetTabLink = $(e.target).first(); | ||
var targetTab = $(targetTabLink.attr('href')).first(); | ||
if ((typeof targetTabLink.attr('data-src') !== 'undefined') && (targetTabLink.attr('data-src') !== false) && ((targetTab.attr('data-cache') !== 'true') || (typeof targetTab.attr('data-loading') === 'undefined') || (targetTab.attr('data-loading') === false))) { | ||
|
||
if ((typeof targetTabLink.attr('data-src') !== 'undefined') | ||
&& (targetTabLink.attr('data-src') !== false) | ||
&& ( | ||
(targetTab.attr('data-cache') !== 'true') | ||
|| (typeof targetTab.attr('data-loading') === 'undefined') | ||
|| (targetTab.attr('data-loading') === false) | ||
) | ||
) { | ||
targetTab.trigger('loadTab.muih', [targetTabLink.attr('data-src')]); | ||
} | ||
|
||
var previousTab = $($(e.relatedTarget).attr('href')).first(); | ||
if ((previousTab.attr('data-cache') === 'false') && (typeof previousTab.attr('data-loading') !== 'undefined') && (previousTab.attr('data-loading') !== false)) { | ||
|
||
if ((previousTab.attr('data-cache') === 'false') | ||
&& (typeof previousTab.attr('data-loading') !== 'undefined') | ||
&& (previousTab.attr('data-loading') !== false) | ||
) { | ||
previousTab.html(previousTab.attr('data-loading')); | ||
} | ||
}); | ||
|
||
$(document.body).on('loadTab.muih', '.tab-pane', function(e, src) { | ||
var targetTab = $(this); | ||
targetTab.attr('data-loading', targetTab.html()); | ||
targetTab.load(src, function(responseText, textStatus, XMLHttpRequest) { | ||
targetTab.load(src, function() { | ||
$('.withTooltip', targetTab).tooltip(); | ||
$('.withPopover', targetTab).popover(); | ||
}); | ||
}); | ||
}); | ||
|
||
$(document.body).on('click', '[data-toggle="modal"]', function(e) { | ||
var targetModalLink = $(this); | ||
if ((typeof targetModalLink.attr('data-target') === 'undefined') | ||
|| (targetModalLink.attr('data-target') === false) | ||
|| (!$(targetModalLink.attr('data-target')).hasClass('modal-ajax')) | ||
) { | ||
return true; | ||
} | ||
e.preventDefault(); | ||
|
||
var targetModal = $(targetModalLink.attr('data-target')); | ||
|
||
var targetModalContent = $('.modal-content', targetModal).first(); | ||
if ((typeof targetModalContent.attr('data-loading') === 'undefined') | ||
|| (targetModalContent.attr('data-loading') === false) | ||
) { | ||
targetModalContent.attr('data-loading', targetModalContent.html()); | ||
} | ||
|
||
targetModal.modal('show'); | ||
targetModal.trigger('loadModal.muih', [targetModalLink.attr('href')]); | ||
e.stopPropagation(); | ||
}); | ||
$(document.body).on('hidden.bs.modal', '.modal', function(e) { | ||
if ((!$(e.target).is($(this))) || (!$(this).hasClass('modal-ajax'))) { | ||
return true; | ||
} | ||
|
||
var targetModalContent = $('.modal-content', $(this)).first(); | ||
if ((typeof targetModalContent.attr('data-loading') !== 'undefined') | ||
&& (targetModalContent.attr('data-loading') !== false) | ||
) { | ||
targetModalContent.html(targetModalContent.attr('data-loading')); | ||
} | ||
}); | ||
$(document.body).on('loadModal.muih', '.modal', function(e, src) { | ||
if (($(this).attr('data-ajax') !== 'undefined') | ||
&& ($(this).attr('data-ajax') !== false) | ||
&& ($(this).attr('data-ajax') === 'body') | ||
) { | ||
var targetModalContent = $('.modal-body', $(this)).first(); | ||
} else { | ||
var targetModalContent = $('.modal-content', $(this)).first(); | ||
} | ||
|
||
targetModalContent.load(src, function () { | ||
$('.withTooltip', targetModalContent).tooltip(); | ||
$('.withPopover', targetModalContent).popover(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters