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($){
|
2012-04-11 05:01:31 +02:00
|
|
|
|
|
|
|
$('#pages-controller-cms-content').entwine({
|
|
|
|
/**
|
|
|
|
* we need to check if the current url contains a sub url 'listchildren' and
|
2012-04-11 05:08:39 +02:00
|
|
|
* select its list view if it does, otherwise use the default tabs() call which is
|
|
|
|
* using cookie options
|
2012-04-11 05:01:31 +02:00
|
|
|
*/
|
|
|
|
redrawTabs: function() {
|
|
|
|
if(window.location.href.match(/listchildren/)){
|
|
|
|
this.rewriteHashlinks();
|
|
|
|
this.tabs({ selected: 1 });
|
|
|
|
}else{
|
|
|
|
this._super();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
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);
|
2012-04-11 05:53:04 +02:00
|
|
|
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
|
|
|
|
2012-04-11 07:37:28 +02:00
|
|
|
this.resetForm();
|
|
|
|
//the dropdown field wont be reset due to it is applied to chosen.js so need to treated specially
|
|
|
|
this.find('.field.dropdown select').val('').trigger("liszt:updated");
|
2009-11-21 03:38:31 +01:00
|
|
|
this._reloadSitetree();
|
2012-04-11 07:37:28 +02:00
|
|
|
this._reloadListview();
|
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);
|
|
|
|
}
|
|
|
|
});
|
2012-04-10 04:14:42 +02:00
|
|
|
},
|
|
|
|
replace: function(url){
|
|
|
|
if(window.History.enabled) {
|
|
|
|
var container = $('.cms-container')
|
2012-04-10 06:21:26 +02:00
|
|
|
container.loadPanel(url, '', {selector: '.cms-list form'});
|
2012-04-10 04:14:42 +02:00
|
|
|
} else {
|
|
|
|
window.location = $.path.makeUrlAbsolute(url, $('base').attr('href'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.cms-list .list-children-link').entwine({
|
|
|
|
onclick: function(e) {
|
|
|
|
this.closest('.cms-list').replace(this.attr('href'));
|
|
|
|
e.preventDefault();
|
|
|
|
return false;
|
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
}
|
2009-11-21 04:19:59 +01:00
|
|
|
});
|
2009-11-21 04:15:55 +01:00
|
|
|
});
|
2009-11-21 03:36:26 +01:00
|
|
|
})(jQuery);
|