Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function($){
- $.fn.widget = function(options,callback) {
- var $this = $(this);
- return this.each(function(i) {
- if ($.fn.widget.arguments.length === 0 || typeof options === "object") {
- var structure = $(document).data("settings").structure;
- $(this).data("options.widget",$.extend({},$.fn.widget.defaults,options,{name:$(this).attr("id")}));
- $.fn.widget.init($this,$.extend($.fn.widget.defaults,options),structure,callback)
- } else if (typeof options==="string") {
- switch(options) {
- case "prefs":
- $.fn.widget.prefs($this);
- break;
- case "menubar":
- $.fn.widget.menubar($this);
- break;
- case "destroy":
- $.fn.widget.destroy($this);
- break;
- case "mini":
- $.fn.widget.mini($this);
- break;
- case "updateTitle":
- $.fn.widget.updateTitle($this);
- break;
- }
- }
- });
- };
- $.fn.widget.defaults = {
- prefs:true,
- mini:true
- };
- $.fn.widget.init = function($w,opts,structure) {
- var w = $w.attr("id");
- if (!$w.data("inited")) {
- $w.data("inited",false)
- }
- var point = $.fn.widget.init.locate(w,structure);
- switch(point.mode) {
- case "append":
- $w.appendTo("#"+point.column);
- break;
- case "after":
- $w.insertAfter("#"+point.loc);
- break;
- case "before":
- $w.insertBefore("#"+point.loc);
- break;
- }
- $("#cpanel_li_"+w).addClass("active").removeClass("inactive");
- var ts = new Date().getTime();
- $.getScript(w+"/"+w+".js",function() {
- $w.load("widgets.cfc?ts="+ts+"&widget="+w+"&method=getMarkup&returnformat=plain",function() {
- function widgetCallback() {
- if (!$w.data("inited")) {
- if (checkIfLast()) {
- $("#controlpanel").controlPanel("activateSortable");
- $().data("settings").showHelp && $("#controlpanel").controlPanel("help");
- if ($().data("settings").applyDefaults && $().data("settings").op && app.validate.entity($().data("settings").op)) {
- $("#override_entity").val($().data("settings").op);
- $("#controlpanel").controlPanel("override");
- }
- }
- $w.widget("menubar");
- if ($(document).data("settings").mini.find(w)) {
- $w.widget("mini");
- }
- if ($w.data("inPrefs")) {
- $.fn.widget.prefs.goTo($w);
- } else if ($.isFunction($w.data("callback"))) {
- $w.data("callback")();
- }
- /*
- else if (ajdebug || bjdebug) {
- if (ajdebug && w==="hperf") { ajdebug(); }
- if (bjdebug && w==="comp") { bjdebug(); }
- }
- */
- }
- $w.data("inited",true);
- function checkIfLast() {
- var widgetCount = $("#controlpanel").data("widgetCount");
- var progress = $("#controlpanel").data("initProgress");
- progress++;
- $("#controlpanel").data("initProgress",progress);
- if (progress===widgetCount) {
- return true;
- } else {
- return false;
- }
- }
- }
- if (w === "ezrpt") {
- $("#"+w+"_body").load("../guest/guestwelcome_simple.cfm",{w:"y"},widgetCallback);
- } else {
- var destination = "";
- if ($("h1.menubar",$w).metadata(app.defaults.metadata).redirect) {
- $w.data("inPrefs",true);
- destination = "widgets.cfc?method=getPrefs&returnformat=plain&widget="+w;
- } else {
- destination = w+"/home.cfm?ts="+ts;
- }
- $("#"+w+"_body").load(destination,widgetCallback);
- }
- });
- });
- };
- })(jQuery);
Add Comment
Please, Sign In to add comment