Guest User

Untitled

a guest
May 23rd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.61 KB | None | 0 0
  1. (function($){
  2. $.fn.widget = function(options,callback) {
  3. var $this = $(this);
  4. return this.each(function(i) {
  5. if ($.fn.widget.arguments.length === 0 || typeof options === "object") {
  6. var structure = $(document).data("settings").structure;
  7. $(this).data("options.widget",$.extend({},$.fn.widget.defaults,options,{name:$(this).attr("id")}));
  8. $.fn.widget.init($this,$.extend($.fn.widget.defaults,options),structure,callback)
  9. } else if (typeof options==="string") {
  10. switch(options) {
  11. case "prefs":
  12. $.fn.widget.prefs($this);
  13. break;
  14. case "menubar":
  15. $.fn.widget.menubar($this);
  16. break;
  17. case "destroy":
  18. $.fn.widget.destroy($this);
  19. break;
  20. case "mini":
  21. $.fn.widget.mini($this);
  22. break;
  23. case "updateTitle":
  24. $.fn.widget.updateTitle($this);
  25. break;
  26.  
  27. }
  28. }
  29. });
  30. };
  31.  
  32. $.fn.widget.defaults = {
  33. prefs:true,
  34. mini:true
  35. };
  36. $.fn.widget.init = function($w,opts,structure) {
  37. var w = $w.attr("id");
  38. if (!$w.data("inited")) {
  39. $w.data("inited",false)
  40. }
  41. var point = $.fn.widget.init.locate(w,structure);
  42. switch(point.mode) {
  43. case "append":
  44. $w.appendTo("#"+point.column);
  45. break;
  46. case "after":
  47. $w.insertAfter("#"+point.loc);
  48. break;
  49. case "before":
  50. $w.insertBefore("#"+point.loc);
  51. break;
  52. }
  53. $("#cpanel_li_"+w).addClass("active").removeClass("inactive");
  54. var ts = new Date().getTime();
  55. $.getScript(w+"/"+w+".js",function() {
  56. $w.load("widgets.cfc?ts="+ts+"&widget="+w+"&method=getMarkup&returnformat=plain",function() {
  57. function widgetCallback() {
  58.  
  59. if (!$w.data("inited")) {
  60. if (checkIfLast()) {
  61. $("#controlpanel").controlPanel("activateSortable");
  62. $().data("settings").showHelp && $("#controlpanel").controlPanel("help");
  63. if ($().data("settings").applyDefaults && $().data("settings").op && app.validate.entity($().data("settings").op)) {
  64. $("#override_entity").val($().data("settings").op);
  65. $("#controlpanel").controlPanel("override");
  66. }
  67. }
  68. $w.widget("menubar");
  69.  
  70. if ($(document).data("settings").mini.find(w)) {
  71. $w.widget("mini");
  72. }
  73. if ($w.data("inPrefs")) {
  74. $.fn.widget.prefs.goTo($w);
  75. } else if ($.isFunction($w.data("callback"))) {
  76. $w.data("callback")();
  77. }
  78.  
  79.  
  80. /*
  81. else if (ajdebug || bjdebug) {
  82. if (ajdebug && w==="hperf") { ajdebug(); }
  83. if (bjdebug && w==="comp") { bjdebug(); }
  84. }
  85. */
  86. }
  87. $w.data("inited",true);
  88. function checkIfLast() {
  89. var widgetCount = $("#controlpanel").data("widgetCount");
  90. var progress = $("#controlpanel").data("initProgress");
  91. progress++;
  92. $("#controlpanel").data("initProgress",progress);
  93. if (progress===widgetCount) {
  94. return true;
  95. } else {
  96. return false;
  97. }
  98. }
  99. }
  100.  
  101. if (w === "ezrpt") {
  102. $("#"+w+"_body").load("../guest/guestwelcome_simple.cfm",{w:"y"},widgetCallback);
  103. } else {
  104. var destination = "";
  105. if ($("h1.menubar",$w).metadata(app.defaults.metadata).redirect) {
  106. $w.data("inPrefs",true);
  107. destination = "widgets.cfc?method=getPrefs&returnformat=plain&widget="+w;
  108. } else {
  109. destination = w+"/home.cfm?ts="+ts;
  110. }
  111. $("#"+w+"_body").load(destination,widgetCallback);
  112. }
  113.  
  114. });
  115. });
  116.  
  117. };
  118.  
  119. })(jQuery);
Add Comment
Please, Sign In to add comment