2010-05-08 04:45:05 +02:00
|
|
|
/**
|
|
|
|
* File: CMSMain.js
|
|
|
|
*/
|
2009-11-21 03:36:00 +01:00
|
|
|
(function($) {
|
2010-04-13 07:55:56 +02:00
|
|
|
$.entwine('ss', function($){
|
2009-11-21 03:37:41 +01:00
|
|
|
|
2009-11-21 04:19:59 +01:00
|
|
|
/**
|
2011-04-22 13:32:10 +02:00
|
|
|
* Class: #Form_SearchForm
|
2010-05-08 04:45:05 +02:00
|
|
|
*
|
|
|
|
* Control the site tree filter.
|
2009-11-21 04:19:59 +01:00
|
|
|
* Toggles search form fields based on a dropdown selection,
|
|
|
|
* similar to "Smart Search" criteria in iTunes.
|
|
|
|
*/
|
2011-04-22 13:32:10 +02:00
|
|
|
$('#Form_SearchForm').entwine({
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2010-05-08 04:45:05 +02:00
|
|
|
/**
|
|
|
|
* Constructor: onmatch
|
|
|
|
*/
|
2009-11-21 03:38:31 +01:00
|
|
|
onmatch: function() {
|
|
|
|
var self = this;
|
2009-11-21 03:37:06 +01:00
|
|
|
|
2011-03-22 04:43:49 +01:00
|
|
|
// Reset binding through entwine doesn't work in IE
|
|
|
|
this.bind('reset', function(e) {
|
|
|
|
self._onreset(e);
|
|
|
|
});
|
2009-11-21 03:37:06 +01:00
|
|
|
|
2009-11-21 04:19:59 +01:00
|
|
|
this._super();
|
|
|
|
},
|
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
/**
|
2010-05-08 04:45:05 +02:00
|
|
|
* Function: onsubmit
|
|
|
|
*
|
2009-11-21 03:38:31 +01:00
|
|
|
* Filter tree based on selected criteria.
|
|
|
|
*/
|
2009-11-21 04:19:59 +01:00
|
|
|
onsubmit: function(e) {
|
2009-11-21 03:38:31 +01:00
|
|
|
var self = this;
|
|
|
|
var data = [];
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
// convert from jQuery object literals to hash map
|
|
|
|
$(this.serializeArray()).each(function(i, el) {
|
|
|
|
data[el.name] = el.value;
|
|
|
|
});
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2011-04-22 13:32:10 +02:00
|
|
|
// TODO Disable checkbox tree controls that currently don't work with search.
|
2011-03-17 22:50:13 +01:00
|
|
|
this.find('.checkboxAboveTree :checkbox').attr('disabled', 'disabled');
|
|
|
|
|
2011-04-22 13:32:10 +02:00
|
|
|
// TODO disable buttons to avoid multiple submission
|
2009-11-21 03:38:31 +01:00
|
|
|
//this.find(':submit').attr('disabled', true);
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 04:21:00 +01:00
|
|
|
this.find(':submit[name=action_doSearchTree]').addClass('loading');
|
2012-04-05 05:39:23 +02:00
|
|
|
|
|
|
|
var params = this.serializeArray();
|
|
|
|
this._reloadSitetree(params);
|
|
|
|
this._reloadListview(params)
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
return false;
|
|
|
|
},
|
2010-05-08 04:45:05 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function: onreset
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* (Event) e
|
|
|
|
*/
|
2011-03-22 04:43:49 +01:00
|
|
|
_onreset: function(e) {
|
2011-04-22 13:32:10 +02:00
|
|
|
// TODO Enable checkbox tree controls
|
2009-11-21 03:38:31 +01:00
|
|
|
this.find('.checkboxAboveTree :checkbox').attr('disabled', 'false');
|
2009-11-21 03:37:06 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
this._reloadSitetree();
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
return false;
|
|
|
|
},
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2010-05-08 04:45:05 +02:00
|
|
|
/**
|
|
|
|
* Function: _reloadSitetree
|
|
|
|
*/
|
2011-03-17 22:50:13 +01:00
|
|
|
_reloadSitetree: function(params) {
|
2009-11-21 03:38:31 +01:00
|
|
|
var self = this;
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2011-04-17 10:04:46 +02:00
|
|
|
$('.cms-tree').search(
|
2011-03-17 22:50:13 +01:00
|
|
|
params,
|
|
|
|
function() {
|
2009-11-21 03:38:31 +01:00
|
|
|
self.find(':submit').attr('disabled', false).removeClass('loading');
|
|
|
|
self.find('.checkboxAboveTree :checkbox').attr('disabled', 'true');
|
|
|
|
},
|
2011-03-17 22:50:13 +01:00
|
|
|
function() {
|
2009-11-21 03:38:31 +01:00
|
|
|
self.find(':submit').attr('disabled', false).removeClass('loading');
|
|
|
|
self.find('.checkboxAboveTree :checkbox').attr('disabled', 'true');
|
|
|
|
errorMessage('Could not filter site tree<br />' + response.responseText);
|
|
|
|
}
|
2011-03-17 22:50:13 +01:00
|
|
|
);
|
2012-04-05 05:39:23 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
_reloadListview: function(params){
|
|
|
|
$('.cms-list').refresh(params);
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#cms-content-listview .cms-list').entwine({
|
|
|
|
refresh: function(params){
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
url: this.data('url-list'),
|
|
|
|
data: params,
|
|
|
|
success: function(data, status, xhr) {
|
|
|
|
self.html(data);
|
|
|
|
},
|
|
|
|
error: function(xhr, status, e) {
|
|
|
|
errorMessage(e);
|
|
|
|
}
|
|
|
|
});
|
2009-11-21 03:38:31 +01:00
|
|
|
}
|
2009-11-21 04:19:59 +01:00
|
|
|
});
|
2009-11-21 04:15:32 +01:00
|
|
|
|
2009-11-21 04:19:59 +01:00
|
|
|
/**
|
2010-05-08 04:45:05 +02:00
|
|
|
* Class: Form_SideReportsForm
|
|
|
|
*
|
|
|
|
* Simple form with a page type dropdown
|
2011-03-31 10:51:59 +02:00
|
|
|
* which creates a new page through .cms-edit-form and adds a new tree node.
|
2009-11-21 04:19:59 +01:00
|
|
|
*/
|
2010-04-13 07:55:56 +02:00
|
|
|
$('#Form_SideReportsForm').entwine(/** @lends ss.reports_holder */{
|
2009-11-21 04:20:54 +01:00
|
|
|
ReportContainer: null,
|
|
|
|
|
2010-05-08 04:45:05 +02:00
|
|
|
/**
|
|
|
|
* Constructor: onmatch
|
|
|
|
*/
|
2009-11-21 04:15:55 +01:00
|
|
|
onmatch: function() {
|
|
|
|
var self = this;
|
2009-11-21 04:20:54 +01:00
|
|
|
|
|
|
|
this.setReportContainer($('#SideReportsHolder'))
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 04:15:55 +01:00
|
|
|
// integrate with sitetree selection changes
|
2009-11-21 04:19:59 +01:00
|
|
|
// TODO Only trigger when report is visible
|
2011-04-17 10:04:46 +02:00
|
|
|
jQuery('.cms-tree').bind('select_node.jstree', function(e, data) {
|
2011-03-10 06:30:41 +01:00
|
|
|
var node = data.rslt.obj;
|
|
|
|
self.find(':input[name=ID]').val(node ? $(node).data('id') : null);
|
2009-11-21 04:15:55 +01:00
|
|
|
self.trigger('submit');
|
|
|
|
});
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 04:15:55 +01:00
|
|
|
// move submit button to the top
|
2009-11-21 04:21:08 +01:00
|
|
|
//this.find('#ReportClass').after(this.find('.Actions'));
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 04:20:54 +01:00
|
|
|
this._super();
|
|
|
|
},
|
|
|
|
|
2010-05-08 04:45:05 +02:00
|
|
|
/**
|
|
|
|
* Function: onsubmit
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* (Event) e
|
|
|
|
*/
|
2009-11-21 04:20:54 +01:00
|
|
|
onsubmit: function(e) {
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
// dont process if no report is selected
|
|
|
|
var reportClass = this.find(':input[name=ReportClass]').val();
|
|
|
|
if(!reportClass) return false;
|
|
|
|
|
|
|
|
var button = this.find(':submit:first');
|
|
|
|
button.addClass('loading');
|
|
|
|
|
|
|
|
jQuery.ajax({
|
|
|
|
url: this.attr('action'),
|
|
|
|
data: this.serializeArray(),
|
|
|
|
dataType: 'html',
|
|
|
|
success: function(data, status) {
|
|
|
|
// replace current form
|
|
|
|
self.getReportContainer().html(data);
|
|
|
|
},
|
|
|
|
complete: function(xmlhttp, status) {
|
|
|
|
button.removeClass('loading');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
2010-05-08 04:45:05 +02:00
|
|
|
* Class: #SideReportsHolder form
|
|
|
|
*
|
2009-11-21 04:20:54 +01:00
|
|
|
* All forms loaded via ajax from the Form_SideReports dropdown.
|
|
|
|
*/
|
2010-04-13 07:55:56 +02:00
|
|
|
$("#SideReportsHolder form").entwine({
|
2010-05-08 04:45:05 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function: onsubmit
|
|
|
|
*/
|
2009-11-21 04:20:54 +01:00
|
|
|
onsubmit: function() {
|
|
|
|
var self = this;
|
|
|
|
|
2009-11-21 04:15:55 +01:00
|
|
|
var button = this.find(':submit:first');
|
|
|
|
button.addClass('loading');
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 04:15:55 +01:00
|
|
|
jQuery.ajax({
|
|
|
|
url: this.attr('action'),
|
|
|
|
data: this.serializeArray(),
|
|
|
|
dataType: 'html',
|
|
|
|
success: function(data, status) {
|
|
|
|
// replace current form
|
2009-11-21 04:20:54 +01:00
|
|
|
self.html(data);
|
2009-11-21 04:15:55 +01:00
|
|
|
},
|
|
|
|
complete: function(xmlhttp, status) {
|
|
|
|
button.removeClass('loading');
|
|
|
|
}
|
|
|
|
});
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 04:16:09 +01:00
|
|
|
return false;
|
|
|
|
}
|
2009-11-21 04:20:54 +01:00
|
|
|
|
2009-11-21 04:19:59 +01:00
|
|
|
});
|
2009-12-16 23:25:05 +01:00
|
|
|
|
2009-12-16 23:40:09 +01:00
|
|
|
/**
|
|
|
|
* Register the onclick handler that loads the page into EditForm
|
|
|
|
*/
|
2010-04-13 07:55:56 +02:00
|
|
|
$("#SideReportsHolder form ul a").entwine({
|
2010-05-08 04:45:05 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function: onclick
|
|
|
|
*/
|
2009-12-17 01:33:23 +01:00
|
|
|
onclick: function(e) {
|
|
|
|
if (e.button!=2) {
|
|
|
|
var $link = $(this);
|
|
|
|
$link.addClass('loading');
|
2011-06-08 01:30:54 +02:00
|
|
|
jQuery('.cms-content').entwine('ss').loadForm(
|
2009-12-17 01:33:23 +01:00
|
|
|
$(this).attr('href'),
|
2011-06-08 01:30:54 +02:00
|
|
|
null,
|
2009-12-17 01:33:23 +01:00
|
|
|
function(e) {
|
|
|
|
$link.removeClass('loading');
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2009-12-16 23:25:05 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
2009-11-21 04:15:55 +01:00
|
|
|
});
|
2009-11-21 03:36:26 +01:00
|
|
|
})(jQuery);
|