Skip to content

Commit

Permalink
Merge branch 'master' of ssh://github.com/Fabrik/fabrik
Browse files Browse the repository at this point in the history
  • Loading branch information
cheesegrits committed Aug 22, 2012
2 parents 11af0ee + 59f4d3f commit 9bbde72
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 37 deletions.
5 changes: 4 additions & 1 deletion administrator/components/com_fabrik/models/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,12 @@ protected function getData()
$data = (array) json_decode($item->params);
$data['plugin'] = $this->getState('plugin');

$state = JArrayHelper::getValue($data, 'plugin_state');
$state = (array) JArrayHelper::getValue($data, 'plugin_state');

$data['params'] = (array) JArrayHelper::getValue($data, 'params', array());
$data['params']['plugin_state'] = $state[0];
$data['params']['plugins'] = $this->getState('plugin');

$data['validationrule']['plugin'] = $this->getState('plugin');
return $data;
}
Expand Down
19 changes: 17 additions & 2 deletions administrator/components/com_fabrik/views/element/tmpl/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
*/

// no direct access
// No direct access
defined('_JEXEC') or die;

JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
Expand All @@ -28,8 +28,23 @@
JText::script('COM_FABRIK_SUBOPTS_VALUES_ERROR');
?>

<script type="text/javascript">

Joomla.submitbutton = function(task) {
if (task !== 'element.cancel' && !controller.canSaveForm()) {
alert('Please wait - still loading');
return false;
}
if (task == 'element.cancel' || document.formvalidator.isValid(document.id('adminForm'))) {

Joomla.submitform(task, document.getElementById('adminForm'));
} else {
alert('<?php echo $this->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED'));?>');
}
}
</script>
<form action="<?php JRoute::_('index.php?option=com_fabrik'); ?>" method="post" name="adminForm" id="adminForm" class="form-validate">
<?php //?>

<?php if ($this->item->parent_id != 0) {
?>
<div id="system-message">
Expand Down
16 changes: 16 additions & 0 deletions administrator/components/com_fabrik/views/form/tmpl/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@
FabrikHelperHTML::script($srcs, $this->js);
?>

<script type="text/javascript">

Joomla.submitbutton = function(task) {
if (task !== 'form.cancel' && !controller.canSaveForm()) {
alert('Please wait - still loading');
return false;
}
if (task == 'form.cancel' || document.formvalidator.isValid(document.id('adminForm'))) {

Joomla.submitform(task, document.getElementById('adminForm'));
} else {
alert('<?php echo $this->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED'));?>');
}
}
</script>

<form action="<?php JRoute::_('index.php?option=com_fabrik'); ?>" method="post" name="adminForm" id="adminForm" class="form-validate">
<div class="width-50 fltlft">
<fieldset class="adminform">
Expand Down
16 changes: 16 additions & 0 deletions administrator/components/com_fabrik/views/list/tmpl/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@
FabrikHelperHTML::script($srcs, $this->js);
?>

<script type="text/javascript">

Joomla.submitbutton = function(task) {
if (task !== 'list.cancel' && !controller.canSaveForm()) {
alert('Please wait - still loading');
return false;
}
if (task == 'list.cancel' || document.formvalidator.isValid(document.id('adminForm'))) {

Joomla.submitform(task, document.getElementById('adminForm'));
} else {
alert('<?php echo $this->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED'));?>');
}
}
</script>

<form action="<?php JRoute::_('index.php?option=com_fabrik'); ?>" method="post" name="adminForm" id="adminForm" class="form-validate">

<div class="width-40 fltlft">
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 35 additions & 28 deletions administrator/components/com_fabrik/views/pluginmanager.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
var PluginManager = new Class({

pluginTotal: -1,
pluginTotal: 0,

topTotal: -1,

initialize: function (plugins, id, type) {
this.id = id;
this.type = type;
this.queue = new RequestQueue();
this.accordion = new Fx.Accordion([], [], {alwaysHide: true});
this.accordion = new Fx.Accordion([], [], {alwaysHide: true, display: -1});
for (var i = 0; i < plugins.length; i ++) {
this.addTop(plugins[i]);
}
Expand All @@ -24,6 +25,14 @@ var PluginManager = new Class({
});
},

canSaveForm: function ()
{
if (document.readyState !== 'complete') {
return false;
}
return Fabrik.requestQueue.empty();
},

/**
* @TODO - now only used by element js code - would be nice to remove and use the same code as form/list/validation rule plugins
*/
Expand Down Expand Up @@ -71,6 +80,7 @@ var PluginManager = new Class({
document.id('adminForm').addEvent('click:relay(a.removeButton)', function (event, target) {
event.preventDefault();
this.pluginTotal --;
this.topTotal --;
this.deletePlugin(event);
}.bind(this));
},
Expand All @@ -90,7 +100,9 @@ var PluginManager = new Class({

div.adopt(toggler);
div.inject(document.id('plugins'));
var append = document.id('plugins').getElements('.actionContainer').getLast();
// Ajax request to load the first part of the plugin form (do[plugin] in, on)

var request = new Request.HTML({
url: 'index.php',
data: {
Expand All @@ -100,19 +112,26 @@ var PluginManager = new Class({
'format': 'raw',
'type': this.type,
'plugin': plugin,
'c': this.pluginTotal,
'c': this.topTotal,
'id': this.id
},
append: document.id('plugins').getElements('.actionContainer').getLast(),
append: append,
onSuccess: function (res) {
this.pluginTotal ++;

if (plugin !== '') {
this.addPlugin(plugin);
}
this.accordion.addSection(toggler, div.getElement('.pane-slider'));
}.bind(this)
}.bind(this),
onFailure: function (xhr) {
console.log('fail', xhr);
},
onException: function (headerName, value) {
console.log('excetiprion', headerName, value);
}
});
this.queue.add(request);
this.topTotal ++;
Fabrik.requestQueue.add(request);
},

/**
Expand All @@ -132,14 +151,13 @@ var PluginManager = new Class({

addPlugin: function (plugin, c) {
c = typeOf(c) === 'number' ? c : this.pluginTotal;

if (plugin === '') {
document.id('plugins').getElements('.actionContainer')[c].getElement('.pluginOpts').empty();
return;
}

// Ajax request to load the first part of the plugin form (do[plugin] in, on)
new Request.HTML({
// Ajax request to load the plugin contennt
var request = new Request.HTML({
url: 'index.php',
data: {
'option': 'com_fabrik',
Expand All @@ -150,26 +168,15 @@ var PluginManager = new Class({
'c': c,
'id': this.id
},
update: document.id('plugins').getElements('.actionContainer')[c].getElement('.pluginOpts')
}).send();
update: document.id('plugins').getElements('.actionContainer')[c].getElement('.pluginOpts'),
onComplete: function () {
}.bind(this)
});
this.pluginTotal ++;
Fabrik.requestQueue.add(request);
},

deletePlugin: function (e) {
// decrease the element name counter.
// Otherwise you can loose data on saving (2 validations, delete first - 2nd lost values)
// $$$ hugh - fixing this code
/*
$('plugins').getElements('input, select, textarea').each(function (i) {
var s = i.name.match(/\[[0-9]\]/);
if (s) {
var c = s[0].replace('[', '').replace(']', '').toInt();
if (c > 0) {
c = c - 1;
}
i.name = i.name.replace(/\[[0-9]\]/, '[' + c + ']');
}
});
*/
if (e.target.findClassUp('adminform').id.test(/_\d+$/)) {
var x = e.target.findClassUp('adminform').id.match(/_(\d+)$/)[1].toInt();
document.id('plugins').getElements('input, select, textarea').each(function (i) {
Expand Down
Loading

0 comments on commit 9bbde72

Please sign in to comment.