wisemapping-open-source/trunk/core-js/src/main/javascript/WaitDialog.js

135 lines
4.0 KiB
JavaScript
Raw Normal View History

2009-06-07 20:59:43 +02:00
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
2009-06-07 20:59:43 +02:00
/*
Created By: Chris Campbell
Website: http://particletree.com
Date: 2/1/2006
2009-06-07 20:59:43 +02:00
Inspired by the lightbox implementation found at http://www.huddletogether.com/projects/lightbox/
/*-----------------------------------------------------------------------------------------------*/
2009-06-07 20:59:43 +02:00
core.WaitDialog = new Class({
yPos : 0,
xPos : 0,
initialize: function() {
},
// Turn everything on - mainly the IE fixes
activate: function(changeCursor, dialogContent)
2009-06-07 20:59:43 +02:00
{
this.content = dialogContent;
this._initLightboxMarkup();
2009-06-07 20:59:43 +02:00
this.displayLightbox("block");
// Change to loading cursor.
if (changeCursor)
{
window.document.body.style.cursor = "wait";
}
},
changeContent: function(dialogContent, changeCursor)
{
this.content = dialogContent;
if (!$('lbContent'))
{
// Dialog is not activated. Nothing to do ...
window.document.body.style.cursor = "pointer";
return;
2009-06-07 20:59:43 +02:00
}
this.processInfo();
2009-06-07 20:59:43 +02:00
// Change to loading cursor.
if (changeCursor)
{
window.document.body.style.cursor = "wait";
}else
{
window.document.body.style.cursor = "auto";
}
2009-06-07 20:59:43 +02:00
},
displayLightbox: function(display) {
$('overlay').style.display = display;
$('lightbox').style.display = display;
if (display != 'none')
this.processInfo();
},
// Display dialog content ...
2009-06-07 20:59:43 +02:00
processInfo: function() {
if ($('lbContent'))
$('lbContent').remove();
var lbContentElement = new Element('div').setProperty('id', 'lbContent');
lbContentElement.setHTML(this.content.innerHTML);
lbContentElement.injectBefore($('lbLoadMessage'));
2009-06-07 20:59:43 +02:00
$('lightbox').className = "done";
},
// Search through new links within the lightbox, and attach click event
2009-06-07 20:59:43 +02:00
actions: function() {
lbActions = document.getElementsByClassName('lbAction');
for (i = 0; i < lbActions.length; i++) {
$(lbActions[i]).addEvent('click', function() {
this[lbActions[i].rel].pass(this)
}.bind(this));
lbActions[i].onclick = function() {
return false;
};
}
},
// Example of creating your own functionality once lightbox is initiated
2009-06-07 20:59:43 +02:00
deactivate: function(time) {
if ($('lbContent'))
$('lbContent').remove();
2009-06-07 20:59:43 +02:00
this.displayLightbox("none");
window.document.body.style.cursor = "default";
}
, _initLightboxMarkup:function()
{
// Add overlay element inside body ...
var bodyElem = document.getElementsByTagName('body')[0];
var overlayElem = new Element('div').setProperty('id', 'overlay');
overlayElem.injectInside(bodyElem);
// Add lightbox element inside body ...
var lightboxElem = new Element('div').setProperty('id', 'lightbox');
lightboxElem.addClass('loading');
var lbLoadMessageElem = new Element('div').setProperty('id', 'lbLoadMessage');
lbLoadMessageElem.injectInside(lightboxElem);
lightboxElem.injectInside(bodyElem);
}
});