Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. ;(function$) {
  2. $.plugin2 = function(el, options) {
  3. ...
  4. ...
  5. var init = function() {
  6. plugin.settings = $.extend({}, defaults, options);
  7. plugin.el = el;
  8.  
  9. var init = function() {
  10. ...plugin1Instance.settings.variable... <--------
  11. }
  12.  
  13. init();
  14. };
  15. });
  16.  
  17. var plugins = [];
  18.  
  19. function startOnLoad() {
  20. // Start init() of every 'registered; plugin
  21. for (var i = 0; plugins.length - 1; i++) {
  22. plugins[i]();
  23. }
  24.  
  25. // Ok, all plugins initialized, can access each other.
  26. // Ex: plugin1Instance.settings.variable and etc.
  27. }
  28.  
  29. plugins.push(Plugin1.init);
  30.  
  31. var windowOnLoad = function() {
  32. // your plugins should be loaded at the moment
  33. }
  34. if (window.addEventListener) {
  35. window.addEventListener('load', windowOnLoad, false);
  36. } else if (window.attachEvent) {
  37. window.attachEvent('onload', windowOnLoad);
  38. }
  39.  
  40. var totalPlugins = 2;
  41. var numberOfLoadedPlugins = 0;
  42. var pluginLoaded = function() {
  43. numberOfLoadedPlugins += 1;
  44. if(numberOfLoadedPlugins === totalPlugins) {
  45. // it's done. your plugins are loaded
  46. // proceed with the other logic
  47. }
  48. }
  49.  
  50. ;(function$) {
  51. $.plugin1 = function(el, options) {
  52. // ...
  53. };
  54. pluginLoaded();
  55. });
  56. ;(function$) {
  57. $.plugin2 = function(el, options) {
  58. // ...
  59. };
  60. pluginLoaded();
  61. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement