| [1] | 1 | |
|---|
| 2 | ajaxLoader : { |
|---|
| 3 | /** A queue of embeds to load on document ready */ |
|---|
| 4 | loadQueue: {}, |
|---|
| 5 | |
|---|
| 6 | /** A queue of embeds to load on after the load queue */ |
|---|
| 7 | lazyQueue: {}, |
|---|
| 8 | |
|---|
| 9 | /** |
|---|
| 10 | * Called on Document Ready to load all the queued embeds |
|---|
| 11 | */ |
|---|
| 12 | init: function() { |
|---|
| 13 | jQuery.each(this.loadQueue, function(id, url) { |
|---|
| 14 | wbHtmlWidgets.embed._load(id, url); |
|---|
| 15 | }); |
|---|
| 16 | |
|---|
| 17 | jQuery.each(this.lazyQueue, function(id, url) { |
|---|
| 18 | wbHtmlWidgets.embed._load(id, url); |
|---|
| 19 | }); |
|---|
| 20 | }, |
|---|
| 21 | |
|---|
| 22 | _load: function(id, url) { |
|---|
| 23 | $("#" + id).load(url); |
|---|
| 24 | }, |
|---|
| 25 | |
|---|
| 26 | /** |
|---|
| 27 | * Loads a url into a dom id immediately - ensure that the page has |
|---|
| 28 | * completely loaded before using this method, as manipulating the DOM |
|---|
| 29 | * before it has been created does nasty things in browsers such as IE. |
|---|
| 30 | * If you want to embed the wibl after the page has loaded, use embed.afterLoad() |
|---|
| 31 | * @param {string} id The div id to load the embed into |
|---|
| 32 | * @param {string} url The url to load into the specified div id |
|---|
| 33 | */ |
|---|
| 34 | now: function(id, url) { |
|---|
| 35 | this._load(id, url); |
|---|
| 36 | }, |
|---|
| 37 | |
|---|
| 38 | /** |
|---|
| 39 | * Loads a url into a dom id after the onLoad queue has been processed. |
|---|
| 40 | * @param {string} id The div id to load the embed into |
|---|
| 41 | * @param {string} url The url to load into the specified div id |
|---|
| 42 | */ |
|---|
| 43 | lazy: function(id, url) { |
|---|
| 44 | this.lazyQueue[id] = url; |
|---|
| 45 | }, |
|---|
| 46 | |
|---|
| 47 | /** |
|---|
| 48 | * Loads a url into a dom id after the page has loaded. |
|---|
| 49 | * If you want to embed the wibl now, use embed.now() |
|---|
| 50 | * @param {string} id The div id to load the embed into |
|---|
| 51 | * @param {string} url The url to load into the specified div id |
|---|
| 52 | */ |
|---|
| 53 | afterLoad: function(id, url) { |
|---|
| 54 | if ( $("#"+id).html() == '' ) { |
|---|
| 55 | $("#"+id).html('<image src="/images/spinner.gif" />'); |
|---|
| 56 | } |
|---|
| 57 | this.loadQueue[id] = url; |
|---|
| 58 | } |
|---|
| 59 | } |
|---|