mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +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($) {
|
||||
|
||||
/**
|
||||
* Delete selected folders through "batch actions" tab.
|
||||
*/
|
||||
$(function() {
|
||||
$(document).ready(function() {
|
||||
$('#Form_BatchActionsForm').concrete('ss').register(
|
||||
// TODO Hardcoding of base URL
|
||||
'admin/assets/batchactions/delete',
|
||||
@ -36,32 +35,26 @@ var _HANDLER_FORMS = {
|
||||
);
|
||||
});
|
||||
|
||||
$('#Form_SyncForm').concrete('ss', function($) {
|
||||
return {
|
||||
onmatch: function() {
|
||||
this.bind('submit', this._onsubmit);
|
||||
this._super();
|
||||
},
|
||||
_onsubmit: function(e) {
|
||||
$.concrete('ss', function($){
|
||||
$('#Form_SyncForm').concrete({
|
||||
onsubmit: function(e) {
|
||||
var button = jQuery(this).find(':submit:first');
|
||||
button.addClass('loading');
|
||||
$.get(
|
||||
jQuery(this).attr('action'),
|
||||
function() {
|
||||
button.removeClass('loading');
|
||||
|
||||
// reload current
|
||||
var currNode = $('#sitetree')[0].firstSelected();
|
||||
if(currNode) {
|
||||
var url = $(currNode).find('a').attr('href');
|
||||
$('#Form_EditForm').concrete('ss').loadForm(url);
|
||||
$('#Form_EditForm').loadForm(url);
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
}(jQuery));
|
@ -1,28 +1,23 @@
|
||||
(function($) {
|
||||
/**
|
||||
* Alert the user on change of page-type - this might have implications
|
||||
* on the available form fields etc.
|
||||
* @name ss.EditFormClassName
|
||||
*/
|
||||
$('#Form_EditForm :input[name=ClassName]').concrete('ss', function($){
|
||||
return/** @lends ss.EditFormClassName */{
|
||||
$.concrete('ss', function($){
|
||||
/**
|
||||
* Alert the user on change of page-type - this might have implications
|
||||
* on the available form fields etc.
|
||||
* @name ss.EditFormClassName
|
||||
*/
|
||||
$('#Form_EditForm :input[name=ClassName]').concrete(/** @lends ss.EditFormClassName */{
|
||||
onchange: function() {
|
||||
alert(ss.i18n._t('CMSMAIN.ALERTCLASSNAME'));
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* @class Input validation on the URLSegment field
|
||||
* @name ss.EditForm.URLSegment
|
||||
*/
|
||||
$('#Form_EditForm input[name=URLSegment]').concrete('ss', function($){
|
||||
return/** @lends ss.EditForm.URLSegment */{
|
||||
});
|
||||
|
||||
/**
|
||||
* @class Input validation on the URLSegment field
|
||||
* @name ss.EditForm.URLSegment
|
||||
*/
|
||||
$('#Form_EditForm input[name=URLSegment]').concrete(/** @lends ss.EditForm.URLSegment */{
|
||||
FilterRegex: /[^A-Za-z0-9-]+/,
|
||||
|
||||
ValidationMessage: ss.i18n._t('CMSMAIN.URLSEGMENTVALIDATION'),
|
||||
|
||||
MaxLength: 50,
|
||||
|
||||
onmatch : function() {
|
||||
@ -31,11 +26,13 @@
|
||||
// intercept change event, do our own writing
|
||||
this.bind('change', function(e) {
|
||||
if(!self.validate()) {
|
||||
jQuery.noticeAdd(self.ValidationMessage());
|
||||
jQuery.noticeAdd(self.getValidationMessage());
|
||||
}
|
||||
self.val(self.suggestValue(e.target.value));
|
||||
return false;
|
||||
});
|
||||
|
||||
this._super();
|
||||
},
|
||||
|
||||
/**
|
||||
@ -46,25 +43,22 @@
|
||||
*/
|
||||
suggestValue: function(val) {
|
||||
// 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() {
|
||||
return (
|
||||
this.val().length > this.MaxLength()
|
||||
|| this.val().match(this.FilterRegex())
|
||||
this.val().length > this.getMaxLength()
|
||||
|| this.val().match(this.getFilterRegex())
|
||||
);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* @class Input validation on the Title field
|
||||
* @name ss.EditForm.Title
|
||||
*/
|
||||
$('#Form_EditForm input[name=Title]').concrete('ss', function($){
|
||||
return/** @lends ss.EditForm.Title */{
|
||||
});
|
||||
|
||||
/**
|
||||
* @class Input validation on the Title field
|
||||
* @name ss.EditForm.Title
|
||||
*/
|
||||
$('#Form_EditForm input[name=Title]').concrete(/** @lends ss.EditForm.Title */{
|
||||
onmatch : function() {
|
||||
var self = this;
|
||||
|
||||
@ -73,6 +67,8 @@
|
||||
// TODO We should really user-confirm these changes
|
||||
self.parents('form').find('input[name=MetaTitle], input[name=MenuTitle]').val(self.val());
|
||||
});
|
||||
|
||||
this._super();
|
||||
},
|
||||
|
||||
updateURLSegment: function(field) {
|
||||
@ -97,22 +93,20 @@
|
||||
field.val(suggestion);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @class ParentID field combination - mostly toggling between
|
||||
* the two radiobuttons and setting the hidden "ParentID" field
|
||||
* @name ss.EditForm.parentTypeSelector
|
||||
*/
|
||||
$('#Form_EditForm .parentTypeSelector').concrete('ss', function($){
|
||||
return/** @lends ss.EditForm.parentTypeSelector */{
|
||||
/**
|
||||
* @class ParentID field combination - mostly toggling between
|
||||
* the two radiobuttons and setting the hidden "ParentID" field
|
||||
* @name ss.EditForm.parentTypeSelector
|
||||
*/
|
||||
$('#Form_EditForm .parentTypeSelector').concrete(/** @lends ss.EditForm.parentTypeSelector */{
|
||||
onmatch : function() {
|
||||
var self = this;
|
||||
|
||||
this.find(':input[name=ParentType]').bind('click', function(e) {self._toggleSelection(e);});
|
||||
|
||||
this._toggleSelection();
|
||||
|
||||
this._super();
|
||||
},
|
||||
|
||||
_toggleSelection: function(e) {
|
||||
@ -122,16 +116,14 @@
|
||||
// toggle tree dropdown based on selection
|
||||
this.find('#ParentID').toggle(selected != 'root');
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @class Toggle display of group dropdown in "access" tab,
|
||||
* based on selection of radiobuttons.
|
||||
* @name ss.Form_EditForm.Access
|
||||
*/
|
||||
$('#Form_EditForm #CanViewType, #Form_EditForm #CanEditType').concrete('ss', function($){
|
||||
return/** @lends ss.Form_EditForm.Access */{
|
||||
/**
|
||||
* @class Toggle display of group dropdown in "access" tab,
|
||||
* based on selection of radiobuttons.
|
||||
* @name ss.Form_EditForm.Access
|
||||
*/
|
||||
$('#Form_EditForm #CanViewType, #Form_EditForm #CanEditType').concrete(/** @lends ss.Form_EditForm.Access */{
|
||||
onmatch: function() {
|
||||
// TODO Decouple
|
||||
var dropdown;
|
||||
@ -145,17 +137,17 @@
|
||||
// initial state
|
||||
var currentVal = this.find('input[name=' + this.attr('id') + ']:checked').val();
|
||||
dropdown.toggle(currentVal == 'OnlyTheseUsers');
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* @class Email containing the link to the archived version of the page.
|
||||
* Visible on readonly older versions of a specific page at the moment.
|
||||
* @name ss.Form_EditForm_action_email
|
||||
*/
|
||||
$('#Form_EditForm .Actions #Form_EditForm_action_email').concrete('ss', function($){
|
||||
return/** @lends ss.Form_EditForm_action_email */{
|
||||
this._super();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @class Email containing the link to the archived version of the page.
|
||||
* Visible on readonly older versions of a specific page at the moment.
|
||||
* @name ss.Form_EditForm_action_email
|
||||
*/
|
||||
$('#Form_EditForm .Actions #Form_EditForm_action_email').concrete(/** @lends ss.Form_EditForm_action_email */{
|
||||
onclick: function(e) {
|
||||
window.open(
|
||||
'mailto:?subject='
|
||||
@ -167,16 +159,14 @@
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @class Open a printable representation of the form in a new window.
|
||||
* Used for readonly older versions of a specific page.
|
||||
* @name ss.Form_EditForm_action_print
|
||||
*/
|
||||
$('#Form_EditForm .Actions #Form_EditForm_action_print').concrete('ss', function($){
|
||||
return/** @lends ss.Form_EditForm_action_print */{
|
||||
/**
|
||||
* @class Open a printable representation of the form in a new window.
|
||||
* Used for readonly older versions of a specific page.
|
||||
* @name ss.Form_EditForm_action_print
|
||||
*/
|
||||
$('#Form_EditForm .Actions #Form_EditForm_action_print').concrete(/** @lends ss.Form_EditForm_action_print */{
|
||||
onclick: function(e) {
|
||||
var printURL = $(this[0].form).attr('action').replace(/\?.*$/,'')
|
||||
+ '/printable/'
|
||||
@ -187,19 +177,17 @@
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @class A "rollback" to a specific version needs user confirmation.
|
||||
* @name ss.Form_EditForm_action_rollback
|
||||
*/
|
||||
$('#Form_EditForm .Actions #Form_EditForm_action_rollback').concrete('ss', function($){
|
||||
return/** @lends ss.Form_EditForm_action_rollback */{
|
||||
/**
|
||||
* @class A "rollback" to a specific version needs user confirmation.
|
||||
* @name ss.Form_EditForm_action_rollback
|
||||
*/
|
||||
$('#Form_EditForm .Actions #Form_EditForm_action_rollback').concrete(/** @lends ss.Form_EditForm_action_rollback */{
|
||||
onclick: function(e) {
|
||||
// @todo i18n
|
||||
return confirm("Do you really want to copy the published content to the stage site?");
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
}(jQuery));
|
@ -1,11 +1,11 @@
|
||||
(function($) {
|
||||
$.concrete('ss', function($){
|
||||
|
||||
/**
|
||||
* @class Dropdown with languages above CMS tree, causing a redirect upon translation
|
||||
* @name ss.CMSMain.LangSelector
|
||||
*/
|
||||
$('.CMSMain #Form_LangForm').concrete('ss', function($){
|
||||
return/** @lends ss.CMSMain.LangSelector */{
|
||||
/**
|
||||
* @class Dropdown with languages above CMS tree, causing a redirect upon translation
|
||||
* @name ss.CMSMain.LangSelector
|
||||
*/
|
||||
$('.CMSMain #Form_LangForm').concrete(/** @lends ss.CMSMain.LangSelector */{
|
||||
onmatch: function() {
|
||||
var self = this;
|
||||
|
||||
@ -24,21 +24,21 @@
|
||||
document.location = url;
|
||||
return false;
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* Loads /admin/createtranslation, which will create the new record,
|
||||
* and redirect to an edit form.
|
||||
*
|
||||
* @class Dropdown in "Translation" tab in CMS forms, with button to
|
||||
* trigger translating the currently loaded record.
|
||||
* @name ss.CMSMain.createtranslation
|
||||
* @requires jquery.metadata
|
||||
*/
|
||||
$('.CMSMain .createTranslation').concrete('ss', function($){
|
||||
return/** @lends ss.CMSMain.createtranslation */{
|
||||
this._super();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Loads /admin/createtranslation, which will create the new record,
|
||||
* and redirect to an edit form.
|
||||
*
|
||||
* @class Dropdown in "Translation" tab in CMS forms, with button to
|
||||
* trigger translating the currently loaded record.
|
||||
* @name ss.CMSMain.createtranslation
|
||||
* @requires jquery.metadata
|
||||
*/
|
||||
$('.CMSMain .createTranslation').concrete(/** @lends ss.CMSMain.createtranslation */{
|
||||
onmatch: function() {
|
||||
var self = this;
|
||||
|
||||
@ -55,8 +55,9 @@
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
this._super();
|
||||
}
|
||||
});
|
||||
});
|
||||
}(jQuery));
|
@ -1,11 +1,11 @@
|
||||
(function($) {
|
||||
$.concrete('ss', function($){
|
||||
|
||||
/**
|
||||
* @class All forms in the right content panel should have closeable jQuery UI style titles.
|
||||
* @name ss.contentPanel.form
|
||||
*/
|
||||
$('#contentPanel form').concrete('ss', function($){
|
||||
return/** @lends ss.contentPanel.form */{
|
||||
/**
|
||||
* @class All forms in the right content panel should have closeable jQuery UI style titles.
|
||||
* @name ss.contentPanel.form
|
||||
*/
|
||||
$('#contentPanel form').concrete(/** @lends ss.contentPanel.form */{
|
||||
onmatch: function() {
|
||||
// Style as title bar
|
||||
this.find(':header:first').titlebar({
|
||||
@ -14,22 +14,20 @@
|
||||
// The close button should close the east panel of the layout
|
||||
this.find(':header:first .ui-dialog-titlebar-close').bind('click', function(e) {
|
||||
$('body.CMSMain').concrete('ss').MainLayout().close('east');
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
this._super();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* @class Control the site tree filter.
|
||||
* Toggles search form fields based on a dropdown selection,
|
||||
* similar to "Smart Search" criteria in iTunes.
|
||||
* @name ss.Form_SeachTreeForm
|
||||
*/
|
||||
$('#Form_SearchTreeForm').concrete('ss', function($) {
|
||||
return/** @lends ss.Form_SeachTreeForm */{
|
||||
});
|
||||
|
||||
/**
|
||||
* @class Control the site tree filter.
|
||||
* Toggles search form fields based on a dropdown selection,
|
||||
* similar to "Smart Search" criteria in iTunes.
|
||||
* @name ss.Form_SeachTreeForm
|
||||
*/
|
||||
$('#Form_SearchTreeForm').concrete(/** @lends ss.Form_SeachTreeForm */{
|
||||
/**
|
||||
* @type DOMElement
|
||||
*/
|
||||
@ -38,10 +36,6 @@
|
||||
onmatch: function() {
|
||||
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
|
||||
this.find('.field').not(':first').hide();
|
||||
|
||||
@ -53,21 +47,22 @@
|
||||
|
||||
this._setOptions();
|
||||
|
||||
this._super();
|
||||
},
|
||||
|
||||
_setOptions: function() {
|
||||
var self = this;
|
||||
|
||||
// reset existing elements
|
||||
self.SelectEl().find('option').remove();
|
||||
self.getSelectEl().find('option').remove();
|
||||
|
||||
// add default option
|
||||
// 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
|
||||
this.find('.field').each(function() {
|
||||
$('<option />').appendTo(self.SelectEl())
|
||||
$('<option />').appendTo(self.getSelectEl())
|
||||
.val(this.id)
|
||||
.text($(this).find('label').text());
|
||||
});
|
||||
@ -76,7 +71,7 @@
|
||||
/**
|
||||
* Filter tree based on selected criteria.
|
||||
*/
|
||||
_submitForm: function(e) {
|
||||
onsubmit: function(e) {
|
||||
var self = this;
|
||||
var data = [];
|
||||
|
||||
@ -103,7 +98,7 @@
|
||||
return false;
|
||||
},
|
||||
|
||||
_resetForm: function(e) {
|
||||
onreset: function(e) {
|
||||
this.find('.field').clearFields().not(':first').hide();
|
||||
|
||||
// Reset URL to default
|
||||
@ -150,24 +145,19 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @class Simple form with a page type dropdown
|
||||
* which creates a new page through #Form_EditForm and adds a new tree node.
|
||||
* @name ss.reports_holder
|
||||
*/
|
||||
$('#Form_ReportForm').concrete(function($) {
|
||||
return/** @lends ss.reports_holder */{
|
||||
/**
|
||||
* @class Simple form with a page type dropdown
|
||||
* which creates a new page through #Form_EditForm and adds a new tree node.
|
||||
* @name ss.reports_holder
|
||||
*/
|
||||
$('#Form_ReportForm').concrete(/** @lends ss.reports_holder */{
|
||||
onmatch: function() {
|
||||
var self = this;
|
||||
|
||||
this.bind('submit', function(e) {
|
||||
return self._submit(e);
|
||||
});
|
||||
|
||||
// integrate with sitetree selection changes
|
||||
// TODO Only trigger when report is visible
|
||||
jQuery('#sitetree').bind('selectionchanged', function(e, data) {
|
||||
self.find(':input[name=ID]').val(data.node.getIdx());
|
||||
self.trigger('submit');
|
||||
@ -188,9 +178,11 @@
|
||||
);
|
||||
return false;
|
||||
});
|
||||
|
||||
this._super();
|
||||
},
|
||||
|
||||
_submit: function(e) {
|
||||
onsubmit: function(e) {
|
||||
var self = this;
|
||||
|
||||
// dont process if no report is selected
|
||||
@ -215,28 +207,26 @@
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @class Simple form showing versions of a specific page.
|
||||
* @name ss.Form_VersionsForm
|
||||
* @requires ss.i18n
|
||||
*/
|
||||
$('#Form_VersionsForm').concrete(function($) {
|
||||
return/** @lends ss.Form_VersionsForm */{
|
||||
/**
|
||||
* @class Simple form showing versions of a specific page.
|
||||
* @name ss.Form_VersionsForm
|
||||
* @requires ss.i18n
|
||||
*/
|
||||
$('#Form_VersionsForm').concrete(/** @lends ss.Form_VersionsForm */{
|
||||
onmatch: function() {
|
||||
var self = this;
|
||||
|
||||
this.bind('submit', function(e) {
|
||||
return self._submit(e);
|
||||
});
|
||||
|
||||
// set button to be available in form submit event later on
|
||||
this.find(':submit').bind('click', function(e) {
|
||||
self.data('_clickedButton', this);
|
||||
});
|
||||
|
||||
this.bind('submit', function(e) {
|
||||
return self._submit();
|
||||
});
|
||||
|
||||
// integrate with sitetree selection changes
|
||||
jQuery('#sitetree').bind('selectionchanged', function(e, data) {
|
||||
self.find(':input[name=ID]').val(data.node.getIdx());
|
||||
@ -291,17 +281,19 @@
|
||||
|
||||
// overloaded submission: refresh the right form instead
|
||||
self.data('_clickedButton', this);
|
||||
self._submit(e, true);
|
||||
self._submit(true);
|
||||
|
||||
return false;
|
||||
})
|
||||
});
|
||||
|
||||
this._super();
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {boolean} loadEditForm Determines if responses should show in current panel,
|
||||
* or in the edit form (in the case of 'compare versions').
|
||||
*/
|
||||
_submit: function(e, loadEditForm) {
|
||||
_submit: function(loadEditForm) {
|
||||
var self = this;
|
||||
|
||||
// Don't submit with empty ID
|
||||
@ -335,9 +327,8 @@
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
@ -1,13 +1,13 @@
|
||||
(function($) {
|
||||
/**
|
||||
* @class Simple form with a page type dropdown
|
||||
* which creates a new page through #Form_EditForm and adds a new tree node.
|
||||
* @name ss.Form_AddForm
|
||||
* @requires ss.i18n
|
||||
* @requires ss.Form_EditForm
|
||||
*/
|
||||
$('#Form_AddForm').concrete(function($) {
|
||||
return/** @lends ss.Form_AddForm */{
|
||||
$.concrete('ss', function($){
|
||||
/**
|
||||
* @class Simple form with a page type dropdown
|
||||
* which creates a new page through #Form_EditForm and adds a new tree node.
|
||||
* @name ss.Form_AddForm
|
||||
* @requires ss.i18n
|
||||
* @requires ss.Form_EditForm
|
||||
*/
|
||||
$('#Form_AddForm').concrete(/** @lends ss.Form_AddForm */{
|
||||
/**
|
||||
* @type DOMElement
|
||||
*/
|
||||
@ -16,15 +16,11 @@
|
||||
/**
|
||||
* @type Array Internal counter to create unique page identifiers prior to ajax saving
|
||||
*/
|
||||
_NewPages: [],
|
||||
NewPages: [],
|
||||
|
||||
onmatch: function() {
|
||||
var self = this;
|
||||
|
||||
this.bind('submit', function(e) {
|
||||
return self._submit(e);
|
||||
});
|
||||
|
||||
Observable.applyTo(this[0]);
|
||||
|
||||
var tree = jQuery('#sitetree')[0];
|
||||
@ -32,11 +28,13 @@
|
||||
jQuery(tree).bind('selectionchanged', function(e, data) {self.treeSelectionChanged(e, data);});
|
||||
|
||||
this.find(':input[name=PageType]').bind('change', this.typeDropdownChanged);
|
||||
|
||||
this._super();
|
||||
},
|
||||
|
||||
_submit: function(e) {
|
||||
var newPages = this._NewPages();
|
||||
var tree = this.Tree();
|
||||
onsubmit: function(e) {
|
||||
var newPages = this.getNewPages();
|
||||
var tree = this.getTree();
|
||||
var parentID = (tree.firstSelected()) ? tree.getIdxOf(tree.firstSelected()) : 0;
|
||||
|
||||
// TODO: Remove 'new-' code http://open.silverstripe.com/ticket/875
|
||||
@ -68,7 +66,7 @@
|
||||
{type: 'POST', data: data}
|
||||
);
|
||||
|
||||
this.set_NewPages(newPages);
|
||||
this.setNewPages(newPages);
|
||||
|
||||
return false;
|
||||
},
|
||||
@ -80,12 +78,12 @@
|
||||
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);
|
||||
},
|
||||
|
||||
typeDropdownChanged : function() {
|
||||
var tree = this.Tree();
|
||||
var tree = this.getTree();
|
||||
|
||||
// Don't do anything if we're already on an appropriate node
|
||||
var sel = tree.firstSelected();
|
||||
@ -102,6 +100,6 @@
|
||||
if(newNode) tree.changeCurrentTo(newNode);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
}(jQuery));
|
@ -1,18 +1,18 @@
|
||||
(function($) {
|
||||
$.concrete('ss', function($){
|
||||
|
||||
/**
|
||||
* @class Batch actions which take a bunch of selected pages,
|
||||
* usually from the CMS tree implementation, and perform serverside
|
||||
* callbacks on the whole set. We make the tree selectable when the jQuery.UI tab
|
||||
* enclosing this form is opened.
|
||||
* @name ss.Form_BatchActionsForm
|
||||
*
|
||||
* Events:
|
||||
* - register: Called before an action is added.
|
||||
* - unregister: Called before an action is removed.
|
||||
*/
|
||||
$('#Form_BatchActionsForm').concrete('ss', function($){
|
||||
return/** @lends ss.Form_BatchActionsForm */{
|
||||
/**
|
||||
* @class Batch actions which take a bunch of selected pages,
|
||||
* usually from the CMS tree implementation, and perform serverside
|
||||
* callbacks on the whole set. We make the tree selectable when the jQuery.UI tab
|
||||
* enclosing this form is opened.
|
||||
* @name ss.Form_BatchActionsForm
|
||||
*
|
||||
* Events:
|
||||
* - register: Called before an action is added.
|
||||
* - unregister: Called before an action is removed.
|
||||
*/
|
||||
$('#Form_BatchActionsForm').concrete(/** @lends ss.Form_BatchActionsForm */{
|
||||
|
||||
/**
|
||||
* @type {DOMElement}
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
this.setTree($('#sitetree')[0]);
|
||||
|
||||
$(this.Tree()).bind('selectionchanged', function(e, data) {
|
||||
$(this.getTree()).bind('selectionchanged', function(e, data) {
|
||||
self._treeSelectionChanged(data.node);
|
||||
});
|
||||
|
||||
@ -42,14 +42,14 @@
|
||||
// if the panel is visible (meaning about to be closed),
|
||||
// disable tree selection and reset any values. Otherwise enable it.
|
||||
if($(ui.panel).is(':visible')) {
|
||||
$(self.Tree()).removeClass('multiselect');
|
||||
$(self.getTree()).removeClass('multiselect');
|
||||
} else {
|
||||
self._multiselectTransform();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
this.bind('submit', function(e) {return self._submit(e);});
|
||||
this._super();
|
||||
},
|
||||
|
||||
/**
|
||||
@ -58,8 +58,7 @@
|
||||
*/
|
||||
register: function(type, callback) {
|
||||
this.trigger('register', {type: type, callback: callback});
|
||||
|
||||
var actions = this.Actions();
|
||||
var actions = this.getActions();
|
||||
actions[type] = callback;
|
||||
this.setActions(actions);
|
||||
},
|
||||
@ -72,7 +71,7 @@
|
||||
unregister: function(type) {
|
||||
this.trigger('unregister', {type: type});
|
||||
|
||||
var actions = this.Actions();
|
||||
var actions = this.getActions();
|
||||
if(actions[type]) delete actions[type];
|
||||
this.setActions(actions);
|
||||
},
|
||||
@ -87,9 +86,9 @@
|
||||
return $('#TreeActions-batchactions').is(':visible');
|
||||
},
|
||||
|
||||
_submit: function(e) {
|
||||
onsubmit: function(e) {
|
||||
var ids = [];
|
||||
var tree = this.Tree();
|
||||
var tree = this.getTree();
|
||||
// find all explicitly selected IDs
|
||||
$(tree).find('li.selected').each(function() {
|
||||
ids.push(tree.getIdxOf(this));
|
||||
@ -107,13 +106,11 @@
|
||||
|
||||
// apply callback, which might modify the IDs
|
||||
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
|
||||
// callback to cancel the actions
|
||||
if(!ids || !ids.length) {
|
||||
return false;
|
||||
}
|
||||
if(!ids || !ids.length) return false;
|
||||
|
||||
// write IDs to the hidden field
|
||||
this.find(':input[name=csvIDs]').val(ids.join(','));
|
||||
@ -181,10 +178,10 @@
|
||||
*/
|
||||
_multiselectTransform : function() {
|
||||
// make tree selectable
|
||||
jQuery(this.Tree()).addClass('multiselect');
|
||||
jQuery(this.getTree()).addClass('multiselect');
|
||||
|
||||
// auto-select the current node
|
||||
var node = this.Tree().firstSelected();
|
||||
var node = this.getTree().firstSelected();
|
||||
if(node){
|
||||
node.removeNodeClass('current');
|
||||
node.addNodeClass('selected');
|
||||
@ -226,7 +223,7 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
|
@ -1,21 +1,20 @@
|
||||
(function($) {
|
||||
$.concrete('ss', function($){
|
||||
|
||||
/**
|
||||
* @class Base edit form, provides ajaxified saving
|
||||
* and reloading itself through the ajax return values.
|
||||
* Takes care of resizing tabsets within the layout container.
|
||||
* @name ss.Form_EditForm
|
||||
* @require jquery.changetracker
|
||||
*
|
||||
* <h3>Events</h3>
|
||||
* - ajaxsubmit: Form is about to be submitted through ajax
|
||||
* - validate: Contains validation result
|
||||
* - removeform: A form is about to be removed from the DOM
|
||||
* - load: Form is about to be loaded through ajax
|
||||
*/
|
||||
$('#Form_EditForm').concrete('ss',function($){
|
||||
return/** @lends ss.Form_EditForm */{
|
||||
|
||||
/**
|
||||
* @class Base edit form, provides ajaxified saving
|
||||
* and reloading itself through the ajax return values.
|
||||
* Takes care of resizing tabsets within the layout container.
|
||||
* @name ss.Form_EditForm
|
||||
* @require jquery.changetracker
|
||||
*
|
||||
* <h3>Events</h3>
|
||||
* - ajaxsubmit: Form is about to be submitted through ajax
|
||||
* - validate: Contains validation result
|
||||
* - removeform: A form is about to be removed from the DOM
|
||||
* - load: Form is about to be loaded through ajax
|
||||
*/
|
||||
$('#Form_EditForm').concrete(/** @lends ss.Form_EditForm */{
|
||||
/**
|
||||
* @type String HTML text to show when no form content is chosen.
|
||||
* Will show inside the <form> tag.
|
||||
@ -32,10 +31,6 @@
|
||||
|
||||
this._setupChangeTracker();
|
||||
|
||||
this.bind('submit', function(e) {
|
||||
return self._submit(e);
|
||||
});
|
||||
|
||||
// Can't bind this through jQuery
|
||||
window.onbeforeunload = function(e) {return self._checkChangeTracker(false);};
|
||||
|
||||
@ -45,7 +40,7 @@
|
||||
_setupChangeTracker: function() {
|
||||
// Don't bind any events here, as we dont replace the
|
||||
// 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
|
||||
*/
|
||||
_submit: function(e) {
|
||||
onsubmit: function(e) {
|
||||
this.ajaxSubmit();
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
@ -201,15 +197,11 @@
|
||||
* Falls back to the default RemoveText() option (Optional)
|
||||
*/
|
||||
removeForm: function(placeholderHtml) {
|
||||
if(!placeholderHtml) placeholderHtml = this.PlaceholderHtml();
|
||||
|
||||
if(!placeholderHtml) placeholderHtml = this.getPlaceholderHtml();
|
||||
// Alert when unsaved changes are present
|
||||
if(this._checkChangeTracker(true) == false) return false;
|
||||
|
||||
if(this._checkChangeTracker(true) == false) return;
|
||||
this.trigger('removeform');
|
||||
|
||||
this.html(placeholderHtml);
|
||||
|
||||
// TODO This should be using the plugin API
|
||||
this.removeClass('changed');
|
||||
},
|
||||
@ -294,45 +286,36 @@
|
||||
statusMessage(_statusMessage, (xmlhttp.status >= 400) ? 'bad' : 'good');
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @class All buttons in the right CMS form go through here by default.
|
||||
* We need this onclick overloading because we can't get to the
|
||||
* clicked button from a form.onsubmit event.
|
||||
* @name ss.Form_EditForm.Actions.submit
|
||||
*/
|
||||
$('#Form_EditForm .Actions :submit').concrete('ss', function($){
|
||||
return/** @lends ss.Form_EditForm.Actions.submit */{
|
||||
onmatch: function() {
|
||||
this.bind('click', this._onclick);
|
||||
|
||||
this._super();
|
||||
},
|
||||
_onclick: function() {
|
||||
/**
|
||||
* @class All buttons in the right CMS form go through here by default.
|
||||
* We need this onclick overloading because we can't get to the
|
||||
* clicked button from a form.onsubmit event.
|
||||
* @name ss.Form_EditForm.Actions.submit
|
||||
*/
|
||||
$('#Form_EditForm .Actions :submit').concrete(/** @lends ss.Form_EditForm.Actions.submit */{
|
||||
onclick: function(e) {
|
||||
jQuery('#Form_EditForm').concrete('ss').ajaxSubmit(this);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @class Add tinymce to HtmlEditorFields within the CMS.
|
||||
* @name ss.Form_EditForm.textarea.htmleditor
|
||||
*/
|
||||
$('#Form_EditForm textarea.htmleditor').concrete('ss', function($){
|
||||
return/** @lends ss.Form_EditForm.Actions.submit */{
|
||||
/**
|
||||
* @class Add tinymce to HtmlEditorFields within the CMS.
|
||||
* @name ss.Form_EditForm.textarea.htmleditor
|
||||
*/
|
||||
$('#Form_EditForm textarea.htmleditor').concrete(/** @lends ss.Form_EditForm.Actions.submit */{
|
||||
onmatch : function() {
|
||||
tinyMCE.execCommand("mceAddControl", true, this.attr('id'));
|
||||
this.isChanged = function() {
|
||||
return tinyMCE.getInstanceById(this.attr('id')).isDirty();
|
||||
}
|
||||
};
|
||||
this.resetChanged = function() {
|
||||
var inst = tinyMCE.getInstanceById(this.attr('id'));
|
||||
if (inst) inst.startContent = tinymce.trim(inst.getContent({format : 'raw', no_events : 1}));
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
}(jQuery));
|
@ -5,33 +5,32 @@
|
||||
var ss_MainLayout;
|
||||
|
||||
(function($) {
|
||||
$.concrete('ss', function($){
|
||||
|
||||
// setup jquery.concrete
|
||||
$.concrete.warningLevel = $.concrete.WARN_LEVEL_BESTPRACTISE;
|
||||
// setup jquery.concrete
|
||||
$.concrete.warningLevel = $.concrete.WARN_LEVEL_BESTPRACTISE;
|
||||
|
||||
// global ajax error handlers
|
||||
$.ajaxSetup({
|
||||
error: function(xmlhttp, status, error) {
|
||||
var msg = (xmlhttp.getResponseHeader('X-Status')) ? xmlhttp.getResponseHeader('X-Status') : xmlhttp.statusText;
|
||||
statusMessage(msg, 'bad');
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Available Custom Events:
|
||||
* <ul>
|
||||
* <li>ajaxsubmit</li>
|
||||
* <li>validate</li>
|
||||
* <li>loadnewpage</li>
|
||||
*
|
||||
* @class Main LeftAndMain interface with some control
|
||||
* panel and an edit form.
|
||||
* @name ss.LeftAndMain
|
||||
*/
|
||||
$('.LeftAndMain').concrete('ss', function($){
|
||||
return/** @lends ss.EditMemberProfile */ {
|
||||
// global ajax error handlers
|
||||
$.ajaxSetup({
|
||||
error: function(xmlhttp, status, error) {
|
||||
var msg = (xmlhttp.getResponseHeader('X-Status')) ? xmlhttp.getResponseHeader('X-Status') : xmlhttp.statusText;
|
||||
statusMessage(msg, 'bad');
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Available Custom Events:
|
||||
* <ul>
|
||||
* <li>ajaxsubmit</li>
|
||||
* <li>validate</li>
|
||||
* <li>loadnewpage</li>
|
||||
*
|
||||
* @class Main LeftAndMain interface with some control
|
||||
* panel and an edit form.
|
||||
* @name ss.LeftAndMain
|
||||
*/
|
||||
$('.LeftAndMain').concrete(/** @lends ss.EditMemberProfile */{
|
||||
/**
|
||||
* Reference to jQuery.layout element
|
||||
* @type Object
|
||||
*/
|
||||
@ -174,12 +173,13 @@ var ss_MainLayout;
|
||||
global: false,
|
||||
complete: onSessionLost
|
||||
});
|
||||
}, this.PingIntervalSeconds() * 1000);
|
||||
}, this.getPingIntervalSeconds() * 1000);
|
||||
},
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
$("#treepanes", this).accordion("resize");
|
||||
@ -196,18 +196,16 @@ var ss_MainLayout;
|
||||
$('#Form_EditForm fieldset > .ss-tabset > .tab > .ss-tabset', this).fitHeightToParent();
|
||||
$('#Form_EditForm fieldset > .ss-tabset > .tab > .ss-tabset > .tab', this).fitHeightToParent();
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @class Make all buttons "hoverable" with jQuery theming.
|
||||
* Also sets the clicked button on a form submission, making it available through
|
||||
* a new 'clickedButton' property on the form DOM element.
|
||||
*
|
||||
* @name ss.LeftAndMain.Buttons
|
||||
*/
|
||||
$('.LeftAndMain :submit, .LeftAndMain button, .LeftAndMain :reset').concrete('ss', function($){
|
||||
return/** @lends ss.LeftAndMain.Buttons */{
|
||||
/**
|
||||
* @class Make all buttons "hoverable" with jQuery theming.
|
||||
* Also sets the clicked button on a form submission, making it available through
|
||||
* a new 'clickedButton' property on the form DOM element.
|
||||
*
|
||||
* @name ss.LeftAndMain.Buttons
|
||||
*/
|
||||
$('.LeftAndMain :submit, .LeftAndMain button, .LeftAndMain :reset').concrete(/** @lends ss.LeftAndMain.Buttons */{
|
||||
onmatch: function() {
|
||||
this.addClass(
|
||||
'ui-state-default ' +
|
||||
@ -238,16 +236,13 @@ var ss_MainLayout;
|
||||
|
||||
this._super();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* @class Container for tree actions like "create", "search", etc.
|
||||
* @name ss.TreeActions
|
||||
*/
|
||||
$('#TreeActions').concrete('ss', function($){
|
||||
return/** @lends ss.TreeActions */{
|
||||
});
|
||||
|
||||
/**
|
||||
* @class Container for tree actions like "create", "search", etc.
|
||||
* @name ss.TreeActions
|
||||
*/
|
||||
$('#TreeActions').concrete(/** @lends ss.TreeActions */{
|
||||
/**
|
||||
* Setup "create", "search", "batch actions" layers above tree.
|
||||
* All tab contents are closed by default.
|
||||
@ -259,17 +254,14 @@ var ss_MainLayout;
|
||||
cookie: { expires: 30, path: '/', name: 'ui-tabs-TreeActions' }
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* @class Link for editing the profile for a logged-in member
|
||||
* through a modal dialog.
|
||||
* @name ss.EditMemberProfile
|
||||
*/
|
||||
$('a#EditMemberProfile').concrete('ss', function($){
|
||||
return/** @lends ss.EditMemberProfile */{
|
||||
});
|
||||
|
||||
/**
|
||||
* @class Link for editing the profile for a logged-in member
|
||||
* through a modal dialog.
|
||||
* @name ss.EditMemberProfile
|
||||
*/
|
||||
$('a#EditMemberProfile').concrete(/** @lends ss.EditMemberProfile */{
|
||||
onmatch: function() {
|
||||
var self = this;
|
||||
|
||||
@ -350,20 +342,16 @@ var ss_MainLayout;
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* @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 */{
|
||||
});
|
||||
|
||||
/**
|
||||
* @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(/** @lends ss.switchViewLinks */{
|
||||
/**
|
||||
* @type DOMElement
|
||||
*/
|
||||
@ -383,9 +371,9 @@ var ss_MainLayout;
|
||||
*/
|
||||
refresh: function() {
|
||||
// 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) {
|
||||
var locale = this.Form().find(':input[name=Locale]').val();
|
||||
var locale = this.getForm().find(':input[name=Locale]').val();
|
||||
var url = urlSegment;
|
||||
if(this.metadata().params) url += '?' + this.metadata().params;
|
||||
if(locale) url += ((url.indexOf('?') > 0) ? '&' : '?') + "locale=" + locale;
|
||||
@ -401,9 +389,8 @@ var ss_MainLayout;
|
||||
window.open($(e.target).attr('href'));
|
||||
return false;
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
}(jQuery));
|
||||
|
||||
// Backwards compatibility
|
||||
|
@ -1,30 +1,27 @@
|
||||
(function($) {
|
||||
|
||||
/**
|
||||
* A simple ajax browser history implementation tailored towards
|
||||
* navigating through search results and different forms loaded into
|
||||
* the ModelAdmin right panels. The logic listens to search and form loading
|
||||
* events, keeps track of the loaded URLs, and will display graphical back/forward
|
||||
* buttons where appropriate. A search action will cause the history to be reset.
|
||||
*
|
||||
* Note: The logic does not replay save operations or hook into any form actions.
|
||||
*
|
||||
* Available Events:
|
||||
* - historyAdd
|
||||
* - historyStart
|
||||
* - historyGoFoward
|
||||
* - historyGoBack
|
||||
*
|
||||
* @todo Switch tab state when re-displaying search forms
|
||||
* @todo Reload search parameters into forms
|
||||
*
|
||||
* @name ss.ModelAdmin
|
||||
*/
|
||||
$('.ModelAdmin').concrete('ss', function($){
|
||||
return/** @lends ss.ModelAdmin */ {
|
||||
|
||||
$.concrete('ss', function($){
|
||||
/**
|
||||
* A simple ajax browser history implementation tailored towards
|
||||
* navigating through search results and different forms loaded into
|
||||
* the ModelAdmin right panels. The logic listens to search and form loading
|
||||
* events, keeps track of the loaded URLs, and will display graphical back/forward
|
||||
* buttons where appropriate. A search action will cause the history to be reset.
|
||||
*
|
||||
* Note: The logic does not replay save operations or hook into any form actions.
|
||||
*
|
||||
* Available Events:
|
||||
* - historyAdd
|
||||
* - historyStart
|
||||
* - historyGoFoward
|
||||
* - historyGoBack
|
||||
*
|
||||
* @todo Switch tab state when re-displaying search forms
|
||||
* @todo Reload search parameters into forms
|
||||
*
|
||||
* @name ss.ModelAdmin
|
||||
*/
|
||||
$('.ModelAdmin').concrete(/** @lends ss.ModelAdmin */ {
|
||||
History: [],
|
||||
|
||||
Future: [],
|
||||
|
||||
onmatch: function() {
|
||||
@ -52,8 +49,8 @@
|
||||
},
|
||||
|
||||
redraw: function() {
|
||||
this.find('.historyNav .forward').toggle(Boolean(this.Future().length > 0));
|
||||
this.find('.historyNav .back').toggle(Boolean(this.History().length > 1));
|
||||
this.find('.historyNav .forward').toggle(Boolean(this.getFuture().length > 0));
|
||||
this.find('.historyNav .back').toggle(Boolean(this.getHistory().length > 1));
|
||||
},
|
||||
|
||||
startHistory: function(url, data) {
|
||||
@ -74,10 +71,8 @@
|
||||
if(url.indexOf('?') == -1) url += '?' + $.param(data);
|
||||
else url += '&' + $.param(data);
|
||||
}
|
||||
|
||||
// Add to history
|
||||
this.History().push(url);
|
||||
|
||||
this.getHistory().push(url);
|
||||
// Reset future
|
||||
this.setFuture([]);
|
||||
|
||||
@ -85,72 +80,67 @@
|
||||
},
|
||||
|
||||
goBack: function() {
|
||||
if(this.History() && this.History().length) {
|
||||
if(this.Future() == null) this.setFuture([]);
|
||||
if(this.getHistory() && this.getHistory().length) {
|
||||
if(this.getFuture() == null) this.setFuture([]);
|
||||
|
||||
var currentPage = this.History().pop();
|
||||
var previousPage = this.History()[this.History().length-1];
|
||||
var currentPage = this.getHistory().pop();
|
||||
var previousPage = this.getHistory()[this.getHistory().length-1];
|
||||
|
||||
this.Future().push(currentPage);
|
||||
this.getFuture().push(currentPage);
|
||||
|
||||
this.trigger('historyGoBack', {url:previousPage});
|
||||
|
||||
// load new location
|
||||
$('#Form_EditForm').concrete('ss').loadForm(previousPage);
|
||||
$('#Form_EditForm').loadForm(previousPage);
|
||||
|
||||
this.redraw();
|
||||
}
|
||||
},
|
||||
|
||||
goForward: function() {
|
||||
if(this.Future() && this.Future().length) {
|
||||
if(this.Future() == null) this.setFuture([]);
|
||||
if(this.getFuture() && this.getFuture().length) {
|
||||
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});
|
||||
|
||||
// load new location
|
||||
$('#Form_EditForm').concrete('ss').loadForm(nextPage);
|
||||
$('#Form_EditForm').loadForm(nextPage);
|
||||
|
||||
this.redraw();
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* A search action will cause the history to be reset.
|
||||
*/
|
||||
$('#SearchForm_holder form').concrete('ss', function($) {
|
||||
return{
|
||||
/**
|
||||
* A search action will cause the history to be reset.
|
||||
*/
|
||||
$('#SearchForm_holder form').concrete({
|
||||
onmatch: function() {
|
||||
var self = this;
|
||||
this.bind('beforeSubmit', function(e) {
|
||||
$('.ModelAdmin').concrete('ss').startHistory(
|
||||
$('.ModelAdmin').startHistory(
|
||||
self.attr('action'),
|
||||
self.serializeArray()
|
||||
);
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* We have to apply this to the result table buttons instead of the
|
||||
* more generic form loading.
|
||||
*/
|
||||
$('form[name=Form_ResultsForm] tbody td a').concrete('ss', function($) {
|
||||
return{
|
||||
onmatch: function() {
|
||||
var self = this;
|
||||
this.bind('click', function(e) {
|
||||
$('.ModelAdmin').addHistory(self.attr('href'));
|
||||
});
|
||||
this._super();
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* We have to apply this to the result table buttons instead of the
|
||||
* more generic form loading.
|
||||
*/
|
||||
$('form[name=Form_ResultsForm] tbody td a').concrete({
|
||||
onclick: function(e) {
|
||||
$('.ModelAdmin').addHistory(this.attr('href'));
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
})(jQuery);
|
@ -9,152 +9,148 @@
|
||||
* @todo alias the $ function instead of literal jQuery
|
||||
*/
|
||||
(function($) {
|
||||
$.concrete('ss', function($){
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Search form
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Search form
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* If a dropdown is used to choose between the classes, it is handled by this code
|
||||
*/
|
||||
$('#ModelClassSelector select').concrete({
|
||||
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();
|
||||
/**
|
||||
* If a dropdown is used to choose between the classes, it is handled by this code
|
||||
*/
|
||||
$('#ModelClassSelector select').concrete({
|
||||
onmatch: function() {
|
||||
// Initialise the form by calling this onchange event straight away
|
||||
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();
|
||||
});
|
||||
});
|
||||
|
||||
// Initialise the form by calling this onchange event straight away
|
||||
this.change();
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Submits a search filter query and attaches event handlers
|
||||
* to the response table, excluding the import form because
|
||||
* file ($_FILES) submission doesn't work using AJAX
|
||||
*
|
||||
* Note: This is used for Form_CreateForm and all Form_SearchForm_* variations
|
||||
*/
|
||||
$('#SearchForm_holder form').concrete({
|
||||
onmatch: function() {
|
||||
var self = this;
|
||||
|
||||
this.bind('submit', function(e) {
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Submits a search filter query and attaches event handlers
|
||||
* to the response table, excluding the import form because
|
||||
* file ($_FILES) submission doesn't work using AJAX
|
||||
*
|
||||
* Note: This is used for Form_CreateForm and all Form_SearchForm_* variations
|
||||
*/
|
||||
$('#SearchForm_holder form').concrete({
|
||||
onsubmit: function(e) {
|
||||
// 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');
|
||||
|
||||
$('#Form_EditForm').concrete('ss').loadForm(
|
||||
self.attr('action'),
|
||||
$('#Form_EditForm').loadForm(
|
||||
this.attr('action'),
|
||||
function() {
|
||||
btn.removeClass('loading');
|
||||
},
|
||||
{data: self.serialize()}
|
||||
{data: this.serialize()}
|
||||
);
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Column selection in search form
|
||||
*/
|
||||
$('a.form_frontend_function.toggle_result_assembly').concrete({
|
||||
onclick: function(e) {
|
||||
var toggleElement = $(this).next();
|
||||
toggleElement.toggle();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$('a.form_frontend_function.tick_all_result_assembly').concrete({
|
||||
onclick: function(e) {
|
||||
var resultAssembly = $(this).prevAll('div#ResultAssembly').find('ul li input');
|
||||
resultAssembly.attr('checked', 'checked');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$('a.form_frontend_function.untick_all_result_assembly').concrete({
|
||||
onclick: function(e) {
|
||||
var resultAssembly = $(this).prevAll('div#ResultAssembly').find('ul li input');
|
||||
resultAssembly.removeAttr('checked');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Table record handler for search result record
|
||||
*/
|
||||
$('.resultsTable tbody td').concrete({
|
||||
onmatch: function() {
|
||||
// TODO Replace with concrete event handler
|
||||
this.bind('click', function(e) {
|
||||
var firstLink = $(this).find('a[href]');
|
||||
if(!firstLink) return;
|
||||
$('#Form_EditForm').concrete('ss').loadForm(firstLink.attr('href'));
|
||||
/**
|
||||
* Column selection in search form
|
||||
*/
|
||||
$('a.form_frontend_function.toggle_result_assembly').concrete({
|
||||
onclick: function(e) {
|
||||
var toggleElement = $(this).next();
|
||||
toggleElement.toggle();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Add object button
|
||||
*/
|
||||
$('#Form_ManagedModelsSelect').concrete({
|
||||
onmatch: function() {
|
||||
this.bind('submit', function(){
|
||||
$('a.form_frontend_function.tick_all_result_assembly').concrete({
|
||||
onclick: function(e) {
|
||||
var resultAssembly = $(this).prevAll('div#ResultAssembly').find('ul li input');
|
||||
resultAssembly.attr('checked', 'checked');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$('a.form_frontend_function.untick_all_result_assembly').concrete({
|
||||
onclick: function(e) {
|
||||
var resultAssembly = $(this).prevAll('div#ResultAssembly').find('ul li input');
|
||||
resultAssembly.removeAttr('checked');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Table record handler for search result record
|
||||
*/
|
||||
$('.resultsTable tbody td').concrete({
|
||||
onclick: function(e) {
|
||||
var firstLink = this.find('a[href]');
|
||||
if(!firstLink) return;
|
||||
$('#Form_EditForm').loadForm(firstLink.attr('href'));
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Add object button
|
||||
*/
|
||||
$('#Form_ManagedModelsSelect').concrete({
|
||||
onsubmit: function(e) {
|
||||
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);
|
||||
$('#Form_EditForm').concrete('ss').loadForm(
|
||||
$('#Form_EditForm').loadForm(
|
||||
requestPath,
|
||||
function() {
|
||||
$button.removeClass('loading');
|
||||
$button = null;
|
||||
}
|
||||
);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* RHS panel Delete button
|
||||
*/
|
||||
$('#Form_EditForm input[name=action_doDelete]').concrete({
|
||||
onmatch: function() {
|
||||
this.bind('click', function() {
|
||||
var confirmed = confirm(ss.i18n._t('ModelAdmin.REALLYDELETE', 'Really delete?'));
|
||||
if(!confirmed) {
|
||||
$(this).removeClass('loading');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* RHS panel Delete button
|
||||
*/
|
||||
$('#Form_EditForm input[name=action_doDelete]').concrete({
|
||||
onclick: function(e) {
|
||||
if(!confirm(ss.i18n._t('ModelAdmin.REALLYDELETE', 'Really delete?'))) {
|
||||
this.removeClass('loading');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Toggle import specifications
|
||||
*/
|
||||
$('.importSpec').concrete({
|
||||
onmatch: function() {
|
||||
this.hide();
|
||||
this.find('a.detailsLink').click(function() {
|
||||
$('#' + $(this).attr('href').replace(/.*#/,'')).toggle();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Toggle import specifications
|
||||
*/
|
||||
$('.importSpec').concrete({
|
||||
onmatch: function() {
|
||||
this.hide();
|
||||
this.find('a.detailsLink').click(function() {
|
||||
$('#' + $(this).attr('href').replace(/.*#/,'')).toggle();
|
||||
return false;
|
||||
});
|
||||
|
||||
this._super();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
})(jQuery);
|
@ -1,15 +1,17 @@
|
||||
jQuery(function($) {
|
||||
/**
|
||||
* @class Tree panel.
|
||||
* @name ss.sitetree
|
||||
*/
|
||||
$('#sitetree').concrete('ss', function($){
|
||||
return/** @lends ss.sitetree */{
|
||||
(function($) {
|
||||
$.concrete('ss', function($){
|
||||
/**
|
||||
* @class Tree panel.
|
||||
* @name ss.sitetree
|
||||
*/
|
||||
$('#sitetree').concrete(/** @lends ss.sitetree */{
|
||||
onmatch: function() {
|
||||
// make sure current ID of loaded form is actually selected in tree
|
||||
var id = $('#Form_EditForm :input[name=ID]').val();
|
||||
if (id) this[0].setCurrentByIdx(id);
|
||||
|
||||
this._super();
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
});
|
||||
}(jQuery));
|
Loading…
Reference in New Issue
Block a user