MINOR Updated cms javascript to new concrete API around namespaces and properties

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@92608 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2009-11-21 02:36:22 +00:00
parent d973510fef
commit d5ec175cfb
2 changed files with 41 additions and 31 deletions

View File

@ -1,25 +1,30 @@
(function($) {
$('body.CMSMain').concrete({ss:{cmsMain:{
mainLayout: null,
$('body.CMSMain').concrete('ss.leftAndMain', {
MainLayout: null,
onmatch: function() {
var $this = $(this);
this.mainLayout = this.ss().cmsMain()._setupLayout();
var self = this;
this.concrete("ss.leftAndMain").setMainLayout(this.concrete("ss.leftAndMain")._setupLayout());
// artificially delay the resize event 200ms
// to avoid overlapping height changes in different onresize() methods
$(window).resize(function () {
var timerID = "timerCMSMainResize";
if (window[timerID]) clearTimeout(window[timerID]);
window[timerID] = setTimeout(function() {$this.ss().cmsMain()._resizeChildren();}, 200);
window[timerID] = setTimeout(function() {self.concrete("ss.leftAndMain")._resizeChildren();}, 200);
});
this.ss().cmsMain()._resizeChildren();
this.concrete("ss.leftAndMain")._resizeChildren();
this._super();
},
_resizeChildren: function() {
$("#treepanes").accordion("resize");
$('#sitetree_and_tools').fitHeightToParent();
this._super();
},
/**
@ -31,7 +36,8 @@
* - south: "Page view", "profile" and "logout" links
*/
_setupLayout: function() {
var $this = this;
var self = this;
// layout containing the tree, CMS menu, the main form etc.
var layout = $('body').layout({
defaults: {
@ -53,14 +59,14 @@
size: 20,
togglerLength_open: 0
},
east: {
initClosed: true,
fxName: "none"
},
west: {
size: 250,
onresize: function() {$this.ss().cmsMain()._resizeChildren();},
onopen: function() {$this.ss().cmsMain()._resizeChildren();},
onresize: function() {self.concrete()._resizeChildren();},
onopen: function() {self.concrete()._resizeChildren();},
fxName: "none"
},
east: {
initClosed: true,
fxName: "none"
},
center: {}
@ -75,7 +81,7 @@
return layout;
}
}}});
});
/**
* CMS-specific form behaviour

View File

@ -10,19 +10,21 @@
* - beforeValidate
* - afterValidate
*/
$('.LeftAndMain').concrete({ss:{leftAndMain:{
$('.LeftAndMain').concrete('ss.leftAndMain', {
PingIntervalSeconds: 5*60,
onmatch: function() {
this.ss().leftAndMain()._setupPinging();
this.ss().leftAndMain()._setupButtons();
this.concrete("ss.leftAndMain")._setupPinging();
this.concrete("ss.leftAndMain")._setupButtons();
this._super();
},
_setupPinging: function() {
var pingIntervalSeconds = 5*60;
// setup pinging for login expiry
setInterval(function() {
$.get("Security/ping");
}, pingIntervalSeconds * 1000);
}, this.PingIntervalSeconds() * 1000);
},
/**
@ -51,29 +53,30 @@
});
});
}
}}});
});
/**
* Base edit form, provides ajaxified saving
* and reloading itself through the ajax return values.
* Takes care of resizing tabsets within the layout container.
*/
$('#Form_EditForm').concrete({ss:{
$('#Form_EditForm').concrete('ss.editForm',{
onmatch: function() {
var $this = this;
var self = this;
// 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() {$this.ss()._resizeChildren();}, 200);
window[timerID] = setTimeout(function() {self.concrete('ss.editForm')._resizeChildren();}, 200);
});
this.ss()._resizeChildren();
this.concrete('ss.editForm')._resizeChildren();
// trigger resize whenever new tabs are shown
// @todo This is called multiple times when tabs are loaded
this.find('.ss-tabset').bind('tabsshow', function() {$this.ss()._resizeChildren();});
this.find('.ss-tabset').bind('tabsshow', function() {self.concrete('ss.editForm')._resizeChildren();});
},
/**
@ -101,7 +104,7 @@
if(typeof tinyMCE != 'undefined') tinyMCE.triggerSave();
// validate if required
if(!this.ss().validate()) {
if(!this.validate()) {
this.trigger('validationError', [button]);
// TODO Automatically switch to the tab/position of the first error
@ -124,7 +127,7 @@
$form.trigger('afterSubmit', [result]);
$form.ss().loadNewPage();
$form.loadNewPage();
},
// @todo Currently all responses are assumed to be evaluated
'script'
@ -194,7 +197,7 @@
$('fieldset > .ss-tabset > .tab > .ss-tabset', this).fitHeightToParent();
$('fieldset > .ss-tabset > .tab > .ss-tabset > .tab', this).fitHeightToParent();
}
}});
});
/**
* All buttons in the right CMS form go through here by default.
@ -203,7 +206,7 @@
*/
$('#Form_EditForm .Actions :submit').concrete({
onclick: function(e) {
$(this[0].form).ss().ajaxSubmit(this);
$(this[0].form).ajaxSubmit(this);
return false;
}
});
@ -229,6 +232,7 @@
}
});
})(jQuery);
jQuery(document).ready(function() {