Skip to content

Commit

Permalink
MINOR Updated cms javascript to new concrete API around namespaces an…
Browse files Browse the repository at this point in the history
…d properties

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@92608 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information
chillu committed Nov 21, 2009
1 parent d973510 commit d5ec175
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 31 deletions.
36 changes: 21 additions & 15 deletions javascript/CMSMain.js
@@ -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();
},

/**
Expand All @@ -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: {
Expand All @@ -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: {}
Expand All @@ -75,7 +81,7 @@

return layout;
}
}}});
});

/**
* CMS-specific form behaviour
Expand Down
36 changes: 20 additions & 16 deletions javascript/LeftAndMain.js
Expand Up @@ -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);
},

/**
Expand Down Expand Up @@ -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();});
},

/**
Expand Down Expand Up @@ -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
Expand All @@ -124,7 +127,7 @@

$form.trigger('afterSubmit', [result]);

$form.ss().loadNewPage();
$form.loadNewPage();
},
// @todo Currently all responses are assumed to be evaluated
'script'
Expand Down Expand Up @@ -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.
Expand All @@ -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;
}
});
Expand All @@ -229,6 +232,7 @@
}
});


})(jQuery);

jQuery(document).ready(function() {
Expand Down

0 comments on commit d5ec175

Please sign in to comment.