diff --git a/external/jquery/addons/css/images/alert.png b/external/jquery/addons/css/images/alert.png new file mode 100644 index 0000000000..c37bd062e6 Binary files /dev/null and b/external/jquery/addons/css/images/alert.png differ diff --git a/external/jquery/addons/css/images/error.png b/external/jquery/addons/css/images/error.png new file mode 100644 index 0000000000..94af849e72 Binary files /dev/null and b/external/jquery/addons/css/images/error.png differ diff --git a/external/jquery/addons/css/jquery.stepy.css b/external/jquery/addons/css/jquery.stepy.css new file mode 100644 index 0000000000..23a02887ca --- /dev/null +++ b/external/jquery/addons/css/jquery.stepy.css @@ -0,0 +1,134 @@ +.stepy-header { + margin : 0; + padding : 0; + width : 724px; + margin-left : 0; +} + +.stepy-header li { + color : #DDDDDD; + list-style : none; + cursor : pointer; + float : left; + padding : 10px +} + +.stepy-header li.stepy-error { + background : url('images/error.png') no-repeat right top +} + +.stepy-header li div { + color : #CCC; + font : bold 1.5em verdana; + /*text-shadow : 1px 1px #F8F8F8*/ +} + +.stepy-header li.stepy-active div { + color : #369; + cursor : auto +} + +.stepy-header li span { + color : #CCC; + font : 1.2em verdana +} + +.stepy-header li.stepy-active span { + color : #BBB +} + +.stepy-step { + border : 1px solid #BBB; + clear : left; + padding : 0 20px; + width : 600px; + -khtml-border-radius : 3px; + -moz-border-radius : 3px; + -opera-border-radius : 3px; + -webkit-border-radius : 3px; + border-radius : 3px +} + +.stepy-step legend { + color : #4080BF; + font : bold 1.0em arial; + letter-spacing : .7px; + padding : 0 5px 5px; + width : auto; + margin-bottom : 12px; + border-bottom : 0; +} + +.stepy-step label { + /*color : #222;*/ + display : block; + /*font : bold 1.5em arial;*/ + letter-spacing : .7px; + margin : 10px 0 3px 1px +} + +.stepy-navigator { + height : 33px; + margin-top : 20px +} + +.button-back { + float : left +} + +.finish, +.button-next, +.stepy-navigator input[type="submit"] { + float : right +} + +.button-back, +.button-next, +.stepy-navigator input[type="submit"] { + border : 1px solid #CCC; + color : #7F0055; + cursor : pointer; + font : 1.2em verdana; + padding : 7px 15px 8px; + text-decoration : none; + -khtml-border-radius : 3px; + -moz-border-radius : 3px; + -opera-border-radius : 3px; + -webkit-border-radius : 3px; + border-radius : 3px +} + +.stepy-navigator input[type="submit"] { + background-color : transparent; + border-color : #CCC; + margin-bottom : 0; + padding : 7px 15px 24px; + width : 90px +} + +.button-back:hover, +.button-next:hover, +.stepy-navigator input[type="submit"]:hover { + border-color : #BBB; + color : #B07 +} + +.error-image { + background : url("images/error.png") no-repeat scroll right top transparent; +} + +.error { + background-color : #FAF4F4; +} + +label.error { + background : url("images/alert.png") no-repeat scroll 0 0 transparent; + color : #DE5130; + display : block; + float : right; + font : 10px verdana; + height : 13px; + margin : 3px 3px 0 10px; + padding-left : 21px; + padding-top : 2px; +} diff --git a/external/jquery/addons/js/jquery.stepy.js b/external/jquery/addons/js/jquery.stepy.js new file mode 100644 index 0000000000..4672323dc9 --- /dev/null +++ b/external/jquery/addons/js/jquery.stepy.js @@ -0,0 +1,410 @@ +/*! + * jQuery Stepy - A Wizard Plugin + * -------------------------------------------------------------- + * + * jQuery Stepy is a plugin that generates a customizable wizard. + * + * Licensed under The MIT License + * + * @version 1.1.0 + * @since 2010-07-03 + * @author Washington Botelho + * @documentation wbotelhos.com/stepy + * + * -------------------------------------------------------------- + * + *
+ *
+ * description one + * + *
+ * + *
+ * description two + * + *
+ * + * + *
+ * + * $('form').stepy(); + * + */ + +; +(function ($) { + + var methods = { + init: function (settings) { + return this.each(function () { + methods.destroy.call(this); + + this.opt = $.extend({}, $.fn.stepy.defaults, settings); + + var self = this, + that = $(this), + id = that.attr('id'); + + if (id === undefined || id === '') { + var id = methods._hash.call(self); + + that.attr('id', id); + } + + if (self.opt.validate) { + jQuery.validator.setDefaults({ ignore: self.opt.ignore }); + + that.append('
'); + } + + self.header = methods._header.call(self); + self.steps = that.children('fieldset'); + + self.steps.each(function (index) { + methods._createHead.call(self, this, index); + methods._createButtons.call(self, this, index); + }); + + self.heads = self.header.children('li'); + + self.heads.first().addClass('stepy-active'); + + if (self.opt.finishButton) { + methods._bindFinish.call(self); + } + + if (self.opt.titleClick) { + self.heads.click(function () { + var array = self.heads.filter('.stepy-active').attr('id').split('-'), // TODO: try keep the number in an attribute. + current = parseInt(array[array.length - 1], 10), + clicked = $(this).index(); + + if (clicked > current) { + if (self.opt.next && !methods._execute.call(that, self.opt.next, clicked)) { + return false; + } + } else if (clicked < current) { + if (self.opt.back && !methods._execute.call(that, self.opt.back, clicked)) { + return false; + } + } + + if (clicked != current) { + methods.step.call(self, (clicked) + 1); + } + }); + } else { + self.heads.css('cursor', 'default'); + } + + if (self.opt.enter) { + methods._bindEnter.call(self); + } + + self.steps.first().find(':input:visible:enabled').first().select().focus(); + + that.data({ 'settings': this.opt, 'stepy': true }); + }); + }, _bindEnter: function () { + var self = this; + + self.steps.delegate('input[type="text"], input[type="password"]', 'keypress', function (evt) { + var key = (evt.keyCode ? evt.keyCode : evt.which); + + if (key == 13) { + evt.preventDefault(); + + var buttons = $(this).closest('fieldset').find('.stepy-navigator'); + + if (buttons.length) { + var next = buttons.children('.button-next'); + + if (next.length) { + next.click(); + } else if (self.finish) { + self.finish.click(); + } + } + } + }); + }, _bindFinish: function () { + var self = this, + that = $(this), + finish = $(':submit', that); + + self.finish = (finish.length === 1) ? finish : that.children('.stepy-finish'); + + if (self.finish.length) { + var isForm = that.is('form'), + onSubmit = undefined; + + if (isForm && self.opt.finish) { + onSubmit = that.attr('onsubmit'); + + that.attr('onsubmit', 'return false;'); + } + + self.finish.on('click.stepy', function (evt) { + if (self.opt.finish && !methods._execute.call(that, self.opt.finish, self.steps.length - 1)) { + evt.preventDefault(); + } else if (isForm) { + if (onSubmit) { + that.attr('onsubmit', onSubmit); + } else { + that.removeAttr('onsubmit'); + } + + var isSubmit = self.finish.attr('type') === 'submit'; + + if (!isSubmit && (!self.opt.validate || methods.validate.call(that, self.steps.length - 1))) { + that.submit(); + } + } + }); + + self.steps.last().children('.stepy-navigator').append(self.finish); + } else { + $.error('Submit button or element with class "stepy-finish" missing!'); + } + }, _createBackButton: function (nav, index) { + var self = this, + that = $(this), + attributes = { href: 'javascript:void(0);', 'class': 'button-back '+self.opt.btnClass, html: self.opt.backLabel }; + + $('', attributes).on('click.stepy',function () { + if (!self.opt.back || methods._execute.call(self, self.opt.back, index - 1)) { + methods.step.call(self, (index - 1) + 1); + } + }).appendTo(nav); + }, _createButtons: function (step, index) { + var nav = methods._navigator.call(this).appendTo(step); + + if (index === 0) { + if (this.steps.length > 1) { + methods._createNextButton.call(this, nav, index); + } + } else { + $(step).hide(); + + methods._createBackButton.call(this, nav, index); + + if (index < this.steps.length - 1) { + methods._createNextButton.call(this, nav, index); + } + } + }, _createHead: function (step, index) { + var step = $(step).attr('id', $(this).attr('id') + '-step-' + index).addClass('stepy-step'), + head = methods._head.call(this, index); + + head.append(methods._title.call(this, step)); + + if (this.opt.description) { + head.append(methods._description.call(this, step)); + } + + this.header.append(head); + }, _createNextButton: function (nav, index) { + var self = this, + that = $(this), + attributes = { href: 'javascript:void(0);', 'class': 'button-next '+self.opt.btnClass, html: self.opt.nextLabel }; + + $('', attributes).on('click.stepy',function () { + if (!self.opt.next || methods._execute.call(that, self.opt.next, index + 1)) { + methods.step.call(self, (index + 1) + 1); + } + }).appendTo(nav); + }, _description: function (step) { + var legend = step.children('legend'); + + if (!this.opt.legend) { + legend.hide(); + } + + if (legend.length) { + return $('', { html: legend.html() }); + } + + methods._error.call(this, ' element missing!'); + }, _error: function (message) { + $(this).html(message); + + $.error(message); + }, _execute: function (callback, index) { + var isValid = callback.call(this, index + 1); + + return isValid || isValid === undefined; + }, _hash: function () { + this.hash = 'stepy-' + Math.random().toString().substring(2) + + return this.hash; + }, _head: function (index) { + return $('
  • ', { id: $(this).attr('id') + '-head-' + index }); + }, _header: function () { + var header = $('
  • '; +// } +// if (get_class($this->controls[$name]) == 'pagecontrol' && $rank || $rank == (count($this->controlIdx) - 1)) { + $html .= ''; +// } +// $html .= "\r\n"; $html .= $save; $html .= "\r\n"; return $html; diff --git a/framework/modules/forms/controllers/formsController.php b/framework/modules/forms/controllers/formsController.php index f245548145..434be3095e 100644 --- a/framework/modules/forms/controllers/formsController.php +++ b/framework/modules/forms/controllers/formsController.php @@ -250,6 +250,7 @@ public function enterdata() { if (!empty($f)) { $form = new form(); + $form->id = $f->sef_url; if (!empty($this->params['id'])) { $fc = new forms_control(); $controls = $fc->find('all', 'forms_id=' . $f->id . ' AND is_readonly=0 AND is_static = 0','rank'); @@ -297,6 +298,7 @@ public function enterdata() { $emaillist = array_reverse($emaillist, true); $form->register('email_dest', gt('Send Response to'), new radiogroupcontrol('', $emaillist)); } + $paged = false; foreach ($controls as $c) { // $ctl = unserialize($c->data); $ctl = expUnserialize($c->data); @@ -313,6 +315,7 @@ public function enterdata() { if (!empty($data[$c->name])) $ctl->default = $data[$c->name]; } $form->register($c->name, $c->caption, $ctl); + if (get_class($ctl) == 'pagecontrol') $paged = true; } // if we are editing an existing record we'll need to do recaptcha here since we won't call confirm_data @@ -351,7 +354,7 @@ public function enterdata() { } if (empty($this->config['submitbtn'])) $this->config['submitbtn'] = gt('Submit'); if (empty($this->config['resetbtn'])) $this->config['resetbtn'] = ''; - $form->register("submit", "", new buttongroupcontrol($this->config['submitbtn'], $this->config['resetbtn'], $cancel)); + $form->register("submit", "", new buttongroupcontrol($this->config['submitbtn'], $this->config['resetbtn'], $cancel, 'finish stepy-finish')); $form->meta("m", $this->loc->mod); $form->meta("s", $this->loc->src); @@ -376,6 +379,7 @@ public function enterdata() { "form_html" => $form->toHTML($f->id), "form" => $f, "count" => $count, + 'paged' => $paged, )); } } else { @@ -891,8 +895,12 @@ public function edit_control() { $form->meta('forms_id', $f->id); $types = expTemplate::listControlTypes(); $othertypes = expTemplate::listSimilarControlTypes($control_type); - $otherlist = new dropdowncontrol($control_type,$othertypes); - $form->registerBefore('identifier','control_type',gt('Control Type'),$otherlist); + if (count($othertypes) > 1) { + $otherlist = new dropdowncontrol($control_type,$othertypes); + $form->registerBefore('identifier','control_type',gt('Control Type'),$otherlist); + } else { + $form->registerBefore('identifier','control_type',gt('Control Type'),new genericcontrol('hidden',$control_type)); + } assign_to_template(array( 'form_html' => $form->toHTML($f->id), 'type' => $types[$control_type], diff --git a/framework/modules/forms/definitions/forms_control.php b/framework/modules/forms/definitions/forms_control.php index e282f28885..80ac0c58fd 100644 --- a/framework/modules/forms/definitions/forms_control.php +++ b/framework/modules/forms/definitions/forms_control.php @@ -43,8 +43,6 @@ DB_FIELD_TYPE => DB_DEF_BOOLEAN), 'rank' => array( DB_FIELD_TYPE => DB_DEF_INTEGER), - 'page'=>array( - DB_FIELD_TYPE=>DB_DEF_INTEGER), ); ?> \ No newline at end of file diff --git a/framework/modules/forms/views/forms/edit_control.tpl b/framework/modules/forms/views/forms/edit_control.tpl index 3f76e50e32..0fad32a518 100644 --- a/framework/modules/forms/views/forms/edit_control.tpl +++ b/framework/modules/forms/views/forms/edit_control.tpl @@ -18,7 +18,8 @@

    {if $is_edit == 1}{'Edit Control'|gettext}{else}{'Create a New Control'|gettext}{/if} - {$type}

    {$form_html} - {if $is_edit != 1 && $type != "htmlcontrol"}{br} - ** {'Adding this control will reset the default report to all fields'|gettext} **{/if} + {if $is_edit != 1 && $type != "htmlcontrol" && $type != "pagecontrol"}{br} + ** {'Adding this control will reset the default report to all fields'|gettext} ** + {/if} diff --git a/framework/modules/forms/views/forms/enterdata.tpl b/framework/modules/forms/views/forms/enterdata.tpl index af3811592c..c86209574f 100644 --- a/framework/modules/forms/views/forms/enterdata.tpl +++ b/framework/modules/forms/views/forms/enterdata.tpl @@ -13,6 +13,7 @@ * *} +{uniqueid prepend=$form->sef_url assign="name"} {if !$error} {if $config.style} {css unique="formmod2" corecss="forms2col"} @@ -66,3 +67,30 @@ {/if} + +{*{script unique=jWizard jquery='jqueryui,jquery.jWizard'}*} + {*$("#test").jWizard();*} +{*{/script}*} + +{*{script unique=quickWizard jquery='jqueryui,jquery.validate,jquery.quickWizard'}*} + {*$(document).ready(function() {*} + {*$('#test').quickWizard();*} + {*});*} +{*{/script}*} + +{if $paged} +{script unique=$name jquery='jquery.validate,jquery.stepy'} +{literal} + $("#{/literal}{$form->sef_url}{literal}").stepy({ + validate: true, + block: true, + errorImage: true, + description: false, +// finishButton: false, // otherwise crashes because we can't find submit button + btnClass: 'awesome {/literal}{$smarty.const.BTN_SIZE} {$smarty.const.BTN_COLOR}{literal}', + legend: false, + titleClick: true, + }); +{/literal} +{/script} +{/if}