1 function Panel(target) {
4 this.instanceId = Math.ceil(Math.random() * 1000000000);
5 $.log('new panel - target: ', this.target);
6 $(document).bind('panel:unload.' + this.instanceId,
7 function(event, data) { self.unload(event, data); });
10 Panel.prototype.load = function (url) {
11 $.log('preparing xhr load: ', this.target);
12 $('.change-notification', $(this.target).parent()).fadeOut();
13 $(document).trigger('panel:unload', this.target);
19 success: function(data, tstat) {
20 load_callback = unload_callback = null;
21 $(self.target).html(data);
22 self._onUnload = unload_callback;
24 if(load_callback != null) {
25 $.log('Invoking panel load callback.');
29 error: function(request, textStatus, errorThrown) {
30 $.log('ajax', url, this.target, 'error:', textStatus, errorThrown);
35 Panel.prototype.unload = function(event, data) {
36 $.log('got unload signal', this.target, ' target: ', data);
37 if(this.target == data) {
38 $(document).unbind('panel:unload.' + this.instanceId);
39 $(this.target).html('');
40 if(this._onUnload != null) this._onUnload(this);
47 * Return the data that should be saved
49 Panel.prototype.saveData = function() {
55 $('#panels').makeHorizPanel({});
56 $('#panels').css('top', ($('#header').outerHeight() ) + 'px');
58 $('.panel-content').each(function() {
59 var ctrl = new Panel(this);
60 $(this).data('ctrl', ctrl);
63 $('.panel-toolbar select').change(function() {
64 var panel = $('.panel-content', $(this).parent().parent());
65 $(panel).data('ctrl').load( $(this).val() );