mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
MINOR Adjusted CMS JavaScript to new jquery-concrete API: Getters have 'get' prefix, namespaces are defined in blocks, event handlers work consistently. Mostly indentation and structure changes, no logic changes.
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@92825 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
1036329e86
commit
4d60aa5c83
@ -16,11 +16,10 @@ var _HANDLER_FORMS = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
(function($) {
|
(function($) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete selected folders through "batch actions" tab.
|
* Delete selected folders through "batch actions" tab.
|
||||||
*/
|
*/
|
||||||
$(function() {
|
$(document).ready(function() {
|
||||||
$('#Form_BatchActionsForm').concrete('ss').register(
|
$('#Form_BatchActionsForm').concrete('ss').register(
|
||||||
// TODO Hardcoding of base URL
|
// TODO Hardcoding of base URL
|
||||||
'admin/assets/batchactions/delete',
|
'admin/assets/batchactions/delete',
|
||||||
@ -36,32 +35,26 @@ var _HANDLER_FORMS = {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#Form_SyncForm').concrete('ss', function($) {
|
$.concrete('ss', function($){
|
||||||
return {
|
$('#Form_SyncForm').concrete({
|
||||||
onmatch: function() {
|
onsubmit: function(e) {
|
||||||
this.bind('submit', this._onsubmit);
|
|
||||||
this._super();
|
|
||||||
},
|
|
||||||
_onsubmit: function(e) {
|
|
||||||
var button = jQuery(this).find(':submit:first');
|
var button = jQuery(this).find(':submit:first');
|
||||||
button.addClass('loading');
|
button.addClass('loading');
|
||||||
$.get(
|
$.get(
|
||||||
jQuery(this).attr('action'),
|
jQuery(this).attr('action'),
|
||||||
function() {
|
function() {
|
||||||
button.removeClass('loading');
|
button.removeClass('loading');
|
||||||
|
|
||||||
// reload current
|
// reload current
|
||||||
var currNode = $('#sitetree')[0].firstSelected();
|
var currNode = $('#sitetree')[0].firstSelected();
|
||||||
if(currNode) {
|
if(currNode) {
|
||||||
var url = $(currNode).find('a').attr('href');
|
var url = $(currNode).find('a').attr('href');
|
||||||
$('#Form_EditForm').concrete('ss').loadForm(url);
|
$('#Form_EditForm').loadForm(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
});
|
});
|
||||||
}(jQuery));
|
}(jQuery));
|
@ -1,28 +1,23 @@
|
|||||||
(function($) {
|
(function($) {
|
||||||
|
$.concrete('ss', function($){
|
||||||
/**
|
/**
|
||||||
* Alert the user on change of page-type - this might have implications
|
* Alert the user on change of page-type - this might have implications
|
||||||
* on the available form fields etc.
|
* on the available form fields etc.
|
||||||
* @name ss.EditFormClassName
|
* @name ss.EditFormClassName
|
||||||
*/
|
*/
|
||||||
$('#Form_EditForm :input[name=ClassName]').concrete('ss', function($){
|
$('#Form_EditForm :input[name=ClassName]').concrete(/** @lends ss.EditFormClassName */{
|
||||||
return/** @lends ss.EditFormClassName */{
|
|
||||||
onchange: function() {
|
onchange: function() {
|
||||||
alert(ss.i18n._t('CMSMAIN.ALERTCLASSNAME'));
|
alert(ss.i18n._t('CMSMAIN.ALERTCLASSNAME'));
|
||||||
}
|
}
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class Input validation on the URLSegment field
|
* @class Input validation on the URLSegment field
|
||||||
* @name ss.EditForm.URLSegment
|
* @name ss.EditForm.URLSegment
|
||||||
*/
|
*/
|
||||||
$('#Form_EditForm input[name=URLSegment]').concrete('ss', function($){
|
$('#Form_EditForm input[name=URLSegment]').concrete(/** @lends ss.EditForm.URLSegment */{
|
||||||
return/** @lends ss.EditForm.URLSegment */{
|
|
||||||
|
|
||||||
FilterRegex: /[^A-Za-z0-9-]+/,
|
FilterRegex: /[^A-Za-z0-9-]+/,
|
||||||
|
|
||||||
ValidationMessage: ss.i18n._t('CMSMAIN.URLSEGMENTVALIDATION'),
|
ValidationMessage: ss.i18n._t('CMSMAIN.URLSEGMENTVALIDATION'),
|
||||||
|
|
||||||
MaxLength: 50,
|
MaxLength: 50,
|
||||||
|
|
||||||
onmatch : function() {
|
onmatch : function() {
|
||||||
@ -31,11 +26,13 @@
|
|||||||
// intercept change event, do our own writing
|
// intercept change event, do our own writing
|
||||||
this.bind('change', function(e) {
|
this.bind('change', function(e) {
|
||||||
if(!self.validate()) {
|
if(!self.validate()) {
|
||||||
jQuery.noticeAdd(self.ValidationMessage());
|
jQuery.noticeAdd(self.getValidationMessage());
|
||||||
}
|
}
|
||||||
self.val(self.suggestValue(e.target.value));
|
self.val(self.suggestValue(e.target.value));
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this._super();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -46,25 +43,22 @@
|
|||||||
*/
|
*/
|
||||||
suggestValue: function(val) {
|
suggestValue: function(val) {
|
||||||
// TODO Do we want to enforce lowercasing in URLs?
|
// TODO Do we want to enforce lowercasing in URLs?
|
||||||
return val.substr(0, this.MaxLength()).replace(this.FilterRegex(), '').toLowerCase();
|
return val.substr(0, this.getMaxLength()).replace(this.getFilterRegex(), '').toLowerCase();
|
||||||
},
|
},
|
||||||
|
|
||||||
validate: function() {
|
validate: function() {
|
||||||
return (
|
return (
|
||||||
this.val().length > this.MaxLength()
|
this.val().length > this.getMaxLength()
|
||||||
|| this.val().match(this.FilterRegex())
|
|| this.val().match(this.getFilterRegex())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class Input validation on the Title field
|
* @class Input validation on the Title field
|
||||||
* @name ss.EditForm.Title
|
* @name ss.EditForm.Title
|
||||||
*/
|
*/
|
||||||
$('#Form_EditForm input[name=Title]').concrete('ss', function($){
|
$('#Form_EditForm input[name=Title]').concrete(/** @lends ss.EditForm.Title */{
|
||||||
return/** @lends ss.EditForm.Title */{
|
|
||||||
|
|
||||||
onmatch : function() {
|
onmatch : function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
@ -73,6 +67,8 @@
|
|||||||
// TODO We should really user-confirm these changes
|
// TODO We should really user-confirm these changes
|
||||||
self.parents('form').find('input[name=MetaTitle], input[name=MenuTitle]').val(self.val());
|
self.parents('form').find('input[name=MetaTitle], input[name=MenuTitle]').val(self.val());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this._super();
|
||||||
},
|
},
|
||||||
|
|
||||||
updateURLSegment: function(field) {
|
updateURLSegment: function(field) {
|
||||||
@ -97,7 +93,6 @@
|
|||||||
field.val(suggestion);
|
field.val(suggestion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -105,14 +100,13 @@
|
|||||||
* the two radiobuttons and setting the hidden "ParentID" field
|
* the two radiobuttons and setting the hidden "ParentID" field
|
||||||
* @name ss.EditForm.parentTypeSelector
|
* @name ss.EditForm.parentTypeSelector
|
||||||
*/
|
*/
|
||||||
$('#Form_EditForm .parentTypeSelector').concrete('ss', function($){
|
$('#Form_EditForm .parentTypeSelector').concrete(/** @lends ss.EditForm.parentTypeSelector */{
|
||||||
return/** @lends ss.EditForm.parentTypeSelector */{
|
|
||||||
onmatch : function() {
|
onmatch : function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this.find(':input[name=ParentType]').bind('click', function(e) {self._toggleSelection(e);});
|
this.find(':input[name=ParentType]').bind('click', function(e) {self._toggleSelection(e);});
|
||||||
|
|
||||||
this._toggleSelection();
|
this._toggleSelection();
|
||||||
|
|
||||||
|
this._super();
|
||||||
},
|
},
|
||||||
|
|
||||||
_toggleSelection: function(e) {
|
_toggleSelection: function(e) {
|
||||||
@ -122,7 +116,6 @@
|
|||||||
// toggle tree dropdown based on selection
|
// toggle tree dropdown based on selection
|
||||||
this.find('#ParentID').toggle(selected != 'root');
|
this.find('#ParentID').toggle(selected != 'root');
|
||||||
}
|
}
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -130,8 +123,7 @@
|
|||||||
* based on selection of radiobuttons.
|
* based on selection of radiobuttons.
|
||||||
* @name ss.Form_EditForm.Access
|
* @name ss.Form_EditForm.Access
|
||||||
*/
|
*/
|
||||||
$('#Form_EditForm #CanViewType, #Form_EditForm #CanEditType').concrete('ss', function($){
|
$('#Form_EditForm #CanViewType, #Form_EditForm #CanEditType').concrete(/** @lends ss.Form_EditForm.Access */{
|
||||||
return/** @lends ss.Form_EditForm.Access */{
|
|
||||||
onmatch: function() {
|
onmatch: function() {
|
||||||
// TODO Decouple
|
// TODO Decouple
|
||||||
var dropdown;
|
var dropdown;
|
||||||
@ -145,8 +137,9 @@
|
|||||||
// initial state
|
// initial state
|
||||||
var currentVal = this.find('input[name=' + this.attr('id') + ']:checked').val();
|
var currentVal = this.find('input[name=' + this.attr('id') + ']:checked').val();
|
||||||
dropdown.toggle(currentVal == 'OnlyTheseUsers');
|
dropdown.toggle(currentVal == 'OnlyTheseUsers');
|
||||||
|
|
||||||
|
this._super();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -154,8 +147,7 @@
|
|||||||
* Visible on readonly older versions of a specific page at the moment.
|
* Visible on readonly older versions of a specific page at the moment.
|
||||||
* @name ss.Form_EditForm_action_email
|
* @name ss.Form_EditForm_action_email
|
||||||
*/
|
*/
|
||||||
$('#Form_EditForm .Actions #Form_EditForm_action_email').concrete('ss', function($){
|
$('#Form_EditForm .Actions #Form_EditForm_action_email').concrete(/** @lends ss.Form_EditForm_action_email */{
|
||||||
return/** @lends ss.Form_EditForm_action_email */{
|
|
||||||
onclick: function(e) {
|
onclick: function(e) {
|
||||||
window.open(
|
window.open(
|
||||||
'mailto:?subject='
|
'mailto:?subject='
|
||||||
@ -167,7 +159,6 @@
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -175,8 +166,7 @@
|
|||||||
* Used for readonly older versions of a specific page.
|
* Used for readonly older versions of a specific page.
|
||||||
* @name ss.Form_EditForm_action_print
|
* @name ss.Form_EditForm_action_print
|
||||||
*/
|
*/
|
||||||
$('#Form_EditForm .Actions #Form_EditForm_action_print').concrete('ss', function($){
|
$('#Form_EditForm .Actions #Form_EditForm_action_print').concrete(/** @lends ss.Form_EditForm_action_print */{
|
||||||
return/** @lends ss.Form_EditForm_action_print */{
|
|
||||||
onclick: function(e) {
|
onclick: function(e) {
|
||||||
var printURL = $(this[0].form).attr('action').replace(/\?.*$/,'')
|
var printURL = $(this[0].form).attr('action').replace(/\?.*$/,'')
|
||||||
+ '/printable/'
|
+ '/printable/'
|
||||||
@ -187,19 +177,17 @@
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class A "rollback" to a specific version needs user confirmation.
|
* @class A "rollback" to a specific version needs user confirmation.
|
||||||
* @name ss.Form_EditForm_action_rollback
|
* @name ss.Form_EditForm_action_rollback
|
||||||
*/
|
*/
|
||||||
$('#Form_EditForm .Actions #Form_EditForm_action_rollback').concrete('ss', function($){
|
$('#Form_EditForm .Actions #Form_EditForm_action_rollback').concrete(/** @lends ss.Form_EditForm_action_rollback */{
|
||||||
return/** @lends ss.Form_EditForm_action_rollback */{
|
|
||||||
onclick: function(e) {
|
onclick: function(e) {
|
||||||
// @todo i18n
|
// @todo i18n
|
||||||
return confirm("Do you really want to copy the published content to the stage site?");
|
return confirm("Do you really want to copy the published content to the stage site?");
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
});
|
});
|
||||||
}(jQuery));
|
}(jQuery));
|
@ -1,11 +1,11 @@
|
|||||||
(function($) {
|
(function($) {
|
||||||
|
$.concrete('ss', function($){
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class Dropdown with languages above CMS tree, causing a redirect upon translation
|
* @class Dropdown with languages above CMS tree, causing a redirect upon translation
|
||||||
* @name ss.CMSMain.LangSelector
|
* @name ss.CMSMain.LangSelector
|
||||||
*/
|
*/
|
||||||
$('.CMSMain #Form_LangForm').concrete('ss', function($){
|
$('.CMSMain #Form_LangForm').concrete(/** @lends ss.CMSMain.LangSelector */{
|
||||||
return/** @lends ss.CMSMain.LangSelector */{
|
|
||||||
onmatch: function() {
|
onmatch: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
@ -24,8 +24,9 @@
|
|||||||
document.location = url;
|
document.location = url;
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this._super();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -37,8 +38,7 @@
|
|||||||
* @name ss.CMSMain.createtranslation
|
* @name ss.CMSMain.createtranslation
|
||||||
* @requires jquery.metadata
|
* @requires jquery.metadata
|
||||||
*/
|
*/
|
||||||
$('.CMSMain .createTranslation').concrete('ss', function($){
|
$('.CMSMain .createTranslation').concrete(/** @lends ss.CMSMain.createtranslation */{
|
||||||
return/** @lends ss.CMSMain.createtranslation */{
|
|
||||||
onmatch: function() {
|
onmatch: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
@ -55,8 +55,9 @@
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
|
this._super();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
}(jQuery));
|
}(jQuery));
|
@ -1,11 +1,11 @@
|
|||||||
(function($) {
|
(function($) {
|
||||||
|
$.concrete('ss', function($){
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class All forms in the right content panel should have closeable jQuery UI style titles.
|
* @class All forms in the right content panel should have closeable jQuery UI style titles.
|
||||||
* @name ss.contentPanel.form
|
* @name ss.contentPanel.form
|
||||||
*/
|
*/
|
||||||
$('#contentPanel form').concrete('ss', function($){
|
$('#contentPanel form').concrete(/** @lends ss.contentPanel.form */{
|
||||||
return/** @lends ss.contentPanel.form */{
|
|
||||||
onmatch: function() {
|
onmatch: function() {
|
||||||
// Style as title bar
|
// Style as title bar
|
||||||
this.find(':header:first').titlebar({
|
this.find(':header:first').titlebar({
|
||||||
@ -14,11 +14,11 @@
|
|||||||
// The close button should close the east panel of the layout
|
// The close button should close the east panel of the layout
|
||||||
this.find(':header:first .ui-dialog-titlebar-close').bind('click', function(e) {
|
this.find(':header:first .ui-dialog-titlebar-close').bind('click', function(e) {
|
||||||
$('body.CMSMain').concrete('ss').MainLayout().close('east');
|
$('body.CMSMain').concrete('ss').MainLayout().close('east');
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this._super();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,9 +27,7 @@
|
|||||||
* similar to "Smart Search" criteria in iTunes.
|
* similar to "Smart Search" criteria in iTunes.
|
||||||
* @name ss.Form_SeachTreeForm
|
* @name ss.Form_SeachTreeForm
|
||||||
*/
|
*/
|
||||||
$('#Form_SearchTreeForm').concrete('ss', function($) {
|
$('#Form_SearchTreeForm').concrete(/** @lends ss.Form_SeachTreeForm */{
|
||||||
return/** @lends ss.Form_SeachTreeForm */{
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type DOMElement
|
* @type DOMElement
|
||||||
*/
|
*/
|
||||||
@ -38,10 +36,6 @@
|
|||||||
onmatch: function() {
|
onmatch: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
// TODO Cant bind to onsubmit/onreset directly because of IE6
|
|
||||||
this.bind('submit', function(e) {return self._submitForm(e);});
|
|
||||||
this.bind('reset', function(e) {return self._resetForm(e);});
|
|
||||||
|
|
||||||
// only the first field should be visible by default
|
// only the first field should be visible by default
|
||||||
this.find('.field').not(':first').hide();
|
this.find('.field').not(':first').hide();
|
||||||
|
|
||||||
@ -53,21 +47,22 @@
|
|||||||
|
|
||||||
this._setOptions();
|
this._setOptions();
|
||||||
|
|
||||||
|
this._super();
|
||||||
},
|
},
|
||||||
|
|
||||||
_setOptions: function() {
|
_setOptions: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
// reset existing elements
|
// reset existing elements
|
||||||
self.SelectEl().find('option').remove();
|
self.getSelectEl().find('option').remove();
|
||||||
|
|
||||||
// add default option
|
// add default option
|
||||||
// TODO i18n
|
// TODO i18n
|
||||||
jQuery('<option value="0">Add Criteria</option>').appendTo(self.SelectEl());
|
jQuery('<option value="0">Add Criteria</option>').appendTo(self.getSelectEl());
|
||||||
|
|
||||||
// populate dropdown values from existing fields
|
// populate dropdown values from existing fields
|
||||||
this.find('.field').each(function() {
|
this.find('.field').each(function() {
|
||||||
$('<option />').appendTo(self.SelectEl())
|
$('<option />').appendTo(self.getSelectEl())
|
||||||
.val(this.id)
|
.val(this.id)
|
||||||
.text($(this).find('label').text());
|
.text($(this).find('label').text());
|
||||||
});
|
});
|
||||||
@ -76,7 +71,7 @@
|
|||||||
/**
|
/**
|
||||||
* Filter tree based on selected criteria.
|
* Filter tree based on selected criteria.
|
||||||
*/
|
*/
|
||||||
_submitForm: function(e) {
|
onsubmit: function(e) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var data = [];
|
var data = [];
|
||||||
|
|
||||||
@ -103,7 +98,7 @@
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
_resetForm: function(e) {
|
onreset: function(e) {
|
||||||
this.find('.field').clearFields().not(':first').hide();
|
this.find('.field').clearFields().not(':first').hide();
|
||||||
|
|
||||||
// Reset URL to default
|
// Reset URL to default
|
||||||
@ -150,7 +145,6 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -158,16 +152,12 @@
|
|||||||
* which creates a new page through #Form_EditForm and adds a new tree node.
|
* which creates a new page through #Form_EditForm and adds a new tree node.
|
||||||
* @name ss.reports_holder
|
* @name ss.reports_holder
|
||||||
*/
|
*/
|
||||||
$('#Form_ReportForm').concrete(function($) {
|
$('#Form_ReportForm').concrete(/** @lends ss.reports_holder */{
|
||||||
return/** @lends ss.reports_holder */{
|
|
||||||
onmatch: function() {
|
onmatch: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this.bind('submit', function(e) {
|
|
||||||
return self._submit(e);
|
|
||||||
});
|
|
||||||
|
|
||||||
// integrate with sitetree selection changes
|
// integrate with sitetree selection changes
|
||||||
|
// TODO Only trigger when report is visible
|
||||||
jQuery('#sitetree').bind('selectionchanged', function(e, data) {
|
jQuery('#sitetree').bind('selectionchanged', function(e, data) {
|
||||||
self.find(':input[name=ID]').val(data.node.getIdx());
|
self.find(':input[name=ID]').val(data.node.getIdx());
|
||||||
self.trigger('submit');
|
self.trigger('submit');
|
||||||
@ -188,9 +178,11 @@
|
|||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this._super();
|
||||||
},
|
},
|
||||||
|
|
||||||
_submit: function(e) {
|
onsubmit: function(e) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
// dont process if no report is selected
|
// dont process if no report is selected
|
||||||
@ -215,7 +207,6 @@
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -223,20 +214,19 @@
|
|||||||
* @name ss.Form_VersionsForm
|
* @name ss.Form_VersionsForm
|
||||||
* @requires ss.i18n
|
* @requires ss.i18n
|
||||||
*/
|
*/
|
||||||
$('#Form_VersionsForm').concrete(function($) {
|
$('#Form_VersionsForm').concrete(/** @lends ss.Form_VersionsForm */{
|
||||||
return/** @lends ss.Form_VersionsForm */{
|
|
||||||
onmatch: function() {
|
onmatch: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this.bind('submit', function(e) {
|
|
||||||
return self._submit(e);
|
|
||||||
});
|
|
||||||
|
|
||||||
// set button to be available in form submit event later on
|
// set button to be available in form submit event later on
|
||||||
this.find(':submit').bind('click', function(e) {
|
this.find(':submit').bind('click', function(e) {
|
||||||
self.data('_clickedButton', this);
|
self.data('_clickedButton', this);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.bind('submit', function(e) {
|
||||||
|
return self._submit();
|
||||||
|
});
|
||||||
|
|
||||||
// integrate with sitetree selection changes
|
// integrate with sitetree selection changes
|
||||||
jQuery('#sitetree').bind('selectionchanged', function(e, data) {
|
jQuery('#sitetree').bind('selectionchanged', function(e, data) {
|
||||||
self.find(':input[name=ID]').val(data.node.getIdx());
|
self.find(':input[name=ID]').val(data.node.getIdx());
|
||||||
@ -291,17 +281,19 @@
|
|||||||
|
|
||||||
// overloaded submission: refresh the right form instead
|
// overloaded submission: refresh the right form instead
|
||||||
self.data('_clickedButton', this);
|
self.data('_clickedButton', this);
|
||||||
self._submit(e, true);
|
self._submit(true);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
})
|
});
|
||||||
|
|
||||||
|
this._super();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {boolean} loadEditForm Determines if responses should show in current panel,
|
* @param {boolean} loadEditForm Determines if responses should show in current panel,
|
||||||
* or in the edit form (in the case of 'compare versions').
|
* or in the edit form (in the case of 'compare versions').
|
||||||
*/
|
*/
|
||||||
_submit: function(e, loadEditForm) {
|
_submit: function(loadEditForm) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
// Don't submit with empty ID
|
// Don't submit with empty ID
|
||||||
@ -335,9 +327,8 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
});
|
});
|
||||||
})(jQuery);
|
})(jQuery);
|
@ -1,4 +1,5 @@
|
|||||||
(function($) {
|
(function($) {
|
||||||
|
$.concrete('ss', function($){
|
||||||
/**
|
/**
|
||||||
* @class Simple form with a page type dropdown
|
* @class Simple form with a page type dropdown
|
||||||
* which creates a new page through #Form_EditForm and adds a new tree node.
|
* which creates a new page through #Form_EditForm and adds a new tree node.
|
||||||
@ -6,8 +7,7 @@
|
|||||||
* @requires ss.i18n
|
* @requires ss.i18n
|
||||||
* @requires ss.Form_EditForm
|
* @requires ss.Form_EditForm
|
||||||
*/
|
*/
|
||||||
$('#Form_AddForm').concrete(function($) {
|
$('#Form_AddForm').concrete(/** @lends ss.Form_AddForm */{
|
||||||
return/** @lends ss.Form_AddForm */{
|
|
||||||
/**
|
/**
|
||||||
* @type DOMElement
|
* @type DOMElement
|
||||||
*/
|
*/
|
||||||
@ -16,15 +16,11 @@
|
|||||||
/**
|
/**
|
||||||
* @type Array Internal counter to create unique page identifiers prior to ajax saving
|
* @type Array Internal counter to create unique page identifiers prior to ajax saving
|
||||||
*/
|
*/
|
||||||
_NewPages: [],
|
NewPages: [],
|
||||||
|
|
||||||
onmatch: function() {
|
onmatch: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this.bind('submit', function(e) {
|
|
||||||
return self._submit(e);
|
|
||||||
});
|
|
||||||
|
|
||||||
Observable.applyTo(this[0]);
|
Observable.applyTo(this[0]);
|
||||||
|
|
||||||
var tree = jQuery('#sitetree')[0];
|
var tree = jQuery('#sitetree')[0];
|
||||||
@ -32,11 +28,13 @@
|
|||||||
jQuery(tree).bind('selectionchanged', function(e, data) {self.treeSelectionChanged(e, data);});
|
jQuery(tree).bind('selectionchanged', function(e, data) {self.treeSelectionChanged(e, data);});
|
||||||
|
|
||||||
this.find(':input[name=PageType]').bind('change', this.typeDropdownChanged);
|
this.find(':input[name=PageType]').bind('change', this.typeDropdownChanged);
|
||||||
|
|
||||||
|
this._super();
|
||||||
},
|
},
|
||||||
|
|
||||||
_submit: function(e) {
|
onsubmit: function(e) {
|
||||||
var newPages = this._NewPages();
|
var newPages = this.getNewPages();
|
||||||
var tree = this.Tree();
|
var tree = this.getTree();
|
||||||
var parentID = (tree.firstSelected()) ? tree.getIdxOf(tree.firstSelected()) : 0;
|
var parentID = (tree.firstSelected()) ? tree.getIdxOf(tree.firstSelected()) : 0;
|
||||||
|
|
||||||
// TODO: Remove 'new-' code http://open.silverstripe.com/ticket/875
|
// TODO: Remove 'new-' code http://open.silverstripe.com/ticket/875
|
||||||
@ -68,7 +66,7 @@
|
|||||||
{type: 'POST', data: data}
|
{type: 'POST', data: data}
|
||||||
);
|
);
|
||||||
|
|
||||||
this.set_NewPages(newPages);
|
this.setNewPages(newPages);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
@ -80,12 +78,12 @@
|
|||||||
this.find(':input[name=PageType]').val(selectedNode.hints.defaultChild);
|
this.find(':input[name=PageType]').val(selectedNode.hints.defaultChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
var parentID = this.Tree().getIdxOf(selectedNode);
|
var parentID = this.getTree().getIdxOf(selectedNode);
|
||||||
this.find(':input[name=ParentID]').val(parentID ? parentID : 0);
|
this.find(':input[name=ParentID]').val(parentID ? parentID : 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
typeDropdownChanged : function() {
|
typeDropdownChanged : function() {
|
||||||
var tree = this.Tree();
|
var tree = this.getTree();
|
||||||
|
|
||||||
// Don't do anything if we're already on an appropriate node
|
// Don't do anything if we're already on an appropriate node
|
||||||
var sel = tree.firstSelected();
|
var sel = tree.firstSelected();
|
||||||
@ -102,6 +100,6 @@
|
|||||||
if(newNode) tree.changeCurrentTo(newNode);
|
if(newNode) tree.changeCurrentTo(newNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
});
|
});
|
||||||
}(jQuery));
|
}(jQuery));
|
@ -1,4 +1,5 @@
|
|||||||
(function($) {
|
(function($) {
|
||||||
|
$.concrete('ss', function($){
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class Batch actions which take a bunch of selected pages,
|
* @class Batch actions which take a bunch of selected pages,
|
||||||
@ -11,8 +12,7 @@
|
|||||||
* - register: Called before an action is added.
|
* - register: Called before an action is added.
|
||||||
* - unregister: Called before an action is removed.
|
* - unregister: Called before an action is removed.
|
||||||
*/
|
*/
|
||||||
$('#Form_BatchActionsForm').concrete('ss', function($){
|
$('#Form_BatchActionsForm').concrete(/** @lends ss.Form_BatchActionsForm */{
|
||||||
return/** @lends ss.Form_BatchActionsForm */{
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {DOMElement}
|
* @type {DOMElement}
|
||||||
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
this.setTree($('#sitetree')[0]);
|
this.setTree($('#sitetree')[0]);
|
||||||
|
|
||||||
$(this.Tree()).bind('selectionchanged', function(e, data) {
|
$(this.getTree()).bind('selectionchanged', function(e, data) {
|
||||||
self._treeSelectionChanged(data.node);
|
self._treeSelectionChanged(data.node);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -42,14 +42,14 @@
|
|||||||
// if the panel is visible (meaning about to be closed),
|
// if the panel is visible (meaning about to be closed),
|
||||||
// disable tree selection and reset any values. Otherwise enable it.
|
// disable tree selection and reset any values. Otherwise enable it.
|
||||||
if($(ui.panel).is(':visible')) {
|
if($(ui.panel).is(':visible')) {
|
||||||
$(self.Tree()).removeClass('multiselect');
|
$(self.getTree()).removeClass('multiselect');
|
||||||
} else {
|
} else {
|
||||||
self._multiselectTransform();
|
self._multiselectTransform();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.bind('submit', function(e) {return self._submit(e);});
|
this._super();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,8 +58,7 @@
|
|||||||
*/
|
*/
|
||||||
register: function(type, callback) {
|
register: function(type, callback) {
|
||||||
this.trigger('register', {type: type, callback: callback});
|
this.trigger('register', {type: type, callback: callback});
|
||||||
|
var actions = this.getActions();
|
||||||
var actions = this.Actions();
|
|
||||||
actions[type] = callback;
|
actions[type] = callback;
|
||||||
this.setActions(actions);
|
this.setActions(actions);
|
||||||
},
|
},
|
||||||
@ -72,7 +71,7 @@
|
|||||||
unregister: function(type) {
|
unregister: function(type) {
|
||||||
this.trigger('unregister', {type: type});
|
this.trigger('unregister', {type: type});
|
||||||
|
|
||||||
var actions = this.Actions();
|
var actions = this.getActions();
|
||||||
if(actions[type]) delete actions[type];
|
if(actions[type]) delete actions[type];
|
||||||
this.setActions(actions);
|
this.setActions(actions);
|
||||||
},
|
},
|
||||||
@ -87,9 +86,9 @@
|
|||||||
return $('#TreeActions-batchactions').is(':visible');
|
return $('#TreeActions-batchactions').is(':visible');
|
||||||
},
|
},
|
||||||
|
|
||||||
_submit: function(e) {
|
onsubmit: function(e) {
|
||||||
var ids = [];
|
var ids = [];
|
||||||
var tree = this.Tree();
|
var tree = this.getTree();
|
||||||
// find all explicitly selected IDs
|
// find all explicitly selected IDs
|
||||||
$(tree).find('li.selected').each(function() {
|
$(tree).find('li.selected').each(function() {
|
||||||
ids.push(tree.getIdxOf(this));
|
ids.push(tree.getIdxOf(this));
|
||||||
@ -107,13 +106,11 @@
|
|||||||
|
|
||||||
// apply callback, which might modify the IDs
|
// apply callback, which might modify the IDs
|
||||||
var type = this.find(':input[name=Action]').val();
|
var type = this.find(':input[name=Action]').val();
|
||||||
if(this.Actions()[type]) ids = this.Actions()[type].apply(this, [ids]);
|
if(this.getActions()[type]) ids = this.getActions()[type].apply(this, [ids]);
|
||||||
|
|
||||||
// if no IDs are selected, stop here. This is an implict way for the
|
// if no IDs are selected, stop here. This is an implict way for the
|
||||||
// callback to cancel the actions
|
// callback to cancel the actions
|
||||||
if(!ids || !ids.length) {
|
if(!ids || !ids.length) return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// write IDs to the hidden field
|
// write IDs to the hidden field
|
||||||
this.find(':input[name=csvIDs]').val(ids.join(','));
|
this.find(':input[name=csvIDs]').val(ids.join(','));
|
||||||
@ -181,10 +178,10 @@
|
|||||||
*/
|
*/
|
||||||
_multiselectTransform : function() {
|
_multiselectTransform : function() {
|
||||||
// make tree selectable
|
// make tree selectable
|
||||||
jQuery(this.Tree()).addClass('multiselect');
|
jQuery(this.getTree()).addClass('multiselect');
|
||||||
|
|
||||||
// auto-select the current node
|
// auto-select the current node
|
||||||
var node = this.Tree().firstSelected();
|
var node = this.getTree().firstSelected();
|
||||||
if(node){
|
if(node){
|
||||||
node.removeNodeClass('current');
|
node.removeNodeClass('current');
|
||||||
node.addNodeClass('selected');
|
node.addNodeClass('selected');
|
||||||
@ -226,7 +223,7 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
(function($) {
|
(function($) {
|
||||||
|
$.concrete('ss', function($){
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class Base edit form, provides ajaxified saving
|
* @class Base edit form, provides ajaxified saving
|
||||||
@ -13,9 +14,7 @@
|
|||||||
* - removeform: A form is about to be removed from the DOM
|
* - removeform: A form is about to be removed from the DOM
|
||||||
* - load: Form is about to be loaded through ajax
|
* - load: Form is about to be loaded through ajax
|
||||||
*/
|
*/
|
||||||
$('#Form_EditForm').concrete('ss',function($){
|
$('#Form_EditForm').concrete(/** @lends ss.Form_EditForm */{
|
||||||
return/** @lends ss.Form_EditForm */{
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type String HTML text to show when no form content is chosen.
|
* @type String HTML text to show when no form content is chosen.
|
||||||
* Will show inside the <form> tag.
|
* Will show inside the <form> tag.
|
||||||
@ -32,10 +31,6 @@
|
|||||||
|
|
||||||
this._setupChangeTracker();
|
this._setupChangeTracker();
|
||||||
|
|
||||||
this.bind('submit', function(e) {
|
|
||||||
return self._submit(e);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Can't bind this through jQuery
|
// Can't bind this through jQuery
|
||||||
window.onbeforeunload = function(e) {return self._checkChangeTracker(false);};
|
window.onbeforeunload = function(e) {return self._checkChangeTracker(false);};
|
||||||
|
|
||||||
@ -45,7 +40,7 @@
|
|||||||
_setupChangeTracker: function() {
|
_setupChangeTracker: function() {
|
||||||
// Don't bind any events here, as we dont replace the
|
// Don't bind any events here, as we dont replace the
|
||||||
// full <form> tag by any ajax updates they won't automatically reapply
|
// full <form> tag by any ajax updates they won't automatically reapply
|
||||||
this.changetracker(this.ChangeTrackerOptions());
|
this.changetracker(this.getChangeTrackerOptions());
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -79,8 +74,9 @@
|
|||||||
*
|
*
|
||||||
* @param {Event} e
|
* @param {Event} e
|
||||||
*/
|
*/
|
||||||
_submit: function(e) {
|
onsubmit: function(e) {
|
||||||
this.ajaxSubmit();
|
this.ajaxSubmit();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -201,15 +197,11 @@
|
|||||||
* Falls back to the default RemoveText() option (Optional)
|
* Falls back to the default RemoveText() option (Optional)
|
||||||
*/
|
*/
|
||||||
removeForm: function(placeholderHtml) {
|
removeForm: function(placeholderHtml) {
|
||||||
if(!placeholderHtml) placeholderHtml = this.PlaceholderHtml();
|
if(!placeholderHtml) placeholderHtml = this.getPlaceholderHtml();
|
||||||
|
|
||||||
// Alert when unsaved changes are present
|
// Alert when unsaved changes are present
|
||||||
if(this._checkChangeTracker(true) == false) return false;
|
if(this._checkChangeTracker(true) == false) return;
|
||||||
|
|
||||||
this.trigger('removeform');
|
this.trigger('removeform');
|
||||||
|
|
||||||
this.html(placeholderHtml);
|
this.html(placeholderHtml);
|
||||||
|
|
||||||
// TODO This should be using the plugin API
|
// TODO This should be using the plugin API
|
||||||
this.removeClass('changed');
|
this.removeClass('changed');
|
||||||
},
|
},
|
||||||
@ -294,7 +286,6 @@
|
|||||||
statusMessage(_statusMessage, (xmlhttp.status >= 400) ? 'bad' : 'good');
|
statusMessage(_statusMessage, (xmlhttp.status >= 400) ? 'bad' : 'good');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -303,36 +294,28 @@
|
|||||||
* clicked button from a form.onsubmit event.
|
* clicked button from a form.onsubmit event.
|
||||||
* @name ss.Form_EditForm.Actions.submit
|
* @name ss.Form_EditForm.Actions.submit
|
||||||
*/
|
*/
|
||||||
$('#Form_EditForm .Actions :submit').concrete('ss', function($){
|
$('#Form_EditForm .Actions :submit').concrete(/** @lends ss.Form_EditForm.Actions.submit */{
|
||||||
return/** @lends ss.Form_EditForm.Actions.submit */{
|
onclick: function(e) {
|
||||||
onmatch: function() {
|
|
||||||
this.bind('click', this._onclick);
|
|
||||||
|
|
||||||
this._super();
|
|
||||||
},
|
|
||||||
_onclick: function() {
|
|
||||||
jQuery('#Form_EditForm').concrete('ss').ajaxSubmit(this);
|
jQuery('#Form_EditForm').concrete('ss').ajaxSubmit(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class Add tinymce to HtmlEditorFields within the CMS.
|
* @class Add tinymce to HtmlEditorFields within the CMS.
|
||||||
* @name ss.Form_EditForm.textarea.htmleditor
|
* @name ss.Form_EditForm.textarea.htmleditor
|
||||||
*/
|
*/
|
||||||
$('#Form_EditForm textarea.htmleditor').concrete('ss', function($){
|
$('#Form_EditForm textarea.htmleditor').concrete(/** @lends ss.Form_EditForm.Actions.submit */{
|
||||||
return/** @lends ss.Form_EditForm.Actions.submit */{
|
|
||||||
onmatch : function() {
|
onmatch : function() {
|
||||||
tinyMCE.execCommand("mceAddControl", true, this.attr('id'));
|
tinyMCE.execCommand("mceAddControl", true, this.attr('id'));
|
||||||
this.isChanged = function() {
|
this.isChanged = function() {
|
||||||
return tinyMCE.getInstanceById(this.attr('id')).isDirty();
|
return tinyMCE.getInstanceById(this.attr('id')).isDirty();
|
||||||
}
|
};
|
||||||
this.resetChanged = function() {
|
this.resetChanged = function() {
|
||||||
var inst = tinyMCE.getInstanceById(this.attr('id'));
|
var inst = tinyMCE.getInstanceById(this.attr('id'));
|
||||||
if (inst) inst.startContent = tinymce.trim(inst.getContent({format : 'raw', no_events : 1}));
|
if (inst) inst.startContent = tinymce.trim(inst.getContent({format : 'raw', no_events : 1}));
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}(jQuery));
|
}(jQuery));
|
@ -5,6 +5,7 @@
|
|||||||
var ss_MainLayout;
|
var ss_MainLayout;
|
||||||
|
|
||||||
(function($) {
|
(function($) {
|
||||||
|
$.concrete('ss', function($){
|
||||||
|
|
||||||
// setup jquery.concrete
|
// setup jquery.concrete
|
||||||
$.concrete.warningLevel = $.concrete.WARN_LEVEL_BESTPRACTISE;
|
$.concrete.warningLevel = $.concrete.WARN_LEVEL_BESTPRACTISE;
|
||||||
@ -28,9 +29,7 @@ var ss_MainLayout;
|
|||||||
* panel and an edit form.
|
* panel and an edit form.
|
||||||
* @name ss.LeftAndMain
|
* @name ss.LeftAndMain
|
||||||
*/
|
*/
|
||||||
$('.LeftAndMain').concrete('ss', function($){
|
$('.LeftAndMain').concrete(/** @lends ss.EditMemberProfile */{
|
||||||
return/** @lends ss.EditMemberProfile */ {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reference to jQuery.layout element
|
* Reference to jQuery.layout element
|
||||||
* @type Object
|
* @type Object
|
||||||
@ -174,12 +173,13 @@ var ss_MainLayout;
|
|||||||
global: false,
|
global: false,
|
||||||
complete: onSessionLost
|
complete: onSessionLost
|
||||||
});
|
});
|
||||||
}, this.PingIntervalSeconds() * 1000);
|
}, this.getPingIntervalSeconds() * 1000);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resize elements in center panel
|
* Resize elements in center panel
|
||||||
* to fit the boundary box provided by the layout manager
|
* to fit the boundary box provided by the layout manager.
|
||||||
|
* TODO Replace with automated less ugly parent/sibling traversal
|
||||||
*/
|
*/
|
||||||
_resizeChildren: function() {
|
_resizeChildren: function() {
|
||||||
$("#treepanes", this).accordion("resize");
|
$("#treepanes", this).accordion("resize");
|
||||||
@ -196,7 +196,6 @@ var ss_MainLayout;
|
|||||||
$('#Form_EditForm fieldset > .ss-tabset > .tab > .ss-tabset', this).fitHeightToParent();
|
$('#Form_EditForm fieldset > .ss-tabset > .tab > .ss-tabset', this).fitHeightToParent();
|
||||||
$('#Form_EditForm fieldset > .ss-tabset > .tab > .ss-tabset > .tab', this).fitHeightToParent();
|
$('#Form_EditForm fieldset > .ss-tabset > .tab > .ss-tabset > .tab', this).fitHeightToParent();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -206,8 +205,7 @@ var ss_MainLayout;
|
|||||||
*
|
*
|
||||||
* @name ss.LeftAndMain.Buttons
|
* @name ss.LeftAndMain.Buttons
|
||||||
*/
|
*/
|
||||||
$('.LeftAndMain :submit, .LeftAndMain button, .LeftAndMain :reset').concrete('ss', function($){
|
$('.LeftAndMain :submit, .LeftAndMain button, .LeftAndMain :reset').concrete(/** @lends ss.LeftAndMain.Buttons */{
|
||||||
return/** @lends ss.LeftAndMain.Buttons */{
|
|
||||||
onmatch: function() {
|
onmatch: function() {
|
||||||
this.addClass(
|
this.addClass(
|
||||||
'ui-state-default ' +
|
'ui-state-default ' +
|
||||||
@ -238,16 +236,13 @@ var ss_MainLayout;
|
|||||||
|
|
||||||
this._super();
|
this._super();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class Container for tree actions like "create", "search", etc.
|
* @class Container for tree actions like "create", "search", etc.
|
||||||
* @name ss.TreeActions
|
* @name ss.TreeActions
|
||||||
*/
|
*/
|
||||||
$('#TreeActions').concrete('ss', function($){
|
$('#TreeActions').concrete(/** @lends ss.TreeActions */{
|
||||||
return/** @lends ss.TreeActions */{
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup "create", "search", "batch actions" layers above tree.
|
* Setup "create", "search", "batch actions" layers above tree.
|
||||||
* All tab contents are closed by default.
|
* All tab contents are closed by default.
|
||||||
@ -259,7 +254,6 @@ var ss_MainLayout;
|
|||||||
cookie: { expires: 30, path: '/', name: 'ui-tabs-TreeActions' }
|
cookie: { expires: 30, path: '/', name: 'ui-tabs-TreeActions' }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -267,9 +261,7 @@ var ss_MainLayout;
|
|||||||
* through a modal dialog.
|
* through a modal dialog.
|
||||||
* @name ss.EditMemberProfile
|
* @name ss.EditMemberProfile
|
||||||
*/
|
*/
|
||||||
$('a#EditMemberProfile').concrete('ss', function($){
|
$('a#EditMemberProfile').concrete(/** @lends ss.EditMemberProfile */{
|
||||||
return/** @lends ss.EditMemberProfile */{
|
|
||||||
|
|
||||||
onmatch: function() {
|
onmatch: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
@ -350,7 +342,6 @@ var ss_MainLayout;
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -360,10 +351,7 @@ var ss_MainLayout;
|
|||||||
* @name ss.switchViewLinks
|
* @name ss.switchViewLinks
|
||||||
* @requires jquery.metadata
|
* @requires jquery.metadata
|
||||||
*/
|
*/
|
||||||
$('#switchView a').concrete('ss', function($){
|
$('#switchView a').concrete(/** @lends ss.switchViewLinks */{
|
||||||
|
|
||||||
return/** @lends ss.switchViewLinks */{
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type DOMElement
|
* @type DOMElement
|
||||||
*/
|
*/
|
||||||
@ -383,9 +371,9 @@ var ss_MainLayout;
|
|||||||
*/
|
*/
|
||||||
refresh: function() {
|
refresh: function() {
|
||||||
// TODO Compatible with nested urls?
|
// TODO Compatible with nested urls?
|
||||||
var urlSegment = this.Form().find(':input[name=URLSegment]').val();
|
var urlSegment = this.getForm().find(':input[name=URLSegment]').val();
|
||||||
if(urlSegment) {
|
if(urlSegment) {
|
||||||
var locale = this.Form().find(':input[name=Locale]').val();
|
var locale = this.getForm().find(':input[name=Locale]').val();
|
||||||
var url = urlSegment;
|
var url = urlSegment;
|
||||||
if(this.metadata().params) url += '?' + this.metadata().params;
|
if(this.metadata().params) url += '?' + this.metadata().params;
|
||||||
if(locale) url += ((url.indexOf('?') > 0) ? '&' : '?') + "locale=" + locale;
|
if(locale) url += ((url.indexOf('?') > 0) ? '&' : '?') + "locale=" + locale;
|
||||||
@ -401,9 +389,8 @@ var ss_MainLayout;
|
|||||||
window.open($(e.target).attr('href'));
|
window.open($(e.target).attr('href'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}(jQuery));
|
}(jQuery));
|
||||||
|
|
||||||
// Backwards compatibility
|
// Backwards compatibility
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
(function($) {
|
(function($) {
|
||||||
|
$.concrete('ss', function($){
|
||||||
/**
|
/**
|
||||||
* A simple ajax browser history implementation tailored towards
|
* A simple ajax browser history implementation tailored towards
|
||||||
* navigating through search results and different forms loaded into
|
* navigating through search results and different forms loaded into
|
||||||
@ -20,11 +20,8 @@
|
|||||||
*
|
*
|
||||||
* @name ss.ModelAdmin
|
* @name ss.ModelAdmin
|
||||||
*/
|
*/
|
||||||
$('.ModelAdmin').concrete('ss', function($){
|
$('.ModelAdmin').concrete(/** @lends ss.ModelAdmin */ {
|
||||||
return/** @lends ss.ModelAdmin */ {
|
|
||||||
|
|
||||||
History: [],
|
History: [],
|
||||||
|
|
||||||
Future: [],
|
Future: [],
|
||||||
|
|
||||||
onmatch: function() {
|
onmatch: function() {
|
||||||
@ -52,8 +49,8 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
redraw: function() {
|
redraw: function() {
|
||||||
this.find('.historyNav .forward').toggle(Boolean(this.Future().length > 0));
|
this.find('.historyNav .forward').toggle(Boolean(this.getFuture().length > 0));
|
||||||
this.find('.historyNav .back').toggle(Boolean(this.History().length > 1));
|
this.find('.historyNav .back').toggle(Boolean(this.getHistory().length > 1));
|
||||||
},
|
},
|
||||||
|
|
||||||
startHistory: function(url, data) {
|
startHistory: function(url, data) {
|
||||||
@ -74,10 +71,8 @@
|
|||||||
if(url.indexOf('?') == -1) url += '?' + $.param(data);
|
if(url.indexOf('?') == -1) url += '?' + $.param(data);
|
||||||
else url += '&' + $.param(data);
|
else url += '&' + $.param(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add to history
|
// Add to history
|
||||||
this.History().push(url);
|
this.getHistory().push(url);
|
||||||
|
|
||||||
// Reset future
|
// Reset future
|
||||||
this.setFuture([]);
|
this.setFuture([]);
|
||||||
|
|
||||||
@ -85,72 +80,67 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
goBack: function() {
|
goBack: function() {
|
||||||
if(this.History() && this.History().length) {
|
if(this.getHistory() && this.getHistory().length) {
|
||||||
if(this.Future() == null) this.setFuture([]);
|
if(this.getFuture() == null) this.setFuture([]);
|
||||||
|
|
||||||
var currentPage = this.History().pop();
|
var currentPage = this.getHistory().pop();
|
||||||
var previousPage = this.History()[this.History().length-1];
|
var previousPage = this.getHistory()[this.getHistory().length-1];
|
||||||
|
|
||||||
this.Future().push(currentPage);
|
this.getFuture().push(currentPage);
|
||||||
|
|
||||||
this.trigger('historyGoBack', {url:previousPage});
|
this.trigger('historyGoBack', {url:previousPage});
|
||||||
|
|
||||||
// load new location
|
// load new location
|
||||||
$('#Form_EditForm').concrete('ss').loadForm(previousPage);
|
$('#Form_EditForm').loadForm(previousPage);
|
||||||
|
|
||||||
this.redraw();
|
this.redraw();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
goForward: function() {
|
goForward: function() {
|
||||||
if(this.Future() && this.Future().length) {
|
if(this.getFuture() && this.getFuture().length) {
|
||||||
if(this.Future() == null) this.setFuture([]);
|
if(this.getFuture() == null) this.setFuture([]);
|
||||||
|
|
||||||
var nextPage = this.Future().pop();
|
var nextPage = this.getFuture().pop();
|
||||||
|
|
||||||
this.History().push(nextPage);
|
this.getHistory().push(nextPage);
|
||||||
|
|
||||||
this.trigger('historyGoForward', {url:nextPage});
|
this.trigger('historyGoForward', {url:nextPage});
|
||||||
|
|
||||||
// load new location
|
// load new location
|
||||||
$('#Form_EditForm').concrete('ss').loadForm(nextPage);
|
$('#Form_EditForm').loadForm(nextPage);
|
||||||
|
|
||||||
this.redraw();
|
this.redraw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A search action will cause the history to be reset.
|
* A search action will cause the history to be reset.
|
||||||
*/
|
*/
|
||||||
$('#SearchForm_holder form').concrete('ss', function($) {
|
$('#SearchForm_holder form').concrete({
|
||||||
return{
|
|
||||||
onmatch: function() {
|
onmatch: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.bind('beforeSubmit', function(e) {
|
this.bind('beforeSubmit', function(e) {
|
||||||
$('.ModelAdmin').concrete('ss').startHistory(
|
$('.ModelAdmin').startHistory(
|
||||||
self.attr('action'),
|
self.attr('action'),
|
||||||
self.serializeArray()
|
self.serializeArray()
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this._super();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We have to apply this to the result table buttons instead of the
|
* We have to apply this to the result table buttons instead of the
|
||||||
* more generic form loading.
|
* more generic form loading.
|
||||||
*/
|
*/
|
||||||
$('form[name=Form_ResultsForm] tbody td a').concrete('ss', function($) {
|
$('form[name=Form_ResultsForm] tbody td a').concrete({
|
||||||
return{
|
onclick: function(e) {
|
||||||
onmatch: function() {
|
$('.ModelAdmin').addHistory(this.attr('href'));
|
||||||
var self = this;
|
|
||||||
this.bind('click', function(e) {
|
|
||||||
$('.ModelAdmin').addHistory(self.attr('href'));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
});
|
||||||
})(jQuery);
|
})(jQuery);
|
@ -9,6 +9,7 @@
|
|||||||
* @todo alias the $ function instead of literal jQuery
|
* @todo alias the $ function instead of literal jQuery
|
||||||
*/
|
*/
|
||||||
(function($) {
|
(function($) {
|
||||||
|
$.concrete('ss', function($){
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
// Search form
|
// Search form
|
||||||
@ -19,18 +20,21 @@
|
|||||||
*/
|
*/
|
||||||
$('#ModelClassSelector select').concrete({
|
$('#ModelClassSelector select').concrete({
|
||||||
onmatch: function() {
|
onmatch: function() {
|
||||||
var self = this;
|
|
||||||
// Set up an onchange function to show the applicable form and hide all others
|
|
||||||
this.bind('change', function(e) {
|
|
||||||
self.find('option').each(function() {
|
|
||||||
var $form = $('#'+$(this).val());
|
|
||||||
if(self.val() == $(this).val()) $form.show();
|
|
||||||
else $form.hide();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Initialise the form by calling this onchange event straight away
|
// Initialise the form by calling this onchange event straight away
|
||||||
this.change();
|
this.change();
|
||||||
|
|
||||||
|
this._super();
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up an onchange function to show the applicable form and hide all others
|
||||||
|
*/
|
||||||
|
onchange: function(e) {
|
||||||
|
this.find('option').each(function() {
|
||||||
|
var $form = $('#'+this.val());
|
||||||
|
if(this.val() == this.val()) $form.show();
|
||||||
|
else $form.hide();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
/**
|
/**
|
||||||
@ -41,28 +45,24 @@
|
|||||||
* Note: This is used for Form_CreateForm and all Form_SearchForm_* variations
|
* Note: This is used for Form_CreateForm and all Form_SearchForm_* variations
|
||||||
*/
|
*/
|
||||||
$('#SearchForm_holder form').concrete({
|
$('#SearchForm_holder form').concrete({
|
||||||
onmatch: function() {
|
onsubmit: function(e) {
|
||||||
var self = this;
|
|
||||||
|
|
||||||
this.bind('submit', function(e) {
|
|
||||||
// Import forms are processed without ajax
|
// Import forms are processed without ajax
|
||||||
if(self.is('#Form_ImportForm')) return true;
|
if(this.is('#Form_ImportForm')) return true;
|
||||||
|
|
||||||
self.trigger('beforeSubmit');
|
this.trigger('beforeSubmit');
|
||||||
|
|
||||||
var btn = $(self[0].clickedButton);
|
var btn = $(this[0].clickedButton);
|
||||||
btn.addClass('loading');
|
btn.addClass('loading');
|
||||||
|
|
||||||
$('#Form_EditForm').concrete('ss').loadForm(
|
$('#Form_EditForm').loadForm(
|
||||||
self.attr('action'),
|
this.attr('action'),
|
||||||
function() {
|
function() {
|
||||||
btn.removeClass('loading');
|
btn.removeClass('loading');
|
||||||
},
|
},
|
||||||
{data: self.serialize()}
|
{data: this.serialize()}
|
||||||
);
|
);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -97,14 +97,11 @@
|
|||||||
* Table record handler for search result record
|
* Table record handler for search result record
|
||||||
*/
|
*/
|
||||||
$('.resultsTable tbody td').concrete({
|
$('.resultsTable tbody td').concrete({
|
||||||
onmatch: function() {
|
onclick: function(e) {
|
||||||
// TODO Replace with concrete event handler
|
var firstLink = this.find('a[href]');
|
||||||
this.bind('click', function(e) {
|
|
||||||
var firstLink = $(this).find('a[href]');
|
|
||||||
if(!firstLink) return;
|
if(!firstLink) return;
|
||||||
$('#Form_EditForm').concrete('ss').loadForm(firstLink.attr('href'));
|
$('#Form_EditForm').loadForm(firstLink.attr('href'));
|
||||||
return false;
|
return false;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -112,20 +109,19 @@
|
|||||||
* Add object button
|
* Add object button
|
||||||
*/
|
*/
|
||||||
$('#Form_ManagedModelsSelect').concrete({
|
$('#Form_ManagedModelsSelect').concrete({
|
||||||
onmatch: function() {
|
onsubmit: function(e) {
|
||||||
this.bind('submit', function(){
|
|
||||||
className = $('select option:selected', this).val();
|
className = $('select option:selected', this).val();
|
||||||
requestPath = $(this).attr('action').replace('ManagedModelsSelect', className + '/add');
|
requestPath = this.attr('action').replace('ManagedModelsSelect', className + '/add');
|
||||||
var $button = $(':submit', this);
|
var $button = $(':submit', this);
|
||||||
$('#Form_EditForm').concrete('ss').loadForm(
|
$('#Form_EditForm').loadForm(
|
||||||
requestPath,
|
requestPath,
|
||||||
function() {
|
function() {
|
||||||
$button.removeClass('loading');
|
$button.removeClass('loading');
|
||||||
$button = null;
|
$button = null;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -133,14 +129,11 @@
|
|||||||
* RHS panel Delete button
|
* RHS panel Delete button
|
||||||
*/
|
*/
|
||||||
$('#Form_EditForm input[name=action_doDelete]').concrete({
|
$('#Form_EditForm input[name=action_doDelete]').concrete({
|
||||||
onmatch: function() {
|
onclick: function(e) {
|
||||||
this.bind('click', function() {
|
if(!confirm(ss.i18n._t('ModelAdmin.REALLYDELETE', 'Really delete?'))) {
|
||||||
var confirmed = confirm(ss.i18n._t('ModelAdmin.REALLYDELETE', 'Really delete?'));
|
this.removeClass('loading');
|
||||||
if(!confirmed) {
|
|
||||||
$(this).removeClass('loading');
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -154,7 +147,10 @@
|
|||||||
$('#' + $(this).attr('href').replace(/.*#/,'')).toggle();
|
$('#' + $(this).attr('href').replace(/.*#/,'')).toggle();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this._super();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
});
|
||||||
})(jQuery);
|
})(jQuery);
|
@ -1,15 +1,17 @@
|
|||||||
jQuery(function($) {
|
(function($) {
|
||||||
|
$.concrete('ss', function($){
|
||||||
/**
|
/**
|
||||||
* @class Tree panel.
|
* @class Tree panel.
|
||||||
* @name ss.sitetree
|
* @name ss.sitetree
|
||||||
*/
|
*/
|
||||||
$('#sitetree').concrete('ss', function($){
|
$('#sitetree').concrete(/** @lends ss.sitetree */{
|
||||||
return/** @lends ss.sitetree */{
|
|
||||||
onmatch: function() {
|
onmatch: function() {
|
||||||
// make sure current ID of loaded form is actually selected in tree
|
// make sure current ID of loaded form is actually selected in tree
|
||||||
var id = $('#Form_EditForm :input[name=ID]').val();
|
var id = $('#Form_EditForm :input[name=ID]').val();
|
||||||
if (id) this[0].setCurrentByIdx(id);
|
if (id) this[0].setCurrentByIdx(id);
|
||||||
|
|
||||||
|
this._super();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}(jQuery));
|
Loading…
Reference in New Issue
Block a user