+
+
Registration
+
Required fields are marked by *
+
+
+
+
+
+
+
Index: branches/1.0.x/inc/js/thickbox/thickbox.css
===================================================================
diff -u
--- branches/1.0.x/inc/js/thickbox/thickbox.css (revision 0)
+++ branches/1.0.x/inc/js/thickbox/thickbox.css (revision 14759)
@@ -0,0 +1,176 @@
+/* ----------------------------------------------------------------------------------------------------------------*/
+/* ---------->>> global settings needed for thickbox <<<-----------------------------------------------------------*/
+/* ----------------------------------------------------------------------------------------------------------------*/
+*{padding: 0; margin: 0;}
+
+/* ----------------------------------------------------------------------------------------------------------------*/
+/* ---------->>> thickbox specific link and font settings <<<------------------------------------------------------*/
+/* ----------------------------------------------------------------------------------------------------------------*/
+/*#TB_window {
+ font: 12px Arial, Helvetica, sans-serif;
+ color: #333333;
+}*/
+
+#TB_secondLine {
+ font: 10px Arial, Helvetica, sans-serif;
+ color:#666666;
+}
+
+#TB_window a:link {color: #666666;}
+#TB_window a:visited {color: #666666;}
+#TB_window a:hover {color: #000;}
+#TB_window a:active {color: #666666;}
+#TB_window a:focus{color: #666666;}
+
+/* ----------------------------------------------------------------------------------------------------------------*/
+/* ---------->>> thickbox settings <<<-----------------------------------------------------------------------------*/
+/* ----------------------------------------------------------------------------------------------------------------*/
+#TB_overlay {
+ position: fixed;
+ z-index:100;
+ top: 0px;
+ left: 0px;
+ height:100%;
+ width:100%;
+}
+
+.TB_overlayMacFFBGHack {background: url(macFFBgHack.png) repeat;}
+.TB_overlayBG {
+ background-color:#000;
+ filter:alpha(opacity=75);
+ -moz-opacity: 0.75;
+ opacity: 0.75;
+}
+
+* html #TB_overlay { /* ie6 hack */
+ position: absolute;
+ height: expression(document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px');
+}
+
+#TB_window {
+ /*position: fixed;*/
+ position: absolute;
+ background-color: #ffffff;
+ z-index: 102;
+ display: none;
+ border: 1px solid #404040;
+ border-radius: 3px;
+ text-align: left;
+ top: 50%;
+ left: 50%;
+ padding: 14px 17px;
+ font-size: 1em;
+}
+
+* html #TB_window { /* ie6 hack */
+position: absolute;
+margin-top: expression(0 - parseInt(this.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px');
+}
+
+#TB_window img#TB_Image {
+ display:block;
+ margin: 15px 0 0 15px;
+ border-right: 1px solid #ccc;
+ border-bottom: 1px solid #ccc;
+ border-top: 1px solid #666;
+ border-left: 1px solid #666;
+}
+
+#TB_caption{
+ height:25px;
+ padding:7px 30px 10px 25px;
+ float:left;
+}
+
+#TB_closeWindow{
+ height:25px;
+ padding:11px 25px 10px 0;
+ float:right;
+}
+
+#TB_closeAjaxWindow{
+ background: url("@templates_base@/img/modal/close.png") no-repeat scroll 100% 0 transparent;
+ color: #5A5A5A;
+ cursor: pointer;
+ font: bold 11px Arial;
+ height: 15px;
+ padding-right: 20px;
+ position: absolute;
+ right: 30px;
+ text-align: right;
+ top: 30px;
+ width: 100px;
+
+}
+
+#TB_ajaxWindowTitle{
+ float:left;
+ padding:7px 0 5px 10px;
+ margin-bottom:1px;
+ font-weight: bold;
+}
+
+#TB_title{
+ background-color:#e8e8e8;
+ height:27px;
+}
+
+#TB_ajaxContent{
+ clear: both;
+ border: 9px solid #E6E6E6;
+ padding: 40px 50px;
+ overflow: auto;
+ text-align: left;
+ line-height: 1.4em;
+}
+
+#TB_ajaxContent.TB_modal{
+ padding:15px;
+}
+
+/*#TB_ajaxContent p{
+ padding:5px 0px 5px 0px;
+}*/
+
+#TB_load{
+ position: fixed;
+ display:none;
+ height:13px;
+ width:208px;
+ z-index:103;
+ top: 50%;
+ left: 50%;
+ margin: -6px 0 0 -104px; /* -height/2 0 0 -width/2 */
+}
+
+* html #TB_load { /* ie6 hack */
+position: absolute;
+margin-top: expression(0 - parseInt(this.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px');
+}
+
+#TB_HideSelect{
+ z-index:99;
+ position:fixed;
+ top: 0;
+ left: 0;
+ background-color:#fff;
+ border:none;
+ filter:alpha(opacity=0);
+ -moz-opacity: 0;
+ opacity: 0;
+ height:100%;
+ width:100%;
+}
+
+* html #TB_HideSelect { /* ie6 hack */
+ position: absolute;
+ height: expression(document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px');
+}
+
+#TB_iframeContent{
+ clear:both;
+ border:none;
+ margin-bottom:-1px;
+ margin-top:1px;
+ _margin-bottom:1px;
+}
Index: branches/1.0.x/inc/js/form_manager.js
===================================================================
diff -u
--- branches/1.0.x/inc/js/form_manager.js (revision 0)
+++ branches/1.0.x/inc/js/form_manager.js (revision 14759)
@@ -0,0 +1,507 @@
+function FormManager() { }
+
+FormManager.init = function ($settings) {
+ $.ajaxSetup( {cache: false} );
+
+ this.url = '';
+ this.fieldMask = '#PREFIX#[#ID#][#FIELD_NAME#]';
+
+ this.noErrorsHTML = ''
+ this.checkTimeout = 1000;
+ this.pendingChecks = {};
+
+ this.fields = {};
+ this.fieldTypes = {};
+ this.forms = {};
+ this.fieldWatermarks = {};
+
+ this.xhrRequests = [];
+
+ $.extend(this, $settings);
+}
+
+FormManager.resetFields = function ($prefix) {
+ this.fields[$prefix] = [];
+}
+
+FormManager.registerField = function ($prefix, $field, $watermark, $field_type) {
+ // fields are registered before form -> store them in separate array
+ if (!this.fields[$prefix]) {
+ this.fields[$prefix] = [];
+ }
+
+ if ($watermark === undefined) {
+ $watermark = '';
+ }
+
+ this.fieldWatermarks[$prefix + '_' + $field] = $watermark;
+
+ this.fields[$prefix].push($field);
+
+ if ($field_type !== undefined) {
+ this.fieldTypes[$prefix + '_' + $field] = $field_type;
+ }
+}
+
+FormManager.getFieldMask = function ($prefix) {
+ return this.fieldMask.replace('#PREFIX#', $prefix).replace('#ID#', this.form_param($prefix, 'id'));
+}
+
+FormManager.getField = function ($prefix, $field, $prepend, $append) {
+ if ($prepend === undefined) {
+ $prepend = '';
+ }
+
+ if ($append === undefined) {
+ $append = '';
+ }
+
+ var $control_id = this.getFieldMask($prefix).replace('#FIELD_NAME#', $field);
+
+ return document.getElementById($prepend + $control_id + $append);
+}
+
+FormManager.getBlurFields = function ($prefix, $field) {
+ var $field_mask = this.getFieldMask($prefix);
+
+ switch ( this.fieldTypes[$prefix + '_' + $field] ) {
+ case 'swf_upload':
+ return this.getField($prefix, $field, undefined, '[tmp_names]');
+ break;
+
+ case 'date':
+ $field += '_date';
+ break;
+
+ case 'radio':
+ return $("input[name='" + jq($field_mask.replace('#FIELD_NAME#', $field)) + "']");
+ break;
+
+ case 'checkbox':
+ return get_control($field_mask, $field, undefined, '_cb');
+ break;
+
+ case 'checkboxes':
+ return $("input[id^='" + jq($field_mask.replace('#FIELD_NAME#', $field)) + "_']");
+ break;
+ }
+
+ return this.getField($prefix, $field);
+}
+
+FormManager.registerForm = function ($settings) {
+ var $defaults = {
+ url: false, // url for form submission
+ prefix: '', // unit prefix, used in the form
+ enabled: true, // form submit enabled
+ enabledTimer: null, // timer that performs form-resubmit countdown
+ save_event: '', // event to use for form data processing
+ id: 0, // id of item being add/edited on a form
+ form_id: '', // form id to work with
+ before_close: '', // before window close callback
+ validation_failure: '', // on validate failure callback
+ immediate_validation: true // perfom validation on blur
+ }
+
+ this.forms[$settings.prefix] = {};
+ $.extend(this.forms[$settings.prefix], $defaults, $settings);
+
+ // when form is registred, then all it's fields should also be registred
+
+ if ( !this.form_param($settings.prefix, 'immediate_validation') ) {
+ return ;
+ }
+
+ var $me = this;
+
+ $( this.fields[$settings.prefix] ).each(
+ function () {
+ $( $me.getBlurFields($settings.prefix, this) ).blur(
+ function ($e) {
+ $me.checkField(this);
+ }
+ );
+ }
+ );
+
+ $('input[title], select[title], textarea[title]', '#' + this.forms[$settings.prefix].form_id).qtip(
+ {
+ style: {
+ classes: 'ui-tooltip-light ui-tooltip-shadow'
+ },
+ position: {
+ my: 'left center',
+ at: 'right center'
+ },
+ show: {
+ event: 'focus'
+ }
+ }
+ );
+
+ $('img.help-icon', '#' + this.forms[$settings.prefix].form_id ).qtip(
+ {
+ style: {
+ classes: 'ui-tooltip-light ui-tooltip-shadow'
+ },
+ position: {
+ my: 'bottom left',
+ at: 'top center'
+ }
+ }
+ );
+}
+
+FormManager.getURL = function ($prefix, $template, $event, $params) {
+ var $url = this.form_param($prefix, 'url');
+
+ if (!$url) {
+ $url = this.url;
+ }
+
+ if ($template === undefined) {
+ $template = '';
+ }
+
+ $url = $url.replace('#TEMPLATE#', $template);
+
+ if ($event !== undefined) {
+ $url += ($url.indexOf('?') == -1 ? '?' : '&') + 'events[' + $prefix + ']=' + $event;
+ }
+
+ if ( typeof($params) == 'object' ) {
+ for (key in $params) {
+ $url += ($url.indexOf('?') == -1 ? '?' : '&') + key + '=' + $params[key];
+ }
+ }
+
+ return $url;
+}
+
+FormManager.processResponse = function ($prefix, $data, $add_params) {
+ // enable form back
+// alert('enabling for for [' + $prefix + '] in processResponse');
+
+ if ( $add_params !== undefined ) {
+ $add_params.response = $data;
+ }
+ else {
+ $add_params = {response: $data};
+ }
+
+ this.clearErrors($prefix);
+
+ if ($data.status == 'OK') {
+ var $next_template = this.getNextTemplate($prefix, $data);
+
+ if ( $next_template || $data.do_refresh ) {
+ var $before_close = this.getFormParamOverride($prefix, 'before_close', $add_params);
+
+ if ( $.isFunction($before_close) ) {
+ $before_close.call(this, $data, $add_params);
+ }
+
+ if ( $next_template ) {
+ // load another template instead of current form
+ $('#TB_ajaxContent').html('').load( this.getURL($prefix, $next_template, undefined, $data.params) );
+ }
+ else if ( $data.do_refresh ) {
+ // refresh whole page
+ window.location.href = window.location.href;
+ }
+ }
+ else {
+ // close form without refreshing the page
+ this.closeForm($prefix, $data, $add_params);
+ }
+ }
+ else {
+ // set new errors
+ for ($field in $data.field_errors) {
+ this.setFieldStatus($prefix, $field, $data.field_errors[$field]);
+ }
+
+ var $validation_failure = this.form_param($prefix, 'validation_failure');
+
+ if ( $.isFunction($validation_failure) ) {
+ $validation_failure.call(this, $data, $add_params);
+ }
+ }
+
+ this.enableForm($prefix, true);
+
+// var $me = this;
+// setTimeout(function () { $me.enableForm($prefix, true); }, 1000);
+}
+
+/**
+ * Clear errors from all from fields
+ *
+ * @param $prefix
+ */
+FormManager.clearErrors = function ($prefix) {
+ var $fields = this.fields[$prefix];
+
+ if (typeof($fields) == 'undefined') {
+ $fields = [];
+ }
+
+ for (var $i = 0; $i < $fields.length; $i++) {
+ this.setFieldStatus($prefix, $fields[$i]);
+ }
+}
+
+FormManager.getNextTemplate = function ($prefix, $responce) {
+ if ( $responce.next_template && $responce.next_template != '' ) {
+ return $responce.next_template;
+ }
+ else if ( this.form_param($prefix, 'next_template') ) {
+ return this.form_param($prefix, 'next_template');
+ }
+
+ return false;
+}
+
+FormManager.setFieldStatus = function ($prefix, $field_name, $error_msg) {
+ var field_cell = this.getField($prefix, $field_name, undefined, '_field_cell');
+ var status_cell = this.getField($prefix, $field_name, undefined, '_status_cell');
+
+ if (!field_cell) {
+ alert('Error field "' + $field_name + '" missing.');
+ return ;
+ }
+
+ if ($error_msg === undefined || !$error_msg) {
+ // show OK
+ $(field_cell).parents('p:first').removeClass('error'); //.addClass('ok');
+ $(status_cell)/*.removeClass('field-error')*/.html(this.noErrorsHTML);
+
+ var $fields = this.fields[$prefix];
+
+ for (var $i = 0; $i < $fields.length; $i++) {
+ if ( this.fieldHasError($prefix, $fields[$i]) ) {
+ return ;
+ }
+ }
+ }
+ else {
+ // show error message
+ $(field_cell).parents('p:first')/*.removeClass('ok')*/.addClass('error');
+ $(status_cell)/*.addClass('field-error')*/.html($error_msg);
+ }
+}
+
+FormManager.fieldHasError = function ($prefix, $field) {
+ var status_cell = this.getField($prefix, $field, undefined, '_status_cell');
+
+ return $.trim( $(status_cell).html() ) != $.trim( this.noErrorsHTML );
+}
+
+FormManager.checkField = function ($input, $delayed) {
+ if ( !$input.id.match(/^(.*?)\[.*?\]\[(.*?)\].*?$/) ) {
+ return ;
+ }
+
+ var $prefix = RegExp.$1;
+ var $field = RegExp.$2.replace(/(_date|_time)$/, '');
+
+ if ( this.pendingChecks[$field] ) {
+ clearTimeout( this.pendingChecks[$field] );
+ delete this.pendingChecks[$field];
+ }
+
+ var $me = this;
+
+ this.pendingChecks[$field] = setTimeout(
+ function () {
+ $me.validateField($prefix, $field, $input)
+ },
+ ($delayed === true ? this.checkTimeout : 0)
+ );
+}
+
+FormManager.validateField = function ($prefix, $field, $input) {
+ var $me = this;
+ var form = document.getElementById( this.form_param($prefix, 'form_id') );
+
+ var $request = $.post(
+ this.getURL($prefix, undefined, 'OnValidateField') + '&field=' + encodeURIComponent($field) + '&' + $input.name + '=' + encodeURIComponent($input.value),
+ $(form).serialize(),
+ function ($data) {
+ $data = eval('(' + $data + ')');
+ $me.setFieldStatus($prefix, $field, $data.status == 'OK' ? undefined : $data.status);
+ }
+ );
+
+ this.xhrRequests.push($request);
+};
+
+FormManager.form_param = function ($prefix, $param, $value) {
+ if ($value === undefined) {
+ return this.forms[$prefix][$param];
+ }
+
+ this.forms[$prefix][$param] = $value;
+}
+
+FormManager.getFormParamOverride = function ($prefix, $param, $overrides) {
+ if ( $overrides[$param] !== undefined ) {
+ return $overrides[$param];
+ }
+
+ return this.form_param($prefix, $param);
+}
+
+/* === related to form opening/closing/submitting === */
+FormManager.openForm = function ($prefix, $template, $width, $height, $source_form, $params) {
+ var $url = this.getURL($prefix, $template, undefined, $params);
+
+ $url += ($url.indexOf('?') == -1 ? '?' : '&') + 'width=' + $width + '&height=' + $height + '&modal=true';
+
+ var $tb_settings = {url: $url};
+
+ if ($source_form !== undefined) {
+ $tb_settings.postParams = $($source_form).serialize();
+ }
+
+ TB.show($tb_settings);
+}
+
+FormManager.validateAll = function ($prefix, $status) {
+ var $fields = this.fields[$prefix];
+
+ for (var $i = 0; $i < $fields.length; $i++) {
+ this.setFieldStatus($prefix, $fields[$i], $status);
+ }
+}
+
+FormManager.closeForm = function ($prefix, $data, $add_params) {
+ if ( $data === undefined ) {
+ $data = {};
+ }
+
+ if ( $add_params === undefined ) {
+ $add_params = {};
+ }
+
+ var $before_close = this.getFormParamOverride($prefix, 'before_close', $add_params);
+
+ this.cancelXHRRequests();
+ this.validateAll($prefix);
+
+ if ( $.isFunction($before_close) ) {
+ var $result = $before_close.call(this, $data, $add_params);
+
+ if ($result === false) {
+ return;
+ }
+ }
+
+ TB.remove();
+}
+
+FormManager._getFormFields = function ($prefix) {
+ var $fields = this.fields[$prefix];
+
+ if (typeof($fields) == 'undefined') {
+ $fields = [];
+ }
+
+ // remove watermakrs from input fields
+ for (var $i = 0; $i < $fields.length; $i++) {
+ var $control = this.getField($prefix, $fields[$i]);
+ var $watermark = this.fieldWatermarks[ $prefix + '_' + $fields[$i] ];
+
+ if ($control && $watermark !== undefined && $control.value == $watermark) {
+ $control.value = '';
+ }
+ }
+
+ var form = document.getElementById( this.form_param($prefix, 'form_id') );
+ var $form_fields = $(form).serialize();
+
+ // restore watermarks in input fields
+ for (var $i = 0; $i < $fields.length; $i++) {
+ var $control = this.getField($prefix, $fields[$i]);
+ var $watermark = this.fieldWatermarks[$prefix + '_' + $fields[$i]];
+
+ if ($control && $watermark !== undefined && !$control.value) {
+ $control.value = $watermark;
+ }
+ }
+
+ return $form_fields;
+}
+
+FormManager.enableForm = function ($prefix, $enabled) {
+ if ($enabled === undefined) {
+ $enabled = true;
+ }
+
+ if ($enabled) {
+ clearTimeout( this.form_param($prefix, 'enabledTimer') );
+ this.form_param($prefix, 'enabledTimer', null);
+ }
+ else {
+ var $me = this;
+
+ // set timer for 10 seconds to enable form back (just in case if ajax responce fails)
+ var $timer = setTimeout(
+ function () {
+// alert('enabling for for [' + $prefix + '] in setTimeout');
+ $me.enableForm($prefix, true);
+ }
+ , 10000
+ );
+
+ this.form_param($prefix, 'enabledTimer', $timer);
+ }
+
+ this.form_param($prefix, 'enabled', $enabled);
+}
+
+FormManager.cancelXHRRequests = function () {
+ while ( this.xhrRequests.length > 0 ) {
+ this.xhrRequests.shift().abort();
+ }
+}
+
+FormManager.submitForm = function ($prefix, $add_params) {
+ if ( !this.form_param($prefix, 'enabled') ) {
+ return ;
+ }
+
+ // disable form
+ this.enableForm($prefix, false);
+
+ var $me = this;
+ this.cancelXHRRequests();
+
+ $.post(
+ this.getURL( $prefix, '', this.form_param($prefix, 'save_event') ),
+ this._getFormFields($prefix),
+ function ($data) {
+ var $redirect = TB.parseRedirect($data);
+
+ if ( $redirect !== false ) {
+ window.location.href = $redirect;
+
+ return ;
+ }
+
+ $me.processResponse($prefix, eval('(' + $data + ')'), $add_params);
+ }
+ )
+}
+
+FormManager.beforeClose = function () {
+ this.cancelXHRRequests();
+
+ for (var $prefix in this.forms) {
+ var $before_close = this.form_param($prefix, 'before_close');
+
+ if ( $.isFunction($before_close) ) {
+ $before_close.call(this, {}, {});
+ }
+ }
+}
\ No newline at end of file
Index: branches/1.0.x/elements/forms.elm.tpl
===================================================================
diff -u
--- branches/1.0.x/elements/forms.elm.tpl (revision 0)
+++ branches/1.0.x/elements/forms.elm.tpl (revision 14759)
@@ -0,0 +1,386 @@
+