/[drupal]/contributions/modules/event/eventblock.js
ViewVC logotype

Contents of /contributions/modules/event/eventblock.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.4 - (show annotations) (download) (as text)
Mon May 5 12:38:13 2008 UTC (18 months, 3 weeks ago) by killes
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +2 -2 lines
File MIME type: text/javascript
#254858, fix eventblock.js for compatibility with new jQuery, patch by snufkin
1 // Global killswitch
2 if (Drupal.jsEnabled) {
3 $(document).ready(eventAutoAttach);
4 }
5
6 /**
7 * Attaches the block update behaviour to links tagged with 'updateblock' class.
8 */
9 function eventAutoAttach() {
10 $("#block-event-0 div.content a.updateblock").click(function() {
11 this.blockUpdater = new blockUpdater( $(this).parents(".content"), $(this).attr("href").replace("month", "block"), eventAutoAttach);
12 return false;
13 });
14
15 }
16
17 /**
18 * create an instance of this object in the onClick handler for block update links.
19 *
20 * could be separated into misc/blockupdater.js
21 */
22
23 function blockUpdater(element,url,callback) {
24 var blockUpdate = this;
25 element.blockUpdate = this;
26
27 this.element = element;
28 this.callback = callback;
29
30 this.oldHTML = this.element.html();
31
32 // Keep block at it's current width/height to make the update less disruptive
33 this.styleHeight = $(element).height();
34 this.styleWidth = $(element).width();
35 $(element).height(element[0].offsetHeight+"px");
36 $(element).width(element[0].offsetWidth+"px");
37
38 // Clear block contents
39 $(element).html("");
40
41 // Insert progressbar
42 this.progress = new Drupal.progressBar('updateprogress');
43 $(this.element).prepend(this.progress.element);
44
45 var rel = this;
46 var cancel = document.createElement("a");
47 $(cancel).html("cancel").attr("alt","cancel").addClass("cancel-update")
48 .attr("href", "#").bind("click", function() {
49 rel.update("abort",undefined,blockUpdate);
50 return false;
51 });
52
53 this.element.prepend($(cancel));
54
55 this.dontUpdate = false;
56 $.get(url,function(data){
57 blockUpdate.update(data)});
58 }
59 blockUpdater.prototype.update = function (xmlHttp) {
60 var blockUpdate=this;
61 if(!blockUpdate.dontUpdate) {
62 if(xmlHttp == 'abort') {
63 blockUpdate.element.html(this.oldHTML);
64 blockUpdate.element.append("<p class='calendar-log'>Update aborted.</p>");
65 } else {
66 blockUpdate.element.height(blockUpdate.styleHeight);
67 blockUpdate.element.width(blockUpdate.styleWidth);
68 blockUpdate.element.html(xmlHttp);
69 blockUpdate.dontUpdate = true;
70 }
71 blockUpdate.dontUpdate = true;
72 if(blockUpdate.callback != undefined)
73 blockUpdate.callback();
74 }
75 }

  ViewVC Help
Powered by ViewVC 1.1.2