-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from TheDMSGroup/ENG-192
[ENG-192] data table loading for doc ready and ajaxComplete
- Loading branch information
Showing
5 changed files
with
207 additions
and
139 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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
Mautic.loadCampaignRevenueWidget = function () { | ||
if (mQuery('#campaign-revenue-table').hasClass('table-initialized') == false) { | ||
mQuery.getScriptCachedOnce(mauticBasePath + '/' + mauticAssetPrefix + 'plugins/MauticContactLedgerBundle/Assets/js/datatables.min.js', function () { | ||
mQuery.getCssOnce(mauticBasePath + '/' + mauticAssetPrefix + 'plugins/MauticContactLedgerBundle/Assets/css/datatables.min.css', function () { | ||
mQuery.getCssOnce(mauticBasePath + '/' + mauticAssetPrefix + 'plugins/MauticContactLedgerBundle/Assets/css/dataTables.fontAwesome.css', function () { | ||
mQuery('#campaign-revenue-table').DataTable(datatableRequest); | ||
}); //getScriptsCachedOnce - fonteawesome css | ||
});//getScriptsCachedOnce - datatables css | ||
}); //getScriptsCachedOnce - datatables js | ||
} // if table initialized | ||
mQuery('#campaign-revenue-table').addClass('table-initialized'); | ||
}; //loadCampaignRevenueWidget | ||
|
||
// getScriptCachedOnce for faster page loads in the backend. | ||
mQuery.getScriptCachedOnce = function (url, callback) { | ||
if ( | ||
typeof window.getScriptCachedOnce !== 'undefined' | ||
&& window.getScriptCachedOnce.indexOf(url) !== -1 | ||
) { | ||
callback(); | ||
return mQuery(this); | ||
} else { | ||
return mQuery.ajax({ | ||
url: url, | ||
dataType: 'script', | ||
cache: true | ||
}).done(function () { | ||
if (typeof window.getScriptCachedOnce === 'undefined') { | ||
window.getScriptCachedOnce = []; | ||
} | ||
window.getScriptCachedOnce.push('url'); | ||
callback(); | ||
}); | ||
} | ||
}; | ||
|
||
// getScriptCachedOnce for faster page loads in the backend. | ||
mQuery.getCssOnce = function (url, callback) { | ||
if (document.createStyleSheet){ | ||
document.createStyleSheet(url); | ||
} | ||
else { | ||
mQuery("head").append(mQuery("<link rel='stylesheet' href='" + url + "' type='text/css' />")); | ||
} | ||
callback(); | ||
}; | ||
|
||
mQuery(document).ready(function () { | ||
Mautic.loadCampaignRevenueWidget(); | ||
}); | ||
mQuery(document).ajaxComplete(function (event, xhr, settings) { | ||
Mautic.loadCampaignRevenueWidget(); | ||
}); |
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
Oops, something went wrong.