2009-11-21 03:36:00 +01:00
|
|
|
(function($) {
|
|
|
|
|
|
|
|
/**
|
2009-11-21 03:37:41 +01:00
|
|
|
* Available Custom Events:
|
|
|
|
* <ul>
|
|
|
|
* <li>ajaxsubmit</li>
|
|
|
|
* <li>validate</li>
|
|
|
|
* <li>loadnewpage</li>
|
2009-11-21 03:36:00 +01:00
|
|
|
*
|
2009-11-21 03:37:41 +01:00
|
|
|
* @class Main LeftAndMain interface with some control
|
|
|
|
* panel and an edit form.
|
|
|
|
* @name ss.LeftAndMain
|
2009-11-21 03:36:00 +01:00
|
|
|
*/
|
2009-11-21 03:37:48 +01:00
|
|
|
$('.LeftAndMain').concrete('ss', function($){
|
|
|
|
return/** @lends ss.EditMemberProfile */ {
|
2009-11-21 03:38:31 +01:00
|
|
|
/**
|
|
|
|
* @type Number Interval in which /Security/ping will be checked for a valid login session.
|
|
|
|
*/
|
|
|
|
PingIntervalSeconds: 5*60,
|
2009-11-21 03:36:26 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
onmatch: function() {
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
this._setupPinging();
|
|
|
|
this._setupButtons();
|
|
|
|
this._resizeChildren();
|
2009-11-21 03:37:45 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
// artificially delay the resize event 200ms
|
|
|
|
// to avoid overlapping height changes in different onresize() methods
|
|
|
|
$(window).resize(function () {
|
|
|
|
var timerID = "timerLeftAndMainResize";
|
|
|
|
if (window[timerID]) clearTimeout(window[timerID]);
|
|
|
|
window[timerID] = setTimeout(function() {self._resizeChildren();}, 200);
|
|
|
|
});
|
2009-11-21 03:37:45 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
// trigger resize whenever new tabs are shown
|
|
|
|
// @todo This is called multiple times when tabs are loaded
|
|
|
|
this.find('.ss-tabset').bind('tabsshow', function() {self._resizeChildren();});
|
2009-11-21 03:37:45 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
$('#Form_EditForm').bind('loadnewpage', function() {self._resizeChildren();});
|
2009-11-21 03:36:22 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
this._super();
|
|
|
|
},
|
2009-11-21 03:38:22 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
/**
|
|
|
|
* This function is called by prototype when it receives notification that the user was logged out.
|
|
|
|
* It uses /Security/ping for this purpose, which should return '1' if a valid user session exists.
|
|
|
|
* It redirects back to the login form if the URL is either unreachable, or returns '0'.
|
|
|
|
*/
|
|
|
|
_setupPinging: function() {
|
2009-11-21 03:39:14 +01:00
|
|
|
var onSessionLost = function(xmlhttp, status) {
|
|
|
|
if(xmlhttp.status > 400 || xmlhttp.responseText == 0) {
|
2009-11-21 03:38:31 +01:00
|
|
|
// TODO will pile up additional alerts when left unattended
|
|
|
|
if(window.open('Security/login')) {
|
|
|
|
alert("Please log in and then try again");
|
|
|
|
} else {
|
|
|
|
alert("Please enable pop-ups for this site");
|
|
|
|
}
|
2009-11-21 03:38:22 +01:00
|
|
|
}
|
2009-11-21 03:38:31 +01:00
|
|
|
};
|
2009-11-21 03:38:22 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
// setup pinging for login expiry
|
|
|
|
setInterval(function() {
|
|
|
|
jQuery.ajax({
|
|
|
|
url: "Security/ping",
|
|
|
|
global: false,
|
2009-11-21 03:39:14 +01:00
|
|
|
complete: onSessionLost
|
2009-11-21 03:38:31 +01:00
|
|
|
});
|
|
|
|
}, this.PingIntervalSeconds() * 1000);
|
|
|
|
},
|
2009-11-21 03:36:00 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
/**
|
|
|
|
* Make all buttons "hoverable" with jQuery theming.
|
|
|
|
*/
|
|
|
|
_setupButtons: function() {
|
|
|
|
// Initialize buttons
|
|
|
|
this.find(':submit, button, :reset').livequery(function() {
|
|
|
|
jQuery(this).addClass(
|
|
|
|
'ui-state-default ' +
|
|
|
|
'ui-corner-all'
|
|
|
|
)
|
|
|
|
.hover(
|
|
|
|
function() {
|
|
|
|
$(this).addClass('ui-state-hover');
|
|
|
|
},
|
|
|
|
function() {
|
|
|
|
$(this).removeClass('ui-state-hover');
|
|
|
|
}
|
|
|
|
)
|
|
|
|
.focus(function() {
|
|
|
|
$(this).addClass('ui-state-focus');
|
|
|
|
})
|
|
|
|
.blur(function() {
|
|
|
|
$(this).removeClass('ui-state-focus');
|
|
|
|
});
|
2009-11-21 03:36:00 +01:00
|
|
|
});
|
2009-11-21 03:38:31 +01:00
|
|
|
},
|
2009-11-21 03:36:26 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
/**
|
|
|
|
* Resize elements in center panel
|
|
|
|
* to fit the boundary box provided by the layout manager
|
|
|
|
*/
|
|
|
|
_resizeChildren: function() {
|
|
|
|
$('#Form_EditForm').fitHeightToParent();
|
|
|
|
$('#Form_EditForm fieldset', this).fitHeightToParent();
|
|
|
|
// Order of resizing is important: Outer to inner
|
|
|
|
// TODO Only supports two levels of tabs at the moment
|
|
|
|
$('#Form_EditForm fieldset > .ss-tabset', this).fitHeightToParent();
|
|
|
|
$('#Form_EditForm fieldset > .ss-tabset > .tab', this).fitHeightToParent();
|
|
|
|
$('#Form_EditForm fieldset > .ss-tabset > .tab > .ss-tabset', this).fitHeightToParent();
|
|
|
|
$('#Form_EditForm fieldset > .ss-tabset > .tab > .ss-tabset > .tab', this).fitHeightToParent();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
2009-11-21 03:36:00 +01:00
|
|
|
|
2009-11-21 03:37:41 +01:00
|
|
|
/**
|
|
|
|
* @class Container for tree actions like "create", "search", etc.
|
|
|
|
* @name ss.TreeActions
|
|
|
|
*/
|
2009-11-21 03:37:48 +01:00
|
|
|
$('#TreeActions').concrete('ss', function($){
|
|
|
|
return/** @lends ss.TreeActions */{
|
2009-11-21 03:37:41 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
/**
|
|
|
|
* Setup "create", "search", "batch actions" layers above tree.
|
|
|
|
* All tab contents are closed by default.
|
|
|
|
*/
|
|
|
|
onmatch: function() {
|
|
|
|
this.tabs({
|
|
|
|
collapsible: true,
|
|
|
|
selected: parseInt(jQuery.cookie('ui-tabs-TreeActions'), 10) || null,
|
|
|
|
cookie: { expires: 30, path: '/', name: 'ui-tabs-TreeActions' }
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
2009-11-21 03:36:09 +01:00
|
|
|
|
2009-11-21 03:36:15 +01:00
|
|
|
/**
|
2009-11-21 03:37:41 +01:00
|
|
|
* @class Link for editing the profile for a logged-in member
|
2009-11-21 03:37:34 +01:00
|
|
|
* through a modal dialog.
|
2009-11-21 03:37:41 +01:00
|
|
|
* @name ss.EditMemberProfile
|
2009-11-21 03:36:15 +01:00
|
|
|
*/
|
2009-11-21 03:37:48 +01:00
|
|
|
$('a#EditMemberProfile').concrete('ss', function($){
|
|
|
|
return/** @lends ss.EditMemberProfile */{
|
2009-11-21 03:37:34 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
onmatch: function() {
|
|
|
|
var self = this;
|
2009-11-21 03:37:34 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
this.bind('click', function(e) {return self._openPopup();});
|
2009-11-21 03:37:34 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
$('body').append(
|
|
|
|
'<div id="ss-ui-dialog">'
|
|
|
|
+ '<iframe id="ss-ui-dialog-iframe" '
|
|
|
|
+ 'marginWidth="0" marginHeight="0" frameBorder="0" scrolling="auto">'
|
|
|
|
+ '</iframe>'
|
|
|
|
+ '</div>'
|
|
|
|
);
|
2009-11-21 03:37:34 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
var cookieVal = (jQuery.cookie) ? JSON.parse(jQuery.cookie('ss-ui-dialog')) : false;
|
|
|
|
$("#ss-ui-dialog").dialog(jQuery.extend({
|
|
|
|
autoOpen: false,
|
|
|
|
bgiframe: true,
|
|
|
|
modal: true,
|
|
|
|
height: 300,
|
|
|
|
width: 500,
|
|
|
|
ghost: true,
|
|
|
|
resizeStop: function(e, ui) {
|
|
|
|
self._resize();
|
|
|
|
self._saveState();
|
|
|
|
},
|
|
|
|
dragStop: function(e, ui) {
|
|
|
|
self._saveState();
|
|
|
|
},
|
|
|
|
// TODO i18n
|
|
|
|
title: 'Edit Profile'
|
|
|
|
}, cookieVal)).css('overflow', 'hidden');
|
2009-11-21 03:37:34 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
$('#ss-ui-dialog-iframe').bind('load', function(e) {self._resize();});
|
|
|
|
},
|
2009-11-21 03:37:34 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
_openPopup: function(e) {
|
|
|
|
$('#ss-ui-dialog-iframe').attr('src', this.attr('href'));
|
2009-11-21 03:37:34 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
$("#ss-ui-dialog").dialog('open');
|
2009-11-21 03:37:34 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
return false;
|
|
|
|
},
|
2009-11-21 03:37:34 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
_resize: function() {
|
|
|
|
var iframe = $('#ss-ui-dialog-iframe');
|
|
|
|
var container = $('#ss-ui-dialog');
|
2009-11-21 03:37:34 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
iframe.attr('width',
|
|
|
|
container.innerWidth()
|
|
|
|
- parseFloat(container.css('paddingLeft'))
|
|
|
|
- parseFloat(container.css('paddingRight'))
|
|
|
|
);
|
|
|
|
iframe.attr('height',
|
|
|
|
container.innerHeight()
|
|
|
|
- parseFloat(container.css('paddingTop'))
|
|
|
|
- parseFloat(container.css('paddingBottom'))
|
|
|
|
);
|
2009-11-21 03:37:34 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
this._saveState();
|
|
|
|
},
|
2009-11-21 03:37:34 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
_saveState: function() {
|
|
|
|
var container = $('#ss-ui-dialog');
|
2009-11-21 03:37:34 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
// save size in cookie (optional)
|
|
|
|
if(jQuery.cookie && container.width() && container.height()) {
|
|
|
|
jQuery.cookie(
|
|
|
|
'ss-ui-dialog',
|
|
|
|
JSON.stringify({
|
|
|
|
width: parseInt(container.width(), 10),
|
|
|
|
height: parseInt(container.height(), 10),
|
|
|
|
position: [
|
|
|
|
parseInt(container.offset().top, 10),
|
|
|
|
parseInt(container.offset().left, 10)
|
|
|
|
]
|
|
|
|
}),
|
|
|
|
{ expires: 30, path: '/'}
|
|
|
|
);
|
|
|
|
}
|
2009-11-21 03:37:34 +01:00
|
|
|
}
|
2009-11-21 03:38:31 +01:00
|
|
|
};
|
|
|
|
});
|
2009-11-21 03:38:17 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @class Links for viewing the currently loaded page
|
|
|
|
* in different modes: 'live', 'stage' or 'archived'.
|
|
|
|
* Automatically updates on loading a new page.
|
|
|
|
* @name ss.switchViewLinks
|
|
|
|
* @requires jquery.metadata
|
|
|
|
*/
|
|
|
|
$('#switchView a').concrete('ss', function($){
|
|
|
|
|
|
|
|
return/** @lends ss.switchViewLinks */{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @type DOMElement
|
|
|
|
*/
|
|
|
|
Form: null,
|
|
|
|
|
|
|
|
onmatch: function() {
|
|
|
|
var self = this;
|
|
|
|
this.setForm($('#Form_EditForm'));
|
|
|
|
|
|
|
|
jQuery('#Form_EditForm').bind('loadnewpage delete', function(e) {self.refresh();});
|
|
|
|
self.refresh();
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse new links based on the underlying form URLSegment,
|
|
|
|
* preserving the ?stage URL parameters if necessary.
|
|
|
|
*/
|
|
|
|
refresh: function() {
|
|
|
|
// TODO Compatible with nested urls?
|
|
|
|
var urlSegment = this.Form().find(':input[name=URLSegment]').val();
|
|
|
|
if(urlSegment) {
|
|
|
|
var locale = this.Form().find(':input[name=Locale]').val();
|
|
|
|
var url = urlSegment;
|
|
|
|
if(this.metadata().params) url += '?' + this.metadata().params;
|
|
|
|
if(locale) url += ((url.indexOf('?') > 0) ? '&' : '?') + "locale=" + locale;
|
|
|
|
this.attr('href', url);
|
|
|
|
}
|
|
|
|
|
|
|
|
// hide fields if no URLSegment is present
|
|
|
|
this.toggle((urlSegment));
|
|
|
|
},
|
|
|
|
|
|
|
|
onclick: function(e) {
|
|
|
|
// Open in popup
|
|
|
|
window.open($(e.target).attr('href'));
|
|
|
|
return false;
|
|
|
|
}
|
2009-11-21 03:38:31 +01:00
|
|
|
};
|
2009-11-21 03:38:17 +01:00
|
|
|
});
|
2009-11-21 03:37:34 +01:00
|
|
|
|
2009-11-21 03:36:00 +01:00
|
|
|
})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-07-19 12:40:05 +02:00
|
|
|
var _AJAX_LOADING = false;
|
|
|
|
|
|
|
|
|
2007-09-14 21:30:11 +02:00
|
|
|
// Event.observe(window, 'beforeunload', LeftAndMain_window_unload);
|
2007-07-19 12:40:05 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Unlock the locked status message.
|
|
|
|
* Show a queued message, if one exists
|
|
|
|
*/
|
|
|
|
function unlockStatusMessage() {
|
2007-09-15 03:25:07 +02:00
|
|
|
statusMessage.locked = false;
|
2007-07-19 12:40:05 +02:00
|
|
|
if(statusMessage.queued) {
|
|
|
|
statusMessage(
|
|
|
|
statusMessage.queued.msg,
|
|
|
|
statusMessage.queued.type,
|
2007-09-15 03:25:07 +02:00
|
|
|
statusMessage.queued.showNetworkActivity);
|
|
|
|
|
2007-07-19 12:40:05 +02:00
|
|
|
statusMessage.queued = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Submit the given form and evaluate the Ajax response.
|
|
|
|
* Needs to be bound to an object with the following parameters to work:
|
|
|
|
* - form
|
|
|
|
* - action
|
|
|
|
* - verb
|
2007-09-15 03:25:07 +02:00
|
|
|
*
|
2007-07-19 12:40:05 +02:00
|
|
|
* The bound function can then be called, with the arguments passed
|
|
|
|
*/
|
2007-09-15 03:25:07 +02:00
|
|
|
|
2007-07-19 12:40:05 +02:00
|
|
|
function ajaxSubmitForm(automated, callAfter, form, action, verb) {
|
|
|
|
var alreadySaved = false;
|
|
|
|
if($(form).elements.length < 2) alreadySaved = true;
|
|
|
|
|
|
|
|
if(alreadySaved) {
|
|
|
|
if(callAfter) callAfter();
|
2007-09-15 03:25:07 +02:00
|
|
|
|
2007-07-19 12:40:05 +02:00
|
|
|
} else {
|
|
|
|
statusMessage(verb + '...', '', true);
|
|
|
|
|
|
|
|
var success = function(response) {
|
|
|
|
Ajax.Evaluator(response);
|
|
|
|
if(callAfter) callAfter();
|
|
|
|
}
|
2007-09-15 03:25:07 +02:00
|
|
|
|
2007-07-19 12:40:05 +02:00
|
|
|
if(callAfter) success = success.bind({callAfter : callAfter});
|
|
|
|
Ajax.SubmitForm(form, action, {
|
|
|
|
onSuccess : success,
|
|
|
|
onFailure : function(response) {
|
|
|
|
errorMessage('Error ' + verb, response);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2007-09-15 03:25:07 +02:00
|
|
|
|
2007-07-19 12:40:05 +02:00
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Behaviour of the statuts message.
|
|
|
|
*/
|
|
|
|
Behaviour.register({
|
|
|
|
'#statusMessage' : {
|
|
|
|
showMessage : function(message, type, waitTime, clearManually) {
|
|
|
|
if(this.fadeTimer) {
|
|
|
|
clearTimeout(this.fadeTimer);
|
|
|
|
this.fadeTimer = null;
|
|
|
|
}
|
|
|
|
if(this.currentEffect) {
|
|
|
|
this.currentEffect.cancel();
|
|
|
|
this.currentEffect = null;
|
|
|
|
}
|
2007-09-15 03:25:07 +02:00
|
|
|
|
2007-07-19 12:40:05 +02:00
|
|
|
this.innerHTML = message;
|
|
|
|
this.className = type;
|
2007-09-15 03:25:07 +02:00
|
|
|
Element.setOpacity(this, 1);
|
|
|
|
|
2008-09-30 05:04:35 +02:00
|
|
|
//this.style.position = 'absolute';
|
2007-07-19 12:40:05 +02:00
|
|
|
this.style.display = '';
|
|
|
|
this.style.visibility = '';
|
2007-09-15 03:25:07 +02:00
|
|
|
|
2007-07-19 12:40:05 +02:00
|
|
|
if(!clearManually) {
|
|
|
|
this.fade(0.5,waitTime ? waitTime : 5);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
clearMessage : function(waitTime) {
|
|
|
|
this.fade(0.5, waitTime);
|
|
|
|
},
|
|
|
|
fade: function(fadeTime, waitTime) {
|
|
|
|
if(!fadeTime) fadeTime = 0.5;
|
2007-09-15 03:25:07 +02:00
|
|
|
|
|
|
|
// Wait a bit before fading
|
2007-07-19 12:40:05 +02:00
|
|
|
if(waitTime) {
|
|
|
|
this.fadeTimer = setTimeout((function() {
|
|
|
|
this.fade(fadeTime);
|
|
|
|
}).bind(this), waitTime * 1000);
|
2007-09-15 03:25:07 +02:00
|
|
|
|
2007-07-19 12:40:05 +02:00
|
|
|
// Fade straight away
|
|
|
|
} else {
|
|
|
|
this.currentEffect = new Effect.Opacity(this,
|
2007-09-15 03:25:07 +02:00
|
|
|
{ duration: 0.5,
|
|
|
|
transition: Effect.Transitions.linear,
|
2007-07-19 12:40:05 +02:00
|
|
|
from: 1.0, to: 0.0,
|
|
|
|
afterFinish : this.afterFade.bind(this) });
|
|
|
|
}
|
|
|
|
},
|
|
|
|
afterFade : function() {
|
|
|
|
this.style.visibility = 'hidden';
|
|
|
|
this.style.display = 'none';
|
|
|
|
this.innerHTML = '';
|
|
|
|
}
|
2007-09-15 03:25:07 +02:00
|
|
|
}
|
2007-07-19 12:40:05 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
2007-09-15 03:25:07 +02:00
|
|
|
* Show a status message.
|
|
|
|
*
|
2007-07-19 12:40:05 +02:00
|
|
|
* @param msg String
|
|
|
|
* @param type String (optional) can be 'good' or 'bad'
|
|
|
|
* @param clearManually boolean Don't automatically fade message.
|
2007-09-16 04:25:07 +02:00
|
|
|
* @param container custom #statusMessage element to show message.
|
2007-07-19 12:40:05 +02:00
|
|
|
*/
|
2007-09-16 04:25:07 +02:00
|
|
|
function statusMessage(msg, type, clearManually, container) {
|
2007-07-19 12:40:05 +02:00
|
|
|
var statusMessageEl = $('statusMessage');
|
2007-09-16 04:25:07 +02:00
|
|
|
if(container != null) statusMessageEl = container;
|
2007-07-19 12:40:05 +02:00
|
|
|
if(statusMessageEl) {
|
|
|
|
if(msg) {
|
2009-03-12 17:39:25 +01:00
|
|
|
statusMessageEl.showMessage(msg, type, msg.length / 10, clearManually);
|
2007-07-19 12:40:05 +02:00
|
|
|
} else {
|
|
|
|
statusMessageEl.clearMessage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function clearStatusMessage() {
|
|
|
|
$('statusMessage').clearMessage();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when something goes wrong
|
|
|
|
*/
|
|
|
|
function errorMessage(msg, fullMessage) {
|
2008-09-16 23:46:08 +02:00
|
|
|
// Show complex error for developers in the console
|
|
|
|
if(fullMessage) {
|
2007-07-19 12:40:05 +02:00
|
|
|
// Get the message from an Ajax response object
|
|
|
|
try {
|
|
|
|
if(typeof fullMessage == 'object') fullMessage = fullMessage.status + '//' + fullMessage.responseText;
|
|
|
|
} catch(er) {
|
|
|
|
fullMessage = "";
|
|
|
|
}
|
2008-09-17 00:08:02 +02:00
|
|
|
console.error(fullMessage);
|
2007-07-19 12:40:05 +02:00
|
|
|
}
|
2008-09-16 23:46:08 +02:00
|
|
|
|
|
|
|
msg = msg.replace(/\n/g,'<br>');
|
2007-09-15 03:25:07 +02:00
|
|
|
|
2008-09-16 23:46:08 +02:00
|
|
|
$('statusMessage').showMessage(msg,'bad');
|
2007-07-19 12:40:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function ajaxErrorHandler(response) {
|
2008-09-16 23:46:08 +02:00
|
|
|
errorMessage('Server Error', response);
|
2007-07-19 12:40:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function hideLoading() {
|
2008-10-08 03:10:38 +02:00
|
|
|
if($('Loading')) $('Loading').style.display = 'none';
|
2008-08-06 05:28:25 +02:00
|
|
|
Element.removeClassName(document.body, 'stillLoading');
|
2007-07-19 12:40:05 +02:00
|
|
|
}
|
|
|
|
|
2007-09-15 03:25:07 +02:00
|
|
|
returnFalse = function() {
|
2007-07-19 12:40:05 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
var _CURRENT_CONTEXT_MENU = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new context menu
|
|
|
|
* @param event The event object
|
|
|
|
* @param owner The DOM element that this context-menu was requested from
|
2007-09-15 03:25:07 +02:00
|
|
|
* @param menuItems A map of title -> method; context-menu operations to get called
|
2007-07-19 12:40:05 +02:00
|
|
|
*/
|
|
|
|
function createContextMenu(event, owner, menuItems) {
|
|
|
|
if(_CURRENT_CONTEXT_MENU) {
|
|
|
|
document.body.removeChild(_CURRENT_CONTEXT_MENU);
|
|
|
|
_CURRENT_CONTEXT_MENU = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
var menu = document.createElement("ul");
|
|
|
|
menu.className = 'contextMenu';
|
|
|
|
menu.style.position = 'absolute';
|
|
|
|
menu.style.left = event.clientX + 'px';
|
|
|
|
menu.style.top = event.clientY + 'px';
|
2007-09-15 03:25:07 +02:00
|
|
|
|
2007-07-19 12:40:05 +02:00
|
|
|
var menuItemName, menuItemTag, menuATag;
|
|
|
|
for(menuItemName in menuItems) {
|
|
|
|
menuItemTag = document.createElement("li");
|
|
|
|
|
|
|
|
menuATag = document.createElement("a");
|
|
|
|
menuATag.href = "#";
|
|
|
|
menuATag.onclick = menuATag.oncontextmenu = contextmenu_onclick;
|
|
|
|
menuATag.innerHTML = menuItemName;
|
|
|
|
menuATag.handler = menuItems[menuItemName];
|
|
|
|
menuATag.owner = owner;
|
|
|
|
|
|
|
|
menuItemTag.appendChild(menuATag);
|
|
|
|
menu.appendChild(menuItemTag);
|
|
|
|
}
|
2007-09-15 03:25:07 +02:00
|
|
|
|
2007-07-19 12:40:05 +02:00
|
|
|
document.body.appendChild(menu);
|
2007-09-15 03:25:07 +02:00
|
|
|
|
2007-07-19 12:40:05 +02:00
|
|
|
document.body.onclick = contextmenu_close;
|
2007-09-15 03:25:07 +02:00
|
|
|
|
2007-07-19 12:40:05 +02:00
|
|
|
_CURRENT_CONTEXT_MENU = menu;
|
2007-09-15 03:25:07 +02:00
|
|
|
|
2007-07-19 12:40:05 +02:00
|
|
|
return menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
function contextmenu_close() {
|
|
|
|
if(_CURRENT_CONTEXT_MENU) {
|
|
|
|
document.body.removeChild(_CURRENT_CONTEXT_MENU);
|
|
|
|
_CURRENT_CONTEXT_MENU = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function contextmenu_onclick() {
|
|
|
|
this.handler(this.owner);
|
|
|
|
contextmenu_close();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-05-14 08:11:18 +02:00
|
|
|
/**
|
|
|
|
* Find and enable TinyMCE on all htmleditor fields
|
|
|
|
* Pulled in from old tinymce.template.js
|
|
|
|
*/
|
|
|
|
|
|
|
|
function nullConverter(url) {
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
|
|
|
Behaviour.register({
|
|
|
|
'textarea.htmleditor' : {
|
|
|
|
initialize : function() {
|
|
|
|
tinyMCE.execCommand("mceAddControl", true, this.id);
|
|
|
|
this.isChanged = function() {
|
|
|
|
return tinyMCE.getInstanceById(this.id).isDirty();
|
|
|
|
}
|
|
|
|
this.resetChanged = function() {
|
|
|
|
inst = tinyMCE.getInstanceById(this.id);
|
2009-05-15 02:13:11 +02:00
|
|
|
if (inst) inst.startContent = tinymce.trim(inst.getContent({format : 'raw', no_events : 1}));
|
2009-05-14 08:11:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
ENHANCEMENT Using jQuery layout manager plugin to size panels in main CMS interface. Removed custom javascript resizing and CSS rules.
API CHANGE Removed custom resizing javascript methods: window.ontabschanged, window.onresize, fixRightWidth(), fixHeight_left()
API CHANGE Removed DraggableSeparator, SideTabs, SideTabItem javascript classes
API CHANGE Removed Effect.ReSize and Highlighter javascript helper classes
API CHANGE Modified template structure in CMSMain_left.ss, CMSMain_right.ss and LeftAndMain.ss
API CHANGE Modified markup IDs in LeftAndMain/CMSMain templates, removed "left", "right", "contentPanel", "bottom"
ENHANCEMENT Using jquery-latest (currently 1.3) in CMSMain and LeftAndMain
ENHANCEMENT Added jQuery UI library and "smoothness" theme to default CMS interface
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@92581 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-11-21 03:35:20 +01:00
|
|
|
});
|