[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [15850] Stable: Merge 15819:15849 from trunk
From: |
sigurdne |
Subject: |
[Fmsystem-commits] [15850] Stable: Merge 15819:15849 from trunk |
Date: |
Tue, 18 Oct 2016 08:17:04 +0000 (UTC) |
Revision: 15850
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15850
Author: sigurdne
Date: 2016-10-18 08:17:04 +0000 (Tue, 18 Oct 2016)
Log Message:
-----------
Stable: Merge 15819:15849 from trunk
Modified Paths:
--------------
branches/Version-2_0-branch/activitycalendarfrontend/setup/setup.inc.php
branches/Version-2_0-branch/activitycalendarfrontend/templates/base/config.tpl
branches/Version-2_0-branch/admin/inc/class.ui_custom.inc.php
branches/Version-2_0-branch/admin/templates/base/custom.xsl
branches/Version-2_0-branch/booking/inc/class.custom_fields.inc.php
branches/Version-2_0-branch/booking/inc/class.soapplication.inc.php
branches/Version-2_0-branch/bookingfrontend/setup/setup.inc.php
branches/Version-2_0-branch/bookingfrontend/templates/base/config.tpl
branches/Version-2_0-branch/mobilefrontend/inc/class.hook_helper.inc.php
branches/Version-2_0-branch/mobilefrontend/setup/setup.inc.php
branches/Version-2_0-branch/mobilefrontend/templates/base/config.tpl
branches/Version-2_0-branch/phpgwapi/inc/class.custom_fields.inc.php
branches/Version-2_0-branch/phpgwapi/inc/class.db_pdo.inc.php
branches/Version-2_0-branch/phpgwapi/inc/class.schema_proc_pgsql.inc.php
branches/Version-2_0-branch/phpgwapi/inc/class.sessions.inc.php
branches/Version-2_0-branch/phpgwapi/inc/class.socommon.inc.php
branches/Version-2_0-branch/phpgwapi/inc/model/class.model.inc.php
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/brazil.js
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/date.js
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/file.js
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/html5.js
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/jquery.form-validator.js
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/jquery.form-validator.min.js
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/jsconf.js
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/lang/de.js
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/lang/es.js
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/lang/fr.js
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/lang/it.js
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/lang/no.js
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/lang/pl.js
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/lang/pt.js
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/lang/ro.js
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/lang/ru.js
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/lang/sv.js
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/location.js
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/sanitize.js
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/security.js
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/sweden.js
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/theme-default.css
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/toggleDisabled.js
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/uk.js
branches/Version-2_0-branch/phpgwapi/templates/base/datatable_jquery.xsl
branches/Version-2_0-branch/property/inc/class.bocommon.inc.php
branches/Version-2_0-branch/property/inc/class.socommon.inc.php
branches/Version-2_0-branch/property/inc/class.sogeneric_.inc.php
branches/Version-2_0-branch/property/inc/class.soproject.inc.php
branches/Version-2_0-branch/property/inc/class.uitts.inc.php
branches/Version-2_0-branch/property/inc/cron/default/reset_workorder_cached_budget.php
branches/Version-2_0-branch/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php
branches/Version-2_0-branch/property/inc/custom/default/BkBygg_exporter_data_til_Agresso.php
branches/Version-2_0-branch/property/js/portico/invoice2.index.js
branches/Version-2_0-branch/property/js/portico/tts.view.js
branches/Version-2_0-branch/property/setup/tables_current.inc.php
branches/Version-2_0-branch/property/setup/tables_update.inc.php
branches/Version-2_0-branch/property/templates/base/admin_entity.xsl
branches/Version-2_0-branch/rental/inc/class.socomposite.inc.php
branches/Version-2_0-branch/rental/inc/class.socontract_price_item.inc.php
branches/Version-2_0-branch/rental/inc/class.soprice_item.inc.php
branches/Version-2_0-branch/rental/inc/class.uicomposite.inc.php
branches/Version-2_0-branch/rental/inc/class.uicontract.inc.php
branches/Version-2_0-branch/rental/inc/model/class.composite.inc.php
branches/Version-2_0-branch/rental/setup/phpgw_no.lang
branches/Version-2_0-branch/rental/setup/setup.inc.php
branches/Version-2_0-branch/rental/setup/tables_current.inc.php
branches/Version-2_0-branch/rental/setup/tables_update.inc.php
branches/Version-2_0-branch/rental/templates/base/composite.xsl
Added Paths:
-----------
branches/Version-2_0-branch/activitycalendarfrontend/inc/class.hook_helper.inc.php
branches/Version-2_0-branch/admin/js/base/ui_custom.list_attribute_group.js
branches/Version-2_0-branch/bookingfrontend/inc/class.hook_helper.inc.php
branches/Version-2_0-branch/eventplanner/
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/lang/ca.js
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/lang/cs.js
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/lang/da.js
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/lang/nl.js
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/lang/vi.js
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/logic.js
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/poland.js
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/sepa.js
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/theme-default.min.css
Property Changed:
----------------
branches/Version-2_0-branch/
branches/Version-2_0-branch/booking/
branches/Version-2_0-branch/bookingfrontend/
Property changes on: branches/Version-2_0-branch
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/dev-syncromind:13653
/branches/dev-syncromind-2:14933-15747
/branches/stavangerkommune:12743-12875,12986
/trunk:14721-14732,14734-14735,14737,14739,14741,14743-14744,14746-14749,14751,14753,14755-14757,14759,14761-14764,14766-14768,14770-14783,14785-14792,14794-14813,14815-14816,14818,14820-14822,14824-14825,14827-14829,14831-14834,14836,14838,14840-14842,14844-14845,14847,14849-14866,14868-14869,14871,14873-14875,14877-14878,14880-14884,14886-14896,14898,14900-14902,14904,14906-14909,14911-14915,14917-14919,14921-14922,14924-14978,14980-15258,15260-15261,15263-15264,15266-15285,15287-15288,15290-15291,15293,15295,15297,15299-15305,15307-15310,15312-15335,15337-15352,15354,15356,15358,15360-15541,15543-15566,15568-15569,15571,15573-15581,15583,15585-15617,15619,15621-15630,15632-15635,15637-15639,15641-15643,15645,15647-15665,15667-15668,15670-15671,15673-15693,15695-15712,15714-15764,15766-15767,15769-15787,15789-15802,15804-15811,15813-15814,15816-15818
+ /branches/dev-syncromind:13653
/branches/dev-syncromind-2:14933-15747
/branches/stavangerkommune:12743-12875,12986
/trunk:14721-14732,14734-14735,14737,14739,14741,14743-14744,14746-14749,14751,14753,14755-14757,14759,14761-14764,14766-14768,14770-14783,14785-14792,14794-14813,14815-14816,14818,14820-14822,14824-14825,14827-14829,14831-14834,14836,14838,14840-14842,14844-14845,14847,14849-14866,14868-14869,14871,14873-14875,14877-14878,14880-14884,14886-14896,14898,14900-14902,14904,14906-14909,14911-14915,14917-14919,14921-14922,14924-14978,14980-15258,15260-15261,15263-15264,15266-15285,15287-15288,15290-15291,15293,15295,15297,15299-15305,15307-15310,15312-15335,15337-15352,15354,15356,15358,15360-15541,15543-15566,15568-15569,15571,15573-15581,15583,15585-15617,15619,15621-15630,15632-15635,15637-15639,15641-15643,15645,15647-15665,15667-15668,15670-15671,15673-15693,15695-15712,15714-15764,15766-15767,15769-15787,15789-15802,15804-15811,15813-15814,15816-15818,15820-15849
Copied:
branches/Version-2_0-branch/activitycalendarfrontend/inc/class.hook_helper.inc.php
(from rev 15849, trunk/activitycalendarfrontend/inc/class.hook_helper.inc.php)
===================================================================
---
branches/Version-2_0-branch/activitycalendarfrontend/inc/class.hook_helper.inc.php
(rev 0)
+++
branches/Version-2_0-branch/activitycalendarfrontend/inc/class.hook_helper.inc.php
2016-10-18 08:17:04 UTC (rev 15850)
@@ -0,0 +1,52 @@
+<?php
+ /**
+ * Activitycalendarfrontend - Hook helper
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2013 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @package Property
+ * @version $Id: class.hook_helper.inc.php 14728 2016-02-11 22:28:46Z
sigurdne $
+ */
+ /*
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+ /**
+ * Hook helper
+ *
+ * @package Activitycalendar
+ */
+ class activitycalendarfrontend_hook_helper
+ {
+
+ public function set_cookie_domain()
+ {
+ $script_path =
dirname(phpgw::get_var('SCRIPT_FILENAME', 'string', 'SERVER'));
+
+ if(preg_match('/activitycalendarfrontend/',
$script_path))
+ {
+ //get from local config
+ $config = CreateObject('phpgwapi.config',
'activitycalendarfrontend');
+ $config->read();
+
+
$GLOBALS['phpgw_info']['server']['cookie_domain'] =
!empty($GLOBALS['phpgw_info']['server']['cookie_domain']) ?
$GLOBALS['phpgw_info']['server']['cookie_domain'] : '';
+
+ if
(!empty($config->config_data['cookie_domain']))
+ {
+
$GLOBALS['phpgw_info']['server']['cookie_domain'] =
$config->config_data['cookie_domain'];
+ }
+ }
+ }
+ }
\ No newline at end of file
Modified:
branches/Version-2_0-branch/activitycalendarfrontend/setup/setup.inc.php
===================================================================
--- branches/Version-2_0-branch/activitycalendarfrontend/setup/setup.inc.php
2016-10-18 02:30:07 UTC (rev 15849)
+++ branches/Version-2_0-branch/activitycalendarfrontend/setup/setup.inc.php
2016-10-18 08:17:04 UTC (rev 15850)
@@ -39,5 +39,6 @@
$setup_info['activitycalendarfrontend']['hooks'] = array
(
'menu' => 'activitycalendarfrontend.menu.get_menu',
+ 'set_cookie_domain' =>
'activitycalendarfrontend.hook_helper.set_cookie_domain',
'config'
);
Modified:
branches/Version-2_0-branch/activitycalendarfrontend/templates/base/config.tpl
===================================================================
---
branches/Version-2_0-branch/activitycalendarfrontend/templates/base/config.tpl
2016-10-18 02:30:07 UTC (rev 15849)
+++
branches/Version-2_0-branch/activitycalendarfrontend/templates/base/config.tpl
2016-10-18 08:17:04 UTC (rev 15850)
@@ -14,22 +14,26 @@
<tr bgcolor="{row_off}">
<td colspan="2"><b>{Registration_settings}</b></td>
</tr>
- <tr bgcolor="{row_on}">
+ <tr class="row_on">
+
<td>{lang_cookie_domain_for_sessions_-_if_Same_as_framework_leave_empty}</td>
+ <td><input name="newsettings[cookie_domain]"
value="{value_cookie_domain}"></td>
+ </tr>
+ <tr bgcolor="{row_off}">
<td>{lang_ajaxURL}:</td>
<td><input name="newsettings[AJAXURL]"
value="{value_AJAXURL}"></td>
</tr>
- <tr bgcolor="{row_off}">
+ <tr bgcolor="{row_on}">
<td colspan="2"> </td>
</tr>
- <tr bgcolor="{row_on}">
+ <tr bgcolor="{row_off}">
<td>{lang_Anonymous_user}:</td>
<td><input name="newsettings[anonymous_user]"
value="{value_anonymous_user}"></td>
</tr>
- <tr bgcolor="{row_off}">
+ <tr bgcolor="{row_on}">
<td>{lang_Anonymous_password}:</td>
<td><input type="password"
name="newsettings[anonymous_passwd]" value="{value_anonymous_passwd}"></td>
</tr>
- <tr bgcolor="{row_on}">
+ <tr bgcolor="{row_off}">
<td>{lang_allow_test_for_sql_injection}:</td>
<td>
<select name="newsettings[allow_test]">
Modified: branches/Version-2_0-branch/admin/inc/class.ui_custom.inc.php
===================================================================
--- branches/Version-2_0-branch/admin/inc/class.ui_custom.inc.php
2016-10-18 02:30:07 UTC (rev 15849)
+++ branches/Version-2_0-branch/admin/inc/class.ui_custom.inc.php
2016-10-18 08:17:04 UTC (rev 15850)
@@ -921,17 +921,11 @@
'text' =>
lang('location'),
'list' =>
$location_list,
),
- array
- (
- 'type' =>
'link',
- 'value' =>
lang('new'),
- 'href' =>
self::link(array(
-
'menuaction' => 'admin.ui_custom.edit_attrib_group',
-
'appname' => $this->appname,
-
'menu_selection' => $this->menu_selection
- )),
- 'class' =>
'new_item'
- ),
+ array('type' =>
'hidden',
+ 'id' =>
'appname',
+ 'name' =>
'appname',
+ 'value' =>
$this->appname,
+ )
)
)
),
@@ -942,6 +936,10 @@
'phpgw_return_as' =>
'json'
)),
'allrows' => true,
+ 'new_item' => array('onclick' =>
'onNew_group()'),/*self::link(array(
+
'menuaction' => 'admin.ui_custom.edit_attrib_group',
+
'appname' => $this->appname,
+
'menu_selection' => $this->menu_selection)),*/
'editor_action' => '',
'field' => array(
array(
@@ -960,7 +958,7 @@
'sortable' => true
),
array(
- 'key' =>
'text',
+ 'key' =>
'descr',
'label' =>
lang('Descr'),
'sortable' =>
false
),
@@ -1104,6 +1102,8 @@
unset($parameters);
unset($parameters2);
+ self::add_javascript('admin', 'base',
'ui_custom.list_attribute_group.js');
+
self::render_template_xsl('datatable_jquery', $data);
}
Copied:
branches/Version-2_0-branch/admin/js/base/ui_custom.list_attribute_group.js
(from rev 15849, trunk/admin/js/base/ui_custom.list_attribute_group.js)
===================================================================
--- branches/Version-2_0-branch/admin/js/base/ui_custom.list_attribute_group.js
(rev 0)
+++ branches/Version-2_0-branch/admin/js/base/ui_custom.list_attribute_group.js
2016-10-18 08:17:04 UTC (rev 15850)
@@ -0,0 +1,11 @@
+function onNew_group()
+{
+ var oArgs = {
+ menuaction: 'admin.ui_custom.edit_attrib_group',
+ appname: document.getElementById('appname').value,
+ location: document.getElementById('location').value
+ };
+ var sUrl = phpGWLink('index.php', oArgs);
+ window.location = sUrl;
+}
+
Modified: branches/Version-2_0-branch/admin/templates/base/custom.xsl
===================================================================
--- branches/Version-2_0-branch/admin/templates/base/custom.xsl 2016-10-18
02:30:07 UTC (rev 15849)
+++ branches/Version-2_0-branch/admin/templates/base/custom.xsl 2016-10-18
08:17:04 UTC (rev 15850)
@@ -298,7 +298,7 @@
<xsl:value-of
select="php:function('lang', 'input text')" />
</td>
<td>
- <input type="text"
name="values[input_text]" value="{value_input_text}" maxlength="20">
+ <input type="text"
name="values[input_text]" value="{value_input_text}" maxlength="200">
<xsl:attribute
name="title">
<xsl:value-of
select="php:function('lang', 'enter the input text for records')" />
</xsl:attribute>
@@ -570,12 +570,12 @@
<xsl:value-of
select="php:function('lang', 'get single function input')"/>
</td>
<td>
- <textarea cols="60"
rows="10" name="values[get_single_function_input]">
- <xsl:attribute
name="title">
-
<xsl:text>parameter1 = value1, parameter2 = value2...</xsl:text>
- </xsl:attribute>
- <xsl:value-of
select="value_get_single_function_input"/>
- </textarea>
+ <textarea
cols="60" rows="10" name="values[get_single_function_input]">
+
<xsl:attribute name="title">
+
<xsl:text>parameter1 = value1, parameter2 = value2...</xsl:text>
+
</xsl:attribute>
+
<xsl:value-of select="value_get_single_function_input"/>
+ </textarea>
</td>
</tr>
</xsl:when>
@@ -1172,82 +1172,72 @@
</xsl:template>
<xsl:template name="choice" xmlns:php="http://php.net/xsl">
- <table cellpadding="2" cellspacing="2" width="80%" align="left">
- <xsl:choose>
- <xsl:when test="value_choice!=''">
- <tr class="th">
- <td class="th_text" width="5%"
align="left">
- <xsl:value-of
select="php:function('lang', 'id')" />
- </td>
- <td class="th_text" width="40%"
align="left">
- <xsl:value-of
select="php:function('lang', 'value')" />
- </td>
- <td class="th_text" width="40%"
align="left">
- <xsl:value-of
select="php:function('lang', 'title')" />
- </td>
- <td class="th_text" width="5%"
align="left">
- <xsl:value-of
select="php:function('lang', 'order')" />
- </td>
- <td class="th_text" width="10%"
align="center">
- <xsl:value-of
select="lang_delete_value"/>
- </td>
- </tr>
- <xsl:for-each select="value_choice" >
- <tr>
- <xsl:attribute name="class">
- <xsl:choose>
- <xsl:when
test="@class">
-
<xsl:value-of select="@class"/>
- </xsl:when>
- <xsl:when
test="position() mod 2 = 0">
-
<xsl:text>row_off</xsl:text>
- </xsl:when>
- <xsl:otherwise>
-
<xsl:text>row_on</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
+ <table class="pure-table pure-table-bordered" border="0"
cellspacing="2" cellpadding="2">
+ <thead>
+ <tr>
+ <th width="5%" align="left">
+ <xsl:value-of
select="php:function('lang', 'id')" />
+ </th>
+ <th width="40%" align="left">
+ <xsl:value-of
select="php:function('lang', 'value')" />
+ </th>
+ <th width="40%" align="left">
+ <xsl:value-of
select="php:function('lang', 'title')" />
+ </th>
+ <th width="5%" align="left">
+ <xsl:value-of
select="php:function('lang', 'order')" />
+ </th>
+ <th width="10%" align="center">
+ <xsl:value-of
select="lang_delete_value"/>
+ </th>
+ </tr>
+ </thead>
+ <xsl:for-each select="value_choice" >
+ <tr>
+ <xsl:attribute name="class">
+ <xsl:choose>
+ <xsl:when test="@class">
+ <xsl:value-of
select="@class"/>
+ </xsl:when>
+ <xsl:when test="position() mod
2 != 0">
+
<xsl:text>pure-table-odd</xsl:text>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:attribute>
+ <td align="left">
+ <xsl:value-of select="id"/>
+ </td>
+ <td align="left">
+ <input type="textbox"
name="values[edit_choice][{id}]" value="{value}" size='15'>
+ <xsl:attribute name="title">
+ <xsl:value-of
select="php:function('lang', 'value')" />
</xsl:attribute>
- <td align="left">
- <xsl:value-of
select="id"/>
- </td>
- <td align="left">
- <input type="textbox"
name="values[edit_choice][{id}]" value="{value}" size='15'>
- <xsl:attribute
name="title">
-
<xsl:value-of select="php:function('lang', 'value')" />
- </xsl:attribute>
- </input>
- </td>
- <td align="left">
- <input type="textbox"
name="values[title_choice][{id}]" value="{title}" size='15'>
- <xsl:attribute
name="title">
-
<xsl:value-of select="php:function('lang', 'value')" />
- </xsl:attribute>
- </input>
- </td>
- <td align="center">
- <input type="textbox"
name="values[order_choice][{id}]" value="{order}" size='4'>
- <xsl:attribute
name="title">
-
<xsl:value-of select="php:function('lang', 'order')" />
- </xsl:attribute>
- </input>
- </td>
- <td align="center">
- <input type="checkbox"
name="values[delete_choice][]" value="{id}">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
-
<xsl:value-of select="//lang_delete_choice_statustext"/>
-
<xsl:text>'; return true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- </tr>
- </xsl:for-each>
- </xsl:when>
- </xsl:choose>
+ </input>
+ </td>
+ <td align="left">
+ <input type="textbox"
name="values[title_choice][{id}]" value="{title}" size='15'>
+ <xsl:attribute name="title">
+ <xsl:value-of
select="php:function('lang', 'value')" />
+ </xsl:attribute>
+ </input>
+ </td>
+ <td align="center">
+ <input type="textbox"
name="values[order_choice][{id}]" value="{order}" size='4'>
+ <xsl:attribute name="title">
+ <xsl:value-of
select="php:function('lang', 'order')" />
+ </xsl:attribute>
+ </input>
+ </td>
+ <td align="center">
+ <input type="checkbox"
name="values[delete_choice][]" value="{id}">
+ <xsl:attribute name="title">
+ <xsl:value-of
select="//lang_delete_choice_statustext"/>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+ </xsl:for-each>
<tr>
- <td valign="top" colspan='2'>
- <xsl:value-of select="lang_new_value"/>
- </td>
<td valign="top">
<input type="text" name="values[new_choice_id]"
size = '3'>
<xsl:attribute name="title">
@@ -1256,14 +1246,23 @@
</input>
</td>
<td valign="top">
- <input type="text" name="values[new_choice]"
onMouseout="window.status='';return true;">
- <xsl:attribute name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
+ <input type="text" name="values[new_choice]">
+ <xsl:attribute name="title">
<xsl:value-of
select="lang_new_value_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
</xsl:attribute>
</input>
</td>
+ <td valign="top">
+ <input type="text"
name="values[new_title_choice]">
+ <xsl:attribute name="title">
+ <xsl:value-of
select="php:function('lang', 'title')" />
+ </xsl:attribute>
+ </input>
+ </td>
+ <td>
+ </td>
+ <td>
+ </td>
</tr>
</table>
</xsl:template>
Property changes on: branches/Version-2_0-branch/booking
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/dev-syncromind-2/booking:14933-15747
/branches/stavangerkommune/booking:9468-12740,12743-12875,12986
/trunk/booking:14721-14732,14824-14825,14827-14829,14831-14834,14836,14838,14840-14842,14844-14845,14871,14886-14896,14900-14902,14917-14919,14924-14978,14980-15258,15266-15285,15287-15288,15297,15299-15305,15307-15310,15312-15335,15337-15352,15354,15360-15541,15543-15566,15568-15569,15585-15617,15621-15630,15637-15639,15641-15643,15645,15647-15665,15667-15668,15695-15712,15714-15764
+ /branches/dev-syncromind-2/booking:14933-15747
/branches/stavangerkommune/booking:9468-12740,12743-12875,12986
/trunk/booking:14721-14732,14824-14825,14827-14829,14831-14834,14836,14838,14840-14842,14844-14845,14871,14886-14896,14900-14902,14917-14919,14924-14978,14980-15258,15266-15285,15287-15288,15297,15299-15305,15307-15310,15312-15335,15337-15352,15354,15360-15541,15543-15566,15568-15569,15585-15617,15621-15630,15637-15639,15641-15643,15645,15647-15665,15667-15668,15695-15712,15714-15764,15820-15849
Modified: branches/Version-2_0-branch/booking/inc/class.custom_fields.inc.php
===================================================================
--- branches/Version-2_0-branch/booking/inc/class.custom_fields.inc.php
2016-10-18 02:30:07 UTC (rev 15849)
+++ branches/Version-2_0-branch/booking/inc/class.custom_fields.inc.php
2016-10-18 08:17:04 UTC (rev 15850)
@@ -46,7 +46,7 @@
*
* @return void
*/
- public function __construct( $appname = null )
+ public function __construct( $appname = 'booking' )
{
parent::__construct($appname);
}
@@ -58,7 +58,7 @@
*/
public function get_fields( $location )
{
- $appname = 'booking';
+ $appname = $this->_appname;
return parent::find($appname, $location, 0, '', 'ASC',
'attrib_sort', true, true);
}
@@ -70,7 +70,8 @@
*/
public function organize_fields( $location, $fields = array() )
{
- $field_groups = $this->get_field_groups('booking',
$location, $fields);
+ $appname = $this->_appname;
+ $field_groups = $this->get_field_groups($appname,
$location, $fields);
$i = -1;
$attributes = array();
$_dummy = array(array());
@@ -119,7 +120,7 @@
*/
public function get_organized_fields( $location )
{
- $appname = 'booking';
+ $appname = $this->_appname;
$fields = parent::find($appname, $location, 0, '',
'ASC', 'attrib_sort', true, true);
return $this->get_field_groups($appname, $location,
$fields);
}
Modified: branches/Version-2_0-branch/booking/inc/class.soapplication.inc.php
===================================================================
--- branches/Version-2_0-branch/booking/inc/class.soapplication.inc.php
2016-10-18 02:30:07 UTC (rev 15849)
+++ branches/Version-2_0-branch/booking/inc/class.soapplication.inc.php
2016-10-18 08:17:04 UTC (rev 15850)
@@ -66,9 +66,10 @@
'manytomany' => array(
'table' =>
'bb_application_agegroup',
'key' => 'application_id',
- 'column' => array('agegroup_id'
=> array('type' => 'int', 'required' => true),
- 'male' => array('type'
=> 'int', 'required' => true), 'female' => array('type' => 'int',
- 'required' =>
true)),
+ 'column' => array(
+ 'agegroup_id' =>
array('type' => 'int', 'required' => true),
+ 'male' => array('type'
=> 'int', 'required' => true),
+ 'female' =>
array('type' => 'int','required' => true)),
)),
'dates' => array('type' => 'timestamp',
'required' => true,
'manytomany' => array(
Property changes on: branches/Version-2_0-branch/bookingfrontend
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/dev-syncromind-2/bookingfrontend:14933-15747
/branches/stavangerkommune/bookingfrontend:9468-12740,12986
/trunk/bookingfrontend:14721-14732,14770-14783,14794-14808,14824-14825,14838,14886-14894,14906-14909,14917-14919,14924-14978,14980-15258,15297,15312-15335,15585-15617,15621-15630,15714-15764,15813-15814
+ /branches/dev-syncromind-2/bookingfrontend:14933-15747
/branches/stavangerkommune/bookingfrontend:9468-12740,12986
/trunk/bookingfrontend:14721-14732,14770-14783,14794-14808,14824-14825,14838,14886-14894,14906-14909,14917-14919,14924-14978,14980-15258,15297,15312-15335,15585-15617,15621-15630,15714-15764,15813-15814,15820-15849
Copied:
branches/Version-2_0-branch/bookingfrontend/inc/class.hook_helper.inc.php (from
rev 15849, trunk/bookingfrontend/inc/class.hook_helper.inc.php)
===================================================================
--- branches/Version-2_0-branch/bookingfrontend/inc/class.hook_helper.inc.php
(rev 0)
+++ branches/Version-2_0-branch/bookingfrontend/inc/class.hook_helper.inc.php
2016-10-18 08:17:04 UTC (rev 15850)
@@ -0,0 +1,53 @@
+<?php
+ /**
+ * Bookingfrontend - Hook helper
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2013 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @package Property
+ * @version $Id: class.hook_helper.inc.php 14728 2016-02-11 22:28:46Z
sigurdne $
+ */
+ /*
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+ /**
+ * Hook helper
+ *
+ * @package bookingfrontend
+ */
+ class bookingfrontend_hook_helper
+ {
+
+
+ public function set_cookie_domain()
+ {
+ $script_path =
dirname(phpgw::get_var('SCRIPT_FILENAME', 'string', 'SERVER'));
+
+ if(preg_match('/bookingfrontend/', $script_path))
+ {
+ //get from local config
+ $config = CreateObject('phpgwapi.config',
'bookingfrontend');
+ $config->read();
+
+
$GLOBALS['phpgw_info']['server']['cookie_domain'] =
!empty($GLOBALS['phpgw_info']['server']['cookie_domain']) ?
$GLOBALS['phpgw_info']['server']['cookie_domain'] : '';
+
+ if
(!empty($config->config_data['cookie_domain']))
+ {
+
$GLOBALS['phpgw_info']['server']['cookie_domain'] =
$config->config_data['cookie_domain'];
+ }
+ }
+ }
+ }
\ No newline at end of file
Modified: branches/Version-2_0-branch/bookingfrontend/setup/setup.inc.php
===================================================================
--- branches/Version-2_0-branch/bookingfrontend/setup/setup.inc.php
2016-10-18 02:30:07 UTC (rev 15849)
+++ branches/Version-2_0-branch/bookingfrontend/setup/setup.inc.php
2016-10-18 08:17:04 UTC (rev 15850)
@@ -34,5 +34,6 @@
$setup_info['bookingfrontend']['hooks'] = array
(
'menu' => 'bookingfrontend.menu.get_menu',
+ 'set_cookie_domain' =>
'bookingfrontend.hook_helper.set_cookie_domain',
'config'
);
Modified: branches/Version-2_0-branch/bookingfrontend/templates/base/config.tpl
===================================================================
--- branches/Version-2_0-branch/bookingfrontend/templates/base/config.tpl
2016-10-18 02:30:07 UTC (rev 15849)
+++ branches/Version-2_0-branch/bookingfrontend/templates/base/config.tpl
2016-10-18 08:17:04 UTC (rev 15850)
@@ -20,6 +20,10 @@
</select>
</td>
</tr>
+ <tr class="row_off">
+
<td>{lang_cookie_domain_for_sessions_-_if_Same_as_framework_leave_empty}</td>
+ <td><input name="newsettings[cookie_domain]"
value="{value_cookie_domain}"></td>
+ </tr>
<tr class="row_on">
<td>{lang_Anonymous_user}:</td>
<td><input name="newsettings[anonymous_user]"
value="{value_anonymous_user}"></td>
Modified:
branches/Version-2_0-branch/mobilefrontend/inc/class.hook_helper.inc.php
===================================================================
--- branches/Version-2_0-branch/mobilefrontend/inc/class.hook_helper.inc.php
2016-10-18 02:30:07 UTC (rev 15849)
+++ branches/Version-2_0-branch/mobilefrontend/inc/class.hook_helper.inc.php
2016-10-18 08:17:04 UTC (rev 15850)
@@ -5,7 +5,7 @@
* @author Sigurd Nes <address@hidden>
* @copyright Copyright (C) 2013 Free Software Foundation, Inc.
http://www.fsf.org/
* @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
- * @package controller
+ * @package Property
* @version $Id$
*/
/*
@@ -43,11 +43,28 @@
$config = CreateObject('phpgwapi.config',
'mobilefrontend');
$config->read();
- if (isset($config->config_data['auth_type']) &&
$config->config_data['auth_type'])
+ if (!empty($config->config_data['auth_type']))
{
$GLOBALS['phpgw_info']['server']['auth_type'] =
$config->config_data['auth_type'];
}
+ }
-//_debug_array($GLOBALS['phpgw_info']['server']);die();
+ public function set_cookie_domain()
+ {
+ $script_path =
dirname(phpgw::get_var('SCRIPT_FILENAME', 'string', 'SERVER'));
+
+ if(preg_match('/mobilefrontend/', $script_path))
+ {
+ //get from local config
+ $config = CreateObject('phpgwapi.config',
'mobilefrontend');
+ $config->read();
+
+
$GLOBALS['phpgw_info']['server']['cookie_domain'] =
!empty($GLOBALS['phpgw_info']['server']['cookie_domain']) ?
$GLOBALS['phpgw_info']['server']['cookie_domain'] : '';
+
+ if
(!empty($config->config_data['cookie_domain']))
+ {
+
$GLOBALS['phpgw_info']['server']['cookie_domain'] =
$config->config_data['cookie_domain'];
+ }
+ }
}
}
\ No newline at end of file
Modified: branches/Version-2_0-branch/mobilefrontend/setup/setup.inc.php
===================================================================
--- branches/Version-2_0-branch/mobilefrontend/setup/setup.inc.php
2016-10-18 02:30:07 UTC (rev 15849)
+++ branches/Version-2_0-branch/mobilefrontend/setup/setup.inc.php
2016-10-18 08:17:04 UTC (rev 15850)
@@ -50,6 +50,7 @@
(
'config',
'home',
+ 'set_cookie_domain' =>
'mobilefrontend.hook_helper.set_cookie_domain',
'set_auth_type' => 'mobilefrontend.hook_helper.set_auth_type',
'menu' => 'mobilefrontend.menu.get_menu'
);
Modified: branches/Version-2_0-branch/mobilefrontend/templates/base/config.tpl
===================================================================
--- branches/Version-2_0-branch/mobilefrontend/templates/base/config.tpl
2016-10-18 02:30:07 UTC (rev 15849)
+++ branches/Version-2_0-branch/mobilefrontend/templates/base/config.tpl
2016-10-18 08:17:04 UTC (rev 15850)
@@ -22,6 +22,10 @@
</select>
</td>
</tr>
+ <tr class="row_off">
+
<td>{lang_cookie_domain_for_sessions_-_if_Same_as_framework_leave_empty}</td>
+ <td><input name="newsettings[cookie_domain]"
value="{value_cookie_domain}"></td>
+ </tr>
<!-- END body -->
<!-- BEGIN footer -->
<tr class="th">
Modified: branches/Version-2_0-branch/phpgwapi/inc/class.custom_fields.inc.php
===================================================================
--- branches/Version-2_0-branch/phpgwapi/inc/class.custom_fields.inc.php
2016-10-18 02:30:07 UTC (rev 15849)
+++ branches/Version-2_0-branch/phpgwapi/inc/class.custom_fields.inc.php
2016-10-18 08:17:04 UTC (rev 15850)
@@ -931,7 +931,7 @@
if(isset($attrib['new_choice']) &&
$attrib['new_choice'] && !$doubled )
{
- $this->add_choice($location_id, $attrib_id,
$attrib['new_choice'], $attrib['new_choice_id']);
+ $this->add_choice($location_id, $attrib_id,
$attrib['new_choice'], $attrib['new_choice_id'], $attrib['new_title_choice']);
}
if ( count($attrib['edit_choice']) && !$doubled )
@@ -992,7 +992,7 @@
* @param integer $choice_id
*/
- public function add_choice($location_id,$attrib_id,$value,
$choice_id = 0)
+ public function add_choice($location_id,$attrib_id,$value,
$choice_id = 0, $title = '')
{
if(!$choice_id)
{
@@ -1008,12 +1008,13 @@
$attrib_id,
$choice_id,
$choice_sort,
- $value
+ $value,
+ $title
);
$values = $this->_db->validate_insert($values);
- $this->_db->query("INSERT INTO phpgw_cust_choice
(location_id, attrib_id, id,choice_sort, value) "
+ $this->_db->query("INSERT INTO phpgw_cust_choice
(location_id, attrib_id, id,choice_sort, value, title) "
. "VALUES ({$values})",__LINE__,__FILE__);
}
Modified: branches/Version-2_0-branch/phpgwapi/inc/class.db_pdo.inc.php
===================================================================
--- branches/Version-2_0-branch/phpgwapi/inc/class.db_pdo.inc.php
2016-10-18 02:30:07 UTC (rev 15849)
+++ branches/Version-2_0-branch/phpgwapi/inc/class.db_pdo.inc.php
2016-10-18 08:17:04 UTC (rev 15850)
@@ -831,7 +831,7 @@
{
if ($strip_slashes ||
($this->auto_stripslashes && ! $strip_slashes))
{
- return
htmlspecialchars_decode(stripslashes(str_replace(array('(;',
');'), array('(', ')'), $this->Record[$name])),ENT_QUOTES);
+ return
htmlspecialchars_decode(stripslashes(str_replace(array('&;#40;',
'&;#41;'), array('(', ')'), $this->Record[$name])),ENT_QUOTES);
// return
htmlspecialchars_decode(stripslashes($this->Record[$name]));
}
else
Modified:
branches/Version-2_0-branch/phpgwapi/inc/class.schema_proc_pgsql.inc.php
===================================================================
--- branches/Version-2_0-branch/phpgwapi/inc/class.schema_proc_pgsql.inc.php
2016-10-18 02:30:07 UTC (rev 15849)
+++ branches/Version-2_0-branch/phpgwapi/inc/class.schema_proc_pgsql.inc.php
2016-10-18 08:17:04 UTC (rev 15850)
@@ -209,6 +209,8 @@
case 'text':
case 'blob':
case 'date':
+ case 'json':
+ case 'jsonb':
$sTranslated = "'type' => '$sType'";
break;
case 'bool':
Modified: branches/Version-2_0-branch/phpgwapi/inc/class.sessions.inc.php
===================================================================
--- branches/Version-2_0-branch/phpgwapi/inc/class.sessions.inc.php
2016-10-18 02:30:07 UTC (rev 15849)
+++ branches/Version-2_0-branch/phpgwapi/inc/class.sessions.inc.php
2016-10-18 08:17:04 UTC (rev 15850)
@@ -153,13 +153,19 @@
{
$use_cookies = true;
$this->_sessionid =
phpgw::get_var(session_name(), 'string', 'COOKIE');
+
+ if(!$this->_sessionid)
+ {
+
$GLOBALS['phpgw']->hooks->process('set_cookie_domain', array('mobilefrontend',
'bookingfrontend', 'activitycalendarfrontend'));
+ }
+
+ $this->_phpgw_set_cookie_params();
}
else
{
$this->_sessionid =
phpgw::get_var(session_name()); // GET or POST
}
- $this->_phpgw_set_cookie_params();
//respect the config option for cookies
ini_set('session.use_cookies', $use_cookies);
Modified: branches/Version-2_0-branch/phpgwapi/inc/class.socommon.inc.php
===================================================================
--- branches/Version-2_0-branch/phpgwapi/inc/class.socommon.inc.php
2016-10-18 02:30:07 UTC (rev 15849)
+++ branches/Version-2_0-branch/phpgwapi/inc/class.socommon.inc.php
2016-10-18 08:17:04 UTC (rev 15850)
@@ -408,7 +408,7 @@
}
else
{
- $row[$field] =
$this->unmarshal($this->db->f($field, false), $params['type']);
+ $row[$field] =
$this->unmarshal($this->db->f($field, true), $params['type']);
}
}
}
@@ -645,6 +645,7 @@
foreach ($this->fields as $field => $params)
{
+ $value = $object->get_field($field);
if (!empty($params['manytomany']) &&
!empty($params['manytomany']['input_field']) &&
$object->get_field($params['manytomany']['input_field']))
{
$table = $params['manytomany']['table'];
@@ -696,6 +697,66 @@
return
$this->db->query($update_query,__LINE__,__FILE__);
}
}
+ else if(!empty($params['manytomany']) &&
is_array($value))
+ {
+ $update_queries = array();
+ $table = $params['manytomany']['table'];
+ $key = $params['manytomany']['key'];
+ $update_queries[] = "DELETE FROM $table
WHERE $key=$id";
+
+ if
(is_array($params['manytomany']['column']))
+ {
+ $colnames = array();
+ foreach
($params['manytomany']['column'] as $intOrCol => $paramsOrCol)
+ {
+
$colnames[(is_array($paramsOrCol) ? $intOrCol : $paramsOrCol)] = true;
+ }
+ unset($colnames['id']);
+
+ $colnames = join(',',
array_keys($colnames));
+
+ foreach ($value as $v)
+ {
+ $data = array();
+ foreach
($params['manytomany']['column'] as $intOrCol => $paramsOrCol)
+ {
+ if
(is_array($paramsOrCol))
+ {
+ $col =
$intOrCol;
+ $type =
isset($paramsOrCol['type']) ? $paramsOrCol['type'] : $params['type'];
+ }
+ else
+ {
+ $col =
$paramsOrCol;
+ $type =
$params['type'];
+ }
+
+ if ($col ==
'id')
+ {
+
continue;
+ }
+
+ $data[] =
$this->marshal($v, $type);
+ }
+ $v = join(',', $data);
+ $update_queries[] =
"INSERT INTO $table ($key, $colnames) VALUES($id, $v)";
+ }
+ }
+ else
+ {
+ $colname =
$params['manytomany']['column'];
+ foreach ($value as $v)
+ {
+ $v = $this->marshal($v,
$params['type']);
+ $update_queries[] =
"INSERT INTO $table ($key, $colname) VALUES($id, $v)";
+ }
+ }
+ foreach ($update_queries as
$update_query)
+ {
+ $this->db->query($update_query,
__LINE__, __FILE__);
+ }
+
+ }
}
return true;
}
Modified: branches/Version-2_0-branch/phpgwapi/inc/model/class.model.inc.php
===================================================================
--- branches/Version-2_0-branch/phpgwapi/inc/model/class.model.inc.php
2016-10-18 02:30:07 UTC (rev 15849)
+++ branches/Version-2_0-branch/phpgwapi/inc/model/class.model.inc.php
2016-10-18 08:17:04 UTC (rev 15850)
@@ -64,25 +64,32 @@
$datatype = $fields[$name]['type'];
}
- if ( isset($this->$name) )
+ if ( isset($this->$name))
{
- switch ($datatype)
+ if(is_array($this->$name))
{
- case 'int':
- case 'integert':
- $value = (int)$this->$name;
- break;
- case 'float':
- $value = (float)$this->$name;
- break;
- case 'bool':
- case 'boolean':
- $value = (bool)$this->$name;
- break;
- default:
- $value = $this->$name;
- break;
+ $value = $this->$name;
}
+ else
+ {
+ switch ($datatype)
+ {
+ case 'int':
+ case 'integert':
+ $value =
(int)$this->$name;
+ break;
+ case 'float':
+ $value =
(float)$this->$name;
+ break;
+ case 'bool':
+ case 'boolean':
+ $value =
(bool)$this->$name;
+ break;
+ default:
+ $value = $this->$name;
+ break;
+ }
+ }
return $value;
}
@@ -318,7 +325,7 @@
{
$this->_validate(
//
(array)$sub_entity, (array)$params['manytomany']['column'], $errors,
sprintf('%s%s[%s]', $field_prefix, empty($field_prefix) ? $field :
"[{$field}]", (is_string($key) ? $key : $sub_entity_count))
-
(array)$sub_entity, (array)$params['manytomany']['column'], $errors
+ $entity,
array($field => $params['manytomany']['column']), $errors
);
$sub_entity_count++;
}
Modified: branches/Version-2_0-branch/phpgwapi/js/jquery/validator/brazil.js
===================================================================
--- branches/Version-2_0-branch/phpgwapi/js/jquery/validator/brazil.js
2016-10-18 02:30:07 UTC (rev 15849)
+++ branches/Version-2_0-branch/phpgwapi/js/jquery/validator/brazil.js
2016-10-18 08:17:04 UTC (rev 15850)
@@ -1,8 +1,9 @@
-/**
+/** File generated by Grunt -- do not modify
* JQUERY-FORM-VALIDATOR
*
- * @website by
+ * @version 2.3.49
+ * @website http://formvalidator.net/
+ * @author Victor Jonsson, http://victorjonsson.se
* @license MIT
- * @version 2.2.83
*/
-$.formUtils.addValidator({name:"cpf",validatorFunction:function(a){var
b=a.replace(/\D/g,""),c=0,d=0,e=0,f=0;if(11!==b.length||"00000000000"===b)return!1;for(i=1;i<=9;i++)c+=parseInt(b.substring(i-1,i))*(11-i);if(e=10*c%11,e>=10&&(e=0),e!==parseInt(b.substring(9,10)))return!1;for(i=1;i<=10;i++)d+=parseInt(b.substring(i-1,i))*(12-i);return
f=10*d%11,f>=10&&(f=0),f!==parseInt(b.substring(10,11))?!1:!0},errorMessage:"",errorMessageKey:"badBrazilCPFAnswer"}),$.formUtils.addValidator({name:"brphone",validatorFunction:function(a){return
a.match(/^(\+[\d]{1,3}[\s]{0,1}){0,1}(\(){0,1}(\d){2}(\)){0,1}(\s){0,1}(\d){4,5}([-.
]){0,1}(\d){4}$/g)?!0:!1},errorMessage:"",errorMessageKey:"badBrazilTelephoneAnswer"}),$.formUtils.addValidator({name:"cep",validatorFunction:function(a){return
a.match(/^(\d){5}([-.
]){0,1}(\d){3}$/g)?!0:!1},errorMessage:"",errorMessageKey:"badBrazilCEPAnswer"});
\ No newline at end of file
+!function(a,b){"function"==typeof
define&&define.amd?define(["jquery"],function(a){return b(a)}):"object"==typeof
exports?module.exports=b(require("jquery")):b(jQuery)}(this,function(a){$.formUtils.addValidator({name:"cpf",validatorFunction:function(a){var
b=a.replace(/\D/g,""),c=0,d=0,e=0,f=0;if(11!==b.length||"00000000000"===b)return!1;for(i=1;i<=9;i++)c+=parseInt(b.substring(i-1,i))*(11-i);if(e=10*c%11,e>=10&&(e=0),e!==parseInt(b.substring(9,10)))return!1;for(i=1;i<=10;i++)d+=parseInt(b.substring(i-1,i))*(12-i);return
f=10*d%11,f>=10&&(f=0),f===parseInt(b.substring(10,11))},errorMessage:"",errorMessageKey:"badBrazilCPFAnswer"}),$.formUtils.addValidator({name:"brphone",validatorFunction:function(a){return!!a.match(/^(\+[\d]{1,3}[\s]{0,1}){0,1}(\(){0,1}(\d){2}(\)){0,1}(\s){0,1}(\d){4,5}([-.
]){0,1}(\d){4}$/g)},errorMessage:"",errorMessageKey:"badBrazilTelephoneAnswer"}),$.formUtils.addValidator({name:"cep",validatorFunction:function(a){return!!a.match(/^(\d){5}([-.
]){0,1}(\d){3}$/g)},errorMessage:"",errorMessageKey:"badBrazilCEPAnswer"})});
\ No newline at end of file
Modified: branches/Version-2_0-branch/phpgwapi/js/jquery/validator/date.js
===================================================================
--- branches/Version-2_0-branch/phpgwapi/js/jquery/validator/date.js
2016-10-18 02:30:07 UTC (rev 15849)
+++ branches/Version-2_0-branch/phpgwapi/js/jquery/validator/date.js
2016-10-18 08:17:04 UTC (rev 15850)
@@ -1,8 +1,9 @@
-/**
+/** File generated by Grunt -- do not modify
* JQUERY-FORM-VALIDATOR
*
- * @website by
+ * @version 2.3.49
+ * @website http://formvalidator.net/
+ * @author Victor Jonsson, http://victorjonsson.se
* @license MIT
- * @version 2.2.83
*/
-!function(a){a.formUtils.addValidator({name:"time",validatorFunction:function(a){if(null===a.match(/^(\d{2}):(\d{2})$/))return!1;var
b=parseInt(a.split(":")[0],10),c=parseInt(a.split(":")[1],10);return
b>23||c>59?!1:!0},errorMessage:"",errorMessageKey:"badTime"}),a.formUtils.addValidator({name:"birthdate",validatorFunction:function(b,c,d){var
e="yyyy-mm-dd";c.valAttr("format")?e=c.valAttr("format"):"undefined"!=typeof
d.dateFormat&&(e=d.dateFormat);var
f=a.formUtils.parseDate(b,e);if(!f)return!1;var g=new
Date,h=g.getFullYear(),i=f[0],j=f[1],k=f[2];if(i===h){var
l=g.getMonth()+1;if(j===l){var m=g.getDate();return m>=k}return l>j}return
h>i&&i>h-124},errorMessage:"",errorMessageKey:"badDate"})}(jQuery);
\ No newline at end of file
+!function(a,b){"function"==typeof
define&&define.amd?define(["jquery"],function(a){return b(a)}):"object"==typeof
exports?module.exports=b(require("jquery")):b(jQuery)}(this,function(a){!function(a){a.formUtils.addValidator({name:"time",validatorFunction:function(a){if(null===a.match(/^(\d{2}):(\d{2})$/))return!1;var
b=parseInt(a.split(":")[0],10),c=parseInt(a.split(":")[1],10);return!(b>23||c>59)},errorMessage:"",errorMessageKey:"badTime"}),a.formUtils.addValidator({name:"birthdate",validatorFunction:function(b,c,d){var
e="yyyy-mm-dd";c.valAttr("format")?e=c.valAttr("format"):"undefined"!=typeof
d.dateFormat&&(e=d.dateFormat);var
f=a.formUtils.parseDate(b,e);if(!f)return!1;var g=new
Date,h=g.getFullYear(),i=f[0],j=f[1],k=f[2];if(i===h){var
l=g.getMonth()+1;if(j===l){var m=g.getDate();return k<=m}return j<l}return
i<h&&i>h-124},errorMessage:"",errorMessageKey:"badDate"})}(a)});
\ No newline at end of file
Modified: branches/Version-2_0-branch/phpgwapi/js/jquery/validator/file.js
===================================================================
--- branches/Version-2_0-branch/phpgwapi/js/jquery/validator/file.js
2016-10-18 02:30:07 UTC (rev 15849)
+++ branches/Version-2_0-branch/phpgwapi/js/jquery/validator/file.js
2016-10-18 08:17:04 UTC (rev 15850)
@@ -1,8 +1,9 @@
-/**
+/** File generated by Grunt -- do not modify
* JQUERY-FORM-VALIDATOR
*
- * @website by
+ * @version 2.3.49
+ * @website http://formvalidator.net/
+ * @author Victor Jonsson, http://victorjonsson.se
* @license MIT
- * @version 2.2.83
*/
-!function(a,b){"use strict";var c="undefined"!=typeof
b.FileReader,d=function(b){var
c=a.split((b.valAttr("allowing")||"").toLowerCase());return
a.inArray("jpg",c)>-1&&-1===a.inArray("jpeg",c)?c.push("jpeg"):a.inArray("jpeg",c)>-1&&-1===a.inArray("jpg",c)&&c.push("jpg"),c},e=function(a,b,c,d){var
e=d[b]||"";a.errorMessageKey="",a.errorMessage=e.replace("%s",c)},f=function(a){b.console&&b.console.log&&b.console.log(a)},g=function(c,d,e){var
f=new FileReader,g=new
Image;f.readAsDataURL(c),f.onload=function(c){g.onload=function(){a(b).trigger("imageValidation",[this]),d(this)},g.onerror=function(){e()},g.src=c.target.result}};a.formUtils.addValidator({name:"mime",validatorFunction:function(b,g,h,i){if(c){var
j=!0,k=g.get(0).files||[],l="",m=d(g);return
k.length&&(a.each(k,function(b,c){return
j=!1,l=c.type||"",a.each(m,function(a,b){return j=l.indexOf(b)>-1,j?!1:void
0}),j}),j||(f("Trying to upload a file with mime type "+l+" which is not
allowed"),e(this,"wrongFileType",m.join(", "),i))),j}return f("FileReader not
supported by browser, will check file
extension"),a.formUtils.validators.validate_extension.validatorFunction(b,g,h,i)},errorMessage:"",errorMessageKey:"wrongFileType"}),a.formUtils.addValidator({name:"extension",validatorFunction:function(b,c,f,g){var
h=!0,i=this,j=d(c);return a.each(c.get(0).files||[b],function(b,c){var
d="string"==typeof
c?c:c.value||c.fileName||c.name,f=d.substr(d.lastIndexOf(".")+1);return-1===a.inArray(f.toLowerCase(),j)?(h=!1,e(i,"wrongFileType",j.join(",
"),g),!1):void
0}),h},errorMessage:"",errorMessageKey:"wrongFileType"}),a.formUtils.addValidator({name:"size",validatorFunction:function(b,d,g,h){var
i=d.valAttr("max-size");if(!i)return f('Input "'+d.attr("name")+'" is missing
data-validation-max-size attribute'),!0;if(!c)return!0;var
j=a.formUtils.convertSizeNameToBytes(i),k=!0;return
a.each(d.get(0).files||[],function(a,b){return
k=b.size<=j}),k||e(this,"wrongFileSize",i,h),k},errorMessage:"",errorMessageKey:"wrongFileSize"}),a.formUtils.convertSizeNameToBytes=function(a){return
a=a.toUpperCase(),"M"===a.substr(a.length-1,1)?1024*parseInt(a.substr(0,a.length-1),10)*1024:"MB"===a.substr(a.length-2,2)?1024*parseInt(a.substr(0,a.length-2),10)*1024:"KB"===a.substr(a.length-2,2)?1024*parseInt(a.substr(0,a.length-2),10):"B"===a.substr(a.length-1,1)?parseInt(a.substr(0,a.length-1),10):parseInt(a,10)};var
h=function(){return!1};a.formUtils.checkImageDimension=function(a,b,c){var
d=!1,e={width:0,height:0},f=function(a){a=a.replace("min","").replace("max","");var
b=a.split("x");e.width=b[0],e.height=b[1]?b[1]:b[0]},g=!1,h=!1,i=b.split("-");return
1===i.length?0===i[0].indexOf("min")?g=i[0]:h=i[0]:(g=i[0],h=i[1]),g&&(f(g),(a.width<e.width||a.height<e.height)&&(d=c.imageTooSmall+"
("+c.min+"
"+e.width+"x"+e.height+"px)")),!d&&h&&(f(h),(a.width>e.width||a.height>e.height)&&(d=a.width>e.width?c.imageTooWide+"
"+e.width+"px":c.imageTooTall+" "+e.height+"px",d+=" ("+c.max+"
"+e.width+"x"+e.height+"px)")),d},a.formUtils.checkImageRatio=function(a,b,c){var
d=a.width/a.height,e=function(a){var
b=a.replace("max","").replace("min","").split(":");return
b[0]/b[1]},f=b.split("-"),g=function(a,b,c){return
a>=b&&c>=a};if(1===f.length){if(d!==e(f[0]))return c.imageRatioNotAccepted}else
if(2===f.length&&!g(d,e(f[0]),e(f[1])))return
c.imageRatioNotAccepted;return!1},a.formUtils.addValidator({name:"dimension",validatorFunction:function(b,d,e,f,i){var
j=!1;if(c){var
k=d.get(0).files||[];if(j=!0,-1===d.attr("data-validation").indexOf("mime"))return
alert("You should validate file type being jpg, gif or png on input
"+d[0].name),!1;if(k.length>1)return alert("Validating image dimensions does
not support inputs allowing multiple
files"),!1;if(0===k.length)return!0;if(d.valAttr("has-valid-dim"))return!0;if(d.valAttr("has-not-valid-dim"))return
this.errorMessage=f.wrongFileDim+"
"+d.valAttr("has-not-valid-dim"),!1;if("keyup"===a.formUtils.eventType)return
null;var l=!1;return
a.formUtils.isValidatingEntireForm&&(l=!0,a.formUtils.haltValidation=!0,i.bind("submit",h).addClass("on-blur")),g(k[0],function(b){var
c=!1;d.valAttr("dimension")&&(c=a.formUtils.checkImageDimension(b,d.valAttr("dimension"),f)),!c&&d.valAttr("ratio")&&(c=a.formUtils.checkImageRatio(b,d.valAttr("ratio"),f)),c?d.valAttr("has-not-valid-dim",c):d.valAttr("has-valid-dim","true"),d.valAttr("has-keyup-event")||d.valAttr("has-keyup-event","1").bind("keyup
change",function(b){9!==b.keyCode&&16!==b.keyCode&&a(this).valAttr("has-not-valid-dim",!1).valAttr("has-valid-dim",!1)}),l?(a.formUtils.haltValidation=!1,i.removeClass("on-blur").get(0).onsubmit=function(){},i.unbind("submit",h),i.trigger("submit")):d.trigger("blur")},function(a){throw
a}),!0}return
j},errorMessage:"",errorMessageKey:""}),a(b).one("validatorsLoaded
formValidationSetup",function(b,c){var
d;d=c?c.find('input[type="file"]'):a('input[type="file"]'),d.filter("*[data-validation]").bind("change",function(){a(this).removeClass("error").parent().find(".form-error").remove()})})}(jQuery,window);
\ No newline at end of file
+!function(a,b){"function"==typeof
define&&define.amd?define(["jquery"],function(a){return b(a)}):"object"==typeof
exports?module.exports=b(require("jquery")):b(jQuery)}(this,function(a){!function(a,b){"use
strict";var c="undefined"!=typeof b.FileReader,d=function(b){var
c=a.split((b.valAttr("allowing")||"").toLowerCase());return
a.inArray("jpg",c)>-1&&a.inArray("jpeg",c)===-1?c.push("jpeg"):a.inArray("jpeg",c)>-1&&a.inArray("jpg",c)===-1&&c.push("jpg"),c},e=function(a,b,c,d){var
e=d[b]||"";a.errorMessageKey="",a.errorMessage=e.replace("%s",c)},f=function(c,d,e){var
f=new FileReader,g=new
Image;f.readAsDataURL(c),f.onload=function(c){g.onload=function(){a(b).trigger("imageValidation",[this]),d(this)},g.onerror=function(){e()},g.src=c.target.result}};a.formUtils.addValidator({name:"mime",validatorFunction:function(b,f,g,h){if(c){var
i=!0,j=f.get(0).files||[],k="",l=d(f);return
j.length&&(a.each(j,function(b,c){return
i=!1,k=c.type||"",a.each(l,function(a,b){if(i=k.indexOf(b)>-1)return!1}),i}),i||(a.formUtils.warn("Trying
to upload a file with mime type "+k+" which is not
allowed"),e(this,"wrongFileType",l.join(", "),h))),i}return
a.formUtils.warn("FileReader not supported by browser, will check file
extension"),a.formUtils.validators.validate_extension.validatorFunction(b,f,g,h)},errorMessage:"",errorMessageKey:"wrongFileType"}),a.formUtils.addValidator({name:"extension",validatorFunction:function(b,c,f,g){var
h=!0,i=this,j=d(c);return a.each(c.get(0).files||[b],function(b,c){var
d="string"==typeof
c?c:c.value||c.fileName||c.name,f=d.substr(d.lastIndexOf(".")+1);if(a.inArray(f.toLowerCase(),j)===-1)return
h=!1,e(i,"wrongFileType",j.join(",
"),g),!1}),h},errorMessage:"",errorMessageKey:"wrongFileType"}),a.formUtils.addValidator({name:"size",validatorFunction:function(b,d,f,g){var
h=d.valAttr("max-size");if(!h)return a.formUtils.warn('Input
"'+d.attr("name")+'" is missing data-validation-max-size
attribute'),!0;if(!c)return!0;var
i=a.formUtils.convertSizeNameToBytes(h),j=!0;return
a.each(d.get(0).files||[],function(a,b){return
j=b.size<=i}),j||e(this,"wrongFileSize",h,g),j},errorMessage:"",errorMessageKey:"wrongFileSize"}),a.formUtils.convertSizeNameToBytes=function(a){return
a=a.toUpperCase(),"M"===a.substr(a.length-1,1)?1024*parseInt(a.substr(0,a.length-1),10)*1024:"MB"===a.substr(a.length-2,2)?1024*parseInt(a.substr(0,a.length-2),10)*1024:"KB"===a.substr(a.length-2,2)?1024*parseInt(a.substr(0,a.length-2),10):"B"===a.substr(a.length-1,1)?parseInt(a.substr(0,a.length-1),10):parseInt(a,10)},a.formUtils.checkImageDimension=function(a,b,c){var
d=!1,e={width:0,height:0},f=function(a){a=a.replace("min","").replace("max","");var
b=a.split("x");e.width=b[0],e.height=b[1]?b[1]:b[0]},g=!1,h=!1,i=b.split("-");return
1===i.length?0===i[0].indexOf("min")?g=i[0]:h=i[0]:(g=i[0],h=i[1]),g&&(f(g),(a.width<e.width||a.height<e.height)&&(d=c.imageTooSmall+"
("+c.min+"
"+e.width+"x"+e.height+"px)")),!d&&h&&(f(h),(a.width>e.width||a.height>e.height)&&(d=a.width>e.width?c.imageTooWide+"
"+e.width+"px":c.imageTooTall+" "+e.height+"px",d+=" ("+c.max+"
"+e.width+"x"+e.height+"px)")),d},a.formUtils.checkImageRatio=function(a,b,c){var
d=a.width/a.height,e=function(a){var
b=a.replace("max","").replace("min","").split(":");return
b[0]/b[1]},f=b.split("-"),g=function(a,b,c){return
a>=b&&a<=c};if(1===f.length){if(d!==e(f[0]))return c.imageRatioNotAccepted}else
if(2===f.length&&!g(d,e(f[0]),e(f[1])))return
c.imageRatioNotAccepted;return!1},a.formUtils.addValidator({name:"dimension",validatorFunction:function(b,d,e,g,h,i){if(c){var
j=this,k=a.formUtils.asyncValidation(this.name,d,h);return
k.run(i,function(b){var
c=d.get(0).files||[];d.attr("data-validation").indexOf("mime")===-1?(alert("You
should validate file type being jpg, gif or png on input
"+d[0].name),b(!1)):c.length>1?(alert("Validating image dimensions does not
support inputs allowing multiple
files"),b(!1)):0===c.length?b(!0):f(c[0],function(c){var
e=!1;d.valAttr("dimension")&&(e=a.formUtils.checkImageDimension(c,d.valAttr("dimension"),g)),!e&&d.valAttr("ratio")&&(e=a.formUtils.checkImageRatio(c,d.valAttr("ratio"),g)),e?(j.errorMessage=g.wrongFileDim+"
"+d.valAttr("has-not-valid-dim"),b(!1)):b(!0)},function(a){throw
a})})}return!0},errorMessage:"",errorMessageKey:""}),a(b).one("validatorsLoaded
formValidationSetup",function(b,c,d){var
e;e=c?c.find('input[type="file"]'):a('input[type="file"]'),a.formUtils.dialogs.removeInputStylingAndMessage(e,d)})}(a,window)});
\ No newline at end of file
Modified: branches/Version-2_0-branch/phpgwapi/js/jquery/validator/html5.js
===================================================================
--- branches/Version-2_0-branch/phpgwapi/js/jquery/validator/html5.js
2016-10-18 02:30:07 UTC (rev 15849)
+++ branches/Version-2_0-branch/phpgwapi/js/jquery/validator/html5.js
2016-10-18 08:17:04 UTC (rev 15850)
@@ -1,8 +1,9 @@
-/**
+/** File generated by Grunt -- do not modify
* JQUERY-FORM-VALIDATOR
*
- * @website by
+ * @version 2.3.49
+ * @website http://formvalidator.net/
+ * @author Victor Jonsson, http://victorjonsson.se
* @license MIT
- * @version 2.2.83
*/
-!function(a,b){"use strict";var c="placeholder"in
document.createElement("INPUT"),d="options"in
document.createElement("DATALIST"),e=!1,f=function(b){b.each(function(){var
b=a(this),f=b.find("input,textarea,select"),g=!1;f.each(function(){var
b=[],c=a(this),f=c.attr("required"),h={};switch((c.attr("type")||"").toLowerCase()){case"time":b.push("time"),a.formUtils.validators.validate_date||e||(e=!0,a.formUtils.loadModules("date"));break;case"url":b.push("url");break;case"email":b.push("email");break;case"date":b.push("date");break;case"number":b.push("number");var
i=c.attr("max"),j=c.attr("min");(j||i)&&(j||(j="0"),i||(i="9007199254740992"),h["data-validation-allowing"]="range["+j+";"+i+"]",(0===j.indexOf("-")||0===i.indexOf("-"))&&(h["data-validation-allowing"]+=",negative"),(j.indexOf(".")>-1||i.indexOf(".")>-1)&&(h["data-validation-allowing"]+=",float"))}if(c.attr("pattern")&&(b.push("custom"),h["data-validation-regexp"]=c.attr("pattern")),c.attr("maxlength")&&(b.push("length"),h["data-validation-length"]="max"+c.attr("maxlength")),!d&&c.attr("list")){var
k=[],l=a("#"+c.attr("list"));if(l.find("option").each(function(){k.push(a(this).text())}),0===k.length){var
m=a.trim(a("#"+c.attr("list")).text()).split("\n");a.each(m,function(b,c){k.push(a.trim(c))})}l.remove(),a.formUtils.suggest(c,k)}f&&0===b.length&&b.push("required"),b.length&&(f||(h["data-validation-optional"]="true"),g=!0,c.attr("data-validation",b.join("
")),a.each(h,function(a,b){c.attr(a,b)}))}),g&&b.trigger("html5ValidationAttrsFound"),c||f.filter("input[placeholder]").each(function(){this.defaultValue=this.getAttribute("placeholder"),a(this).bind("focus",function(){this.value===this.defaultValue&&(this.value="",a(this).removeClass("showing-placeholder"))}).bind("blur",function(){""===a.trim(this.value)&&(this.value=this.defaultValue,a(this).addClass("showing-placeholder"))})})})};a(b).bind("validatorsLoaded
formValidationSetup",function(b,c){c||(c=a("form")),f(c)}),a.formUtils.setupValidationUsingHTML5Attr=f}(jQuery,window);
\ No newline at end of file
+!function(a,b){"function"==typeof
define&&define.amd?define(["jquery"],function(a){return b(a)}):"object"==typeof
exports?module.exports=b(require("jquery")):b(jQuery)}(this,function(a){!function(a){"use
strict";var b="placeholder"in document.createElement("INPUT"),c="options"in
document.createElement("DATALIST"),d=!1,e=function(e){e.each(function(){var
e=a(this),f=e.find("input,textarea,select"),g=!1;f.each(function(){var
b=[],e=a(this),f=e.attr("required"),h={};switch(f&&b.push("required"),(e.attr("type")||"").toLowerCase()){case"time":b.push("time"),a.formUtils.validators.validate_date||d||(d=!0,a.formUtils.loadModules("date"));break;case"url":b.push("url");break;case"email":b.push("email");break;case"date":b.push("date");break;case"number":b.push("number");var
i=e.attr("max"),j=e.attr("min"),k=e.attr("step");j||i?(j||(j="0"),i||(i="9007199254740992"),k||(k="1"),h["data-validation-allowing"]="range["+j+";"+i+"]",0!==j.indexOf("-")&&0!==i.indexOf("-")||(h["data-validation-allowing"]+=",negative"),(j.indexOf(".")>-1||i.indexOf(".")>-1||k.indexOf(".")>-1)&&(h["data-validation-allowing"]+=",float")):h["data-validation-allowing"]+=",float,negative"}if(e.attr("pattern")&&(b.push("custom"),h["data-validation-regexp"]=e.attr("pattern")),e.attr("maxlength")&&(b.push("length"),h["data-validation-length"]="max"+e.attr("maxlength")),!c&&e.attr("list")){var
l=[],m=a("#"+e.attr("list"));if(m.find("option").each(function(){l.push(a(this).text())}),0===l.length){var
n=a.trim(a("#"+e.attr("list")).text()).split("\n");a.each(n,function(b,c){l.push(a.trim(c))})}m.remove(),a.formUtils.suggest(e,l)}if(b.length){f||(h["data-validation-optional"]="true"),g=!0;var
o=(e.attr("data-validation")||"")+" "+b.join("
");e.attr("data-validation",a.trim(o)),a.each(h,function(a,b){e.attr(a,b)})}}),g&&e.trigger("html5ValidationAttrsFound"),b||f.filter("input[placeholder]").each(function(){this.__defaultValue=this.getAttribute("placeholder"),a(this).bind("focus",function(){this.value===this.__defaultValue&&(this.value="",a(this).removeClass("showing-placeholder"))}).bind("blur",function(){""===a.trim(this.value)&&(this.value=this.__defaultValue,a(this).addClass("showing-placeholder"))})})})};a.formUtils.$win.bind("validatorsLoaded
formValidationSetup",function(b,c){c||(c=a("form")),e(c)}),a.formUtils.setupValidationUsingHTML5Attr=e}(a,window)});
\ No newline at end of file
Modified:
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/jquery.form-validator.js
===================================================================
---
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/jquery.form-validator.js
2016-10-18 02:30:07 UTC (rev 15849)
+++
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/jquery.form-validator.js
2016-10-18 08:17:04 UTC (rev 15850)
@@ -1,23 +1,290 @@
-/**
- * jQuery Form Validator
- * ------------------------------------------
- * Created by Victor Jonsson <http://www.victorjonsson.se>
+(function (root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD. Register as an anonymous module unless amdModuleId is set
+ define(["jquery"], function (a0) {
+ return (factory(a0));
+ });
+ } else if (typeof exports === 'object') {
+ // Node. Does not work with strict CommonJS, but
+ // only CommonJS-like environments that support module.exports,
+ // like Node.
+ module.exports = factory(require("jquery"));
+ } else {
+ factory(jQuery);
+ }
+}(this, function (jQuery) {
+
+/** File generated by Grunt -- do not modify
+ * JQUERY-FORM-VALIDATOR
*
- * @website http://formvalidator.net/
- * @license MIT
- * @version 2.2.83
+ * @version 2.3.49
+ * @website http://formvalidator.net/
+ * @author Victor Jonsson, http://victorjonsson.se
+ * @license MIT
*/
+/**
+ */
+(function ($, undefined) {
+
+ var disableFormSubmit = function () {
+ return false;
+ },
+ HaltManager = {
+ numHalted: 0,
+ haltValidation: function($form) {
+ this.numHalted++;
+ $.formUtils.haltValidation = true;
+ $form
+ .unbind('submit', disableFormSubmit)
+ .bind('submit', disableFormSubmit)
+ .find('*[type="submit"]')
+ .addClass('disabled')
+ .attr('disabled', 'disabled');
+ },
+ unHaltValidation: function($form) {
+ this.numHalted--;
+ if (this.numHalted === 0) {
+ $.formUtils.haltValidation = false;
+ $form
+ .unbind('submit', disableFormSubmit)
+ .find('*[type="submit"]')
+ .removeClass('disabled')
+ .removeAttr('disabled', 'disabled');
+ }
+ }
+ };
+
+ function AsyncValidation($form, $input) {
+ this.$form = $form;
+ this.$input = $input;
+ this.reset();
+ $input.on('change paste', this.reset.bind(this));
+ }
+
+ AsyncValidation.prototype.reset = function() {
+ this.haltedFormValidation = false;
+ this.hasRun = false;
+ this.isRunning = false;
+ this.result = undefined;
+ };
+
+ AsyncValidation.prototype.run = function(eventContext, callback) {
+ if (eventContext === 'keyup') {
+ return null;
+ } else if (this.isRunning) {
+ if (!this.haltedFormValidation && eventContext === 'submit') {
+ HaltManager.haltValidation();
+ this.haltedFormValidation = true;
+ }
+ return null; // Waiting for result
+ } else if(this.hasRun) {
+ //this.$input.one('keyup change paste', this.reset.bind(this));
+ return this.result;
+ } else {
+ if (eventContext === 'submit') {
+ HaltManager.haltValidation(this.$form);
+ this.haltedFormValidation = true;
+ }
+ this.isRunning = true;
+ this.$input
+ .attr('disabled', 'disabled')
+ .addClass('async-validation');
+ this.$form.addClass('async-validation');
+
+ callback(function(result) {
+ this.done(result);
+ }.bind(this));
+
+ return null;
+ }
+ };
+
+ AsyncValidation.prototype.done = function(result) {
+ this.result = result;
+ this.hasRun = true;
+ this.isRunning = false;
+ this.$input
+ .removeAttr('disabled')
+ .removeClass('async-validation');
+ this.$form.removeClass('async-validation');
+ if (this.haltedFormValidation) {
+ HaltManager.unHaltValidation(this.$form);
+ this.$form.trigger('submit');
+ } else {
+ this.$input.trigger('validation.revalidate');
+ }
+ };
+
+ $.formUtils = $.extend($.formUtils || {}, {
+ asyncValidation: function(validatorName, $input, $form) {
+ // Return async validator attached to this input element
+ // or create a new async validator and attach it to the input
+ var asyncValidation,
+ input = $input.get(0);
+
+ if (!input.asyncValidators) {
+ input.asyncValidators = {};
+ }
+
+ if (input.asyncValidators[validatorName]) {
+ asyncValidation = input.asyncValidators[validatorName];
+ } else {
+ asyncValidation = new AsyncValidation($form, $input);
+ input.asyncValidators[validatorName] = asyncValidation;
+ }
+
+ return asyncValidation;
+ }
+ });
+
+})(jQuery);
+
+/**
+ * Deprecated functions and attributes
+ * @todo: Remove in release of 3.0
+ */
+(function ($, undefined) {
+
+ 'use strict';
+
+ /**
+ * @deprecated
+ * @param language
+ * @param conf
+ */
+ $.fn.validateForm = function (language, conf) {
+ $.formUtils.warn('Use of deprecated function $.validateForm, use $.isValid
instead');
+ return this.isValid(language, conf, true);
+ };
+
+ $(window)
+ .on('formValidationPluginInit', function(evt, config) {
+ convertDeprecatedLangCodeToISO6391(config);
+ addSupportForCustomErrorMessageCallback(config);
+ addSupportForElementReferenceInPositionParam(config);
+ })
+ .on('validatorsLoaded formValidationSetup', function(evt, $form) {
+ if( !$form ) {
+ $form = $('form');
+ }
+ addSupportForValidationDependingOnCheckedInput($form);
+ });
+
+
+ function addSupportForCustomErrorMessageCallback(config) {
+ if (config &&
+ config.errorMessagePosition === 'custom' &&
+ typeof config.errorMessageCustom === 'function') {
+
+ $.formUtils.warn('Use of deprecated function errorMessageCustom, use
config.submitErrorMessageCallback instead');
+
+ config.submitErrorMessageCallback = function($form, errorMessages) {
+ config.errorMessageCustom(
+ $form,
+ config.language.errorTitle,
+ errorMessages,
+ config
+ );
+ };
+ }
+ }
+
+ function addSupportForElementReferenceInPositionParam(config) {
+ if (config.errorMessagePosition && typeof config.errorMessagePosition ===
'object') {
+ $.formUtils.warn('Deprecated use of config parameter
errorMessagePosition, use config.submitErrorMessageCallback instead');
+ var $errorMessageContainer = config.errorMessagePosition;
+ config.errorMessagePosition = 'top';
+ config.submitErrorMessageCallback = function() {
+ return $errorMessageContainer;
+ };
+ }
+ }
+
+ function addSupportForValidationDependingOnCheckedInput($form) {
+ var $inputsDependingOnCheckedInputs =
$form.find('[data-validation-if-checked]');
+ if ($inputsDependingOnCheckedInputs.length) {
+ $.formUtils.warn(
+ 'Detected use of attribute "data-validation-if-checked" which is '+
+ 'deprecated. Use "data-validation-depends-on" provided by module
"logic"'
+ );
+ }
+
+ $inputsDependingOnCheckedInputs
+ .on('beforeValidation', function() {
+
+ var $elem = $(this),
+ nameOfDependingInput = $elem.valAttr('if-checked');
+
+ // Set the boolean telling us that the validation depends
+ // on another input being checked
+ var $dependingInput = $('input[name="' + nameOfDependingInput + '"]',
$form),
+ dependingInputIsChecked = $dependingInput.is(':checked'),
+ valueOfDependingInput = ($.formUtils.getValue($dependingInput) ||
'').toString(),
+ requiredValueOfDependingInput = $elem.valAttr('if-checked-value');
+
+ if (!dependingInputIsChecked || !(
+ !requiredValueOfDependingInput ||
+ requiredValueOfDependingInput === valueOfDependingInput
+ )) {
+ $elem.valAttr('skipped', true);
+ }
+
+ });
+ }
+
+ function convertDeprecatedLangCodeToISO6391(config) {
+ var deprecatedLangCodes = {
+ se: 'sv',
+ cz: 'cs',
+ dk: 'da'
+ };
+
+ if (config.lang in deprecatedLangCodes) {
+ var newLangCode = deprecatedLangCodes[config.lang];
+ $.formUtils.warn(
+ 'Deprecated use of lang code "'+config.lang+'" use "'+newLangCode+'"
instead'
+ );
+ config.lang = newLangCode;
+ }
+ }
+
+})(jQuery);
+
+/**
+ * Utility methods used for displaying error messages (attached to $.formUtils)
+ */
(function ($) {
'use strict';
- var $window = $(window),
- _getInputParentContainer = function ($elem) {
+ var dialogs = {
+
+ resolveErrorMessage: function($elem, validator, validatorName, conf,
language) {
+ var errorMsgAttr = conf.validationErrorMsgAttribute + '-' +
validatorName.replace('validate_', ''),
+ validationErrorMsg = $elem.attr(errorMsgAttr);
+
+ if (!validationErrorMsg) {
+ validationErrorMsg = $elem.attr(conf.validationErrorMsgAttribute);
+ if (!validationErrorMsg) {
+ if (typeof validator.errorMessageKey !== 'function') {
+ validationErrorMsg = language[validator.errorMessageKey];
+ }
+ else {
+ validationErrorMsg = language[validator.errorMessageKey(conf)];
+ }
+ if (!validationErrorMsg) {
+ validationErrorMsg = validator.errorMessage;
+ }
+ }
+ }
+ return validationErrorMsg;
+ },
+ getParentContainer: function ($elem) {
if ($elem.valAttr('error-msg-container')) {
return $($elem.valAttr('error-msg-container'));
} else {
var $parent = $elem.parent();
- if ( !$parent.hasClass('form-group') &&
!$parent.closest('form').hasClass('form-horizontal') ) {
+ if (!$parent.hasClass('form-group') &&
!$parent.closest('form').hasClass('form-horizontal')) {
var $formGroup = $parent.closest('.form-group');
if ($formGroup.length) {
return $formGroup.eq(0);
@@ -26,97 +293,177 @@
return $parent;
}
},
- _applyErrorStyle = function ($elem, conf) {
- $elem
+ applyInputErrorStyling: function ($input, conf) {
+ $input
.addClass(conf.errorElementClass)
.removeClass('valid');
- _getInputParentContainer($elem)
+ this.getParentContainer($input)
.addClass(conf.inputParentClassOnError)
.removeClass(conf.inputParentClassOnSuccess);
if (conf.borderColorOnError !== '') {
- $elem.css('border-color', conf.borderColorOnError);
+ $input.css('border-color', conf.borderColorOnError);
}
},
- _removeErrorStyle = function ($elem, conf) {
- $elem.each(function () {
- var $this = $(this);
+ applyInputSuccessStyling: function($input, conf) {
+ $input.addClass('valid');
+ this.getParentContainer($input)
+ .addClass(conf.inputParentClassOnSuccess);
+ },
+ removeInputStylingAndMessage: function($input, conf) {
- _setInlineErrorMessage($this, '', conf, conf.errorMessagePosition);
+ // Reset input css
+ $input
+ .removeClass('valid')
+ .removeClass(conf.errorElementClass)
+ .css('border-color', '');
- $this
- .removeClass('valid')
- .removeClass(conf.errorElementClass)
- .css('border-color', '');
+ var $parentContainer = dialogs.getParentContainer($input);
- _getInputParentContainer($this)
- .removeClass(conf.inputParentClassOnError)
- .removeClass(conf.inputParentClassOnSuccess)
- .find('.' + conf.errorMessageClass) // remove inline span holding
error message
- .remove();
+ // Reset parent css
+ $parentContainer
+ .removeClass(conf.inputParentClassOnError)
+ .removeClass(conf.inputParentClassOnSuccess);
+
+ // Remove possible error message
+ if (typeof conf.inlineErrorMessageCallback === 'function') {
+ var $errorMessage = conf.inlineErrorMessageCallback($input, false,
conf);
+ if ($errorMessage) {
+ $errorMessage.html('');
+ }
+ } else {
+ $parentContainer
+ .find('.' + conf.errorMessageClass)
+ .remove();
+ }
+
+ },
+ removeAllMessagesAndStyling: function($form, conf) {
+
+ // Remove error messages in top of form
+ if (typeof conf.submitErrorMessageCallback === 'function') {
+ var $errorMessagesInTopOfForm = conf.submitErrorMessageCallback($form,
false, conf);
+ if ($errorMessagesInTopOfForm) {
+ $errorMessagesInTopOfForm.html('');
+ }
+ } else {
+ $form.find('.' + conf.errorMessageClass + '.alert').remove();
+ }
+
+ // Remove input css/messages
+ $form.find('.' + conf.errorElementClass + ',.valid').each(function() {
+ dialogs.removeInputStylingAndMessage($(this), conf);
});
},
- _setInlineErrorMessage = function ($input, mess, conf, $messageContainer) {
+ setInlineMessage: function ($input, errorMsg, conf) {
+
+ this.applyInputErrorStyling($input, conf);
+
var custom = document.getElementById($input.attr('name') + '_err_msg'),
- setErrorMessage = function($elem) {
- $window.trigger('validationErrorDisplay', [$input, $elem]);
- $elem.html(mess);
- },
- $mess = {};
+ $messageContainer = false,
+ setErrorMessage = function ($elem) {
+ $.formUtils.$win.trigger('validationErrorDisplay', [$input, $elem]);
+ $elem.html(errorMsg);
+ },
+ addErrorToMessageContainer = function() {
+ var $found = false;
+ $messageContainer.find('.' + conf.errorMessageClass).each(function
() {
+ if (this.inputReferer === $input[0]) {
+ $found = $(this);
+ return false;
+ }
+ });
+ if ($found) {
+ if (!errorMsg) {
+ $found.remove();
+ } else {
+ setErrorMessage($found);
+ }
+ } else if(errorMsg !== '') {
+ $message = $('<div class="' + conf.errorMessageClass + '
alert"></div>');
+ setErrorMessage($message);
+ $message[0].inputReferer = $input[0];
+ $messageContainer.prepend($message);
+ }
+ },
+ $message;
if (custom) {
- setErrorMessage($(custom));
- }
- else if (typeof $messageContainer === 'object') {
- var $found = false;
- $messageContainer.find('.' + conf.errorMessageClass).each(function () {
- if (this.inputReferer === $input[0]) {
- $found = $(this);
- return false;
- }
- });
- if ($found) {
- if (!mess) {
- $found.remove();
- } else {
- setErrorMessage($found);
- }
- } else {
- $mess = $('<div class="' + conf.errorMessageClass + '"></div>');
- setErrorMessage($mess);
- $mess[0].inputReferer = $input[0];
- $messageContainer.prepend($mess);
+ // Todo: remove in 3.0
+ $.formUtils.warn('Using deprecated element reference ' + custom.id);
+ $messageContainer = $(custom);
+ addErrorToMessageContainer();
+ } else if (typeof conf.inlineErrorMessageCallback === 'function') {
+ $messageContainer = conf.inlineErrorMessageCallback($input, errorMsg,
conf);
+ if (!$messageContainer) {
+ // Error display taken care of by inlineErrorMessageCallback
+ return;
}
+ addErrorToMessageContainer();
+ } else {
+ var $parent = this.getParentContainer($input);
+ $message = $parent.find('.' + conf.errorMessageClass + '.help-block');
+ if ($message.length === 0) {
+ $message =
$('<span></span>').addClass('help-block').addClass(conf.errorMessageClass);
+ $message.appendTo($parent);
+ }
+ setErrorMessage($message);
}
- else {
- var $parent = _getInputParentContainer($input);
- $mess = $parent.find('.' + conf.errorMessageClass + '.help-block');
+ },
+ setMessageInTopOfForm: function ($form, errorMessages, conf, lang) {
+ var view = '<div class="{errorMessageClass} alert alert-danger">'+
+ '<strong>{errorTitle}</strong>'+
+ '<ul>{fields}</ul>'+
+ '</div>',
+ $container = false;
- if ($mess.length === 0) {
- $mess =
$('<span></span>').addClass('help-block').addClass(conf.errorMessageClass);
- $mess.appendTo($parent);
+ if (typeof conf.submitErrorMessageCallback === 'function') {
+ $container = conf.submitErrorMessageCallback($form, errorMessages,
conf);
+ if (!$container) {
+ // message display taken care of by callback
+ return;
}
-
- setErrorMessage($mess);
}
- },
- _templateMessage = function ($form, title, errorMessages, conf) {
- var messages =
conf.errorMessageTemplate.messages.replace(/\{errorTitle\}/g, title),
- fields = [],
- container;
+ var viewParams = {
+ errorTitle: lang.errorTitle,
+ fields: '',
+ errorMessageClass: conf.errorMessageClass
+ };
+
$.each(errorMessages, function (i, msg) {
- fields.push(conf.errorMessageTemplate.field.replace(/\{msg\}/g, msg));
+ viewParams.fields += '<li>'+msg+'</li>';
});
- messages = messages.replace(/\{fields\}/g, fields.join(''));
- container =
conf.errorMessageTemplate.container.replace(/\{errorMessageClass\}/g,
conf.errorMessageClass);
- container = container.replace(/\{messages\}/g, messages);
- $form.children().eq(0).before(container);
- };
+ $.each(viewParams, function(param, value) {
+ view = view.replace('{'+param+'}', value);
+ });
+ if ($container) {
+ $container.html(view);
+ } else {
+ $form.children().eq(0).before($(view));
+ }
+ }
+ };
+ $.formUtils = $.extend($.formUtils || {}, {
+ dialogs: dialogs
+ });
+
+})(jQuery);
+
+/**
+ * File declaring all methods if this plugin which is applied to $.fn.
+ */
+(function($, window, undefined) {
+
+ 'use strict';
+
+ var _helpers = 0;
+
+
/**
* Assigns validateInputOnBlur function to elements blur event
*
@@ -125,10 +472,28 @@
* @return {jQuery}
*/
$.fn.validateOnBlur = function (language, conf) {
- this.find('*[data-validation]')
- .bind('blur.validation', function () {
- $(this).validateInputOnBlur(language, conf, true, 'blur');
- });
+ var $form = this,
+ $elems = this.find('*[data-validation]');
+
+ $elems.each(function(){
+ var $this = $(this);
+ if ($this.is('[type=radio]')){
+ var $additionals = $form.find('[type=radio][name="' +
$this.attr('name') + '"]');
+ $additionals.bind('blur.validation', function(){
+ $this.validateInputOnBlur(language, conf, true, 'blur');
+ });
+ if (conf.validateCheckboxRadioOnClick) {
+ $additionals.bind('click.validation', function () {
+ $this.validateInputOnBlur(language, conf, true, 'click');
+ });
+ }
+ }
+ });
+
+ $elems.bind('blur.validation', function () {
+ $(this).validateInputOnBlur(language, conf, true, 'blur');
+ });
+
if (conf.validateCheckboxRadioOnClick) {
// bind click event to validate on click for radio & checkboxes for nice
UX
this.find('input[type=checkbox][data-validation],input[type=radio][data-validation]')
@@ -146,16 +511,19 @@
* @param {Object} settings Optional, will override the default settings
* * @return {jQuery}
*/
- $.fn.validateOnEvent = function (language, settings) {
- this.find('*[data-validation-event]')
+ $.fn.validateOnEvent = function (language, config) {
+ var $elements = this[0].nodeName === 'FORM' ?
this.find('*[data-validation-event]') : this;
+ $elements
.each(function () {
var $el = $(this),
- etype = $el.valAttr('event');
+ etype = $el.valAttr('event');
if (etype) {
$el
.unbind(etype + '.validation')
- .bind(etype + '.validation', function () {
- $(this).validateInputOnBlur(language, settings, true, etype);
+ .bind(etype + '.validation', function (evt) {
+ if( (evt || {}).keyCode !== 9 ) {
+ $(this).validateInputOnBlur(language, config, true, etype);
+ }
});
}
});
@@ -175,36 +543,35 @@
attrName = 'data-validation-help';
}
- // Remove previously added event listeners
- this.find('.has-help-txt')
- .valAttr('has-keyup-event', false)
- .removeClass('has-help-txt');
-
// Add help text listeners
this.find('textarea,input').each(function () {
var $elem = $(this),
- className = 'jquery_form_help_' + ($elem.attr('name') ||
'').replace(/(:|\.|\[|\])/g, ''),
- help = $elem.attr(attrName);
+ className = 'jquery_form_help_' + (++_helpers),
+ help = $elem.attr(attrName);
+ // Reset
+ $elem
+ .removeClass('has-help-text')
+ .unbind('focus.help')
+ .unbind('blur.help');
+
if (help) {
$elem
.addClass('has-help-txt')
- .unbind('focus.help')
.bind('focus.help', function () {
var $help = $elem.parent().find('.' + className);
if ($help.length === 0) {
$help = $('<span />')
- .addClass(className)
- .addClass('help')
- .addClass('help-block') // twitter bs
- .text(help)
- .hide();
+ .addClass(className)
+ .addClass('help')
+ .addClass('help-block') // twitter bs
+ .text(help)
+ .hide();
$elem.after($help);
}
$help.fadeIn();
})
- .unbind('blur.help')
.bind('blur.help', function () {
$(this)
.parent()
@@ -226,7 +593,7 @@
var language = $.extend({}, $.formUtils.LANG, lang || {});
this.each(function() {
var $elem = $(this),
- formDefaultConfig = $elem.closest('form').get(0).validationConfig ||
{};
+ formDefaultConfig = $elem.closest('form').get(0).validationConfig ||
{};
$elem.one('validation', function(evt, isValid) {
if ( typeof cb === 'function' ) {
@@ -235,10 +602,10 @@
});
$elem.validateInputOnBlur(
- language,
- $.extend({}, formDefaultConfig, conf || {}),
- true
- );
+ language,
+ $.extend({}, formDefaultConfig, conf || {}),
+ true
+ );
});
};
@@ -248,9 +615,9 @@
*/
$.fn.willPostponeValidation = function() {
return (this.valAttr('suggestion-nr') ||
- this.valAttr('postpone') ||
- this.hasClass('hasDatepicker')) &&
- !window.postponedValidation;
+ this.valAttr('postpone') ||
+ this.hasClass('hasDatepicker')) &&
+ !window.postponedValidation;
};
/**
@@ -261,20 +628,20 @@
* @param {Object} [language] Optional, will override $.formUtils.LANG
* @param {Object} [conf] Optional, will override the default settings
* @param {Boolean} attachKeyupEvent Optional
- * @param {String} eventType
+ * @param {String} eventContext
* @return {jQuery}
*/
- $.fn.validateInputOnBlur = function (language, conf, attachKeyupEvent,
eventType) {
+ $.fn.validateInputOnBlur = function (language, conf, attachKeyupEvent,
eventContext) {
- $.formUtils.eventType = eventType;
+ $.formUtils.eventType = eventContext;
if ( this.willPostponeValidation() ) {
// This validation has to be postponed
var _self = this,
- postponeTime = this.valAttr('postpone') || 200;
+ postponeTime = this.valAttr('postpone') || 200;
window.postponedValidation = function () {
- _self.validateInputOnBlur(language, conf, attachKeyupEvent, eventType);
+ _self.validateInputOnBlur(language, conf, attachKeyupEvent,
eventContext);
window.postponedValidation = false;
};
@@ -288,38 +655,75 @@
}
language = $.extend({}, $.formUtils.LANG, language || {});
- _removeErrorStyle(this, conf);
+ $.formUtils.dialogs.removeInputStylingAndMessage(this, conf);
+
var $elem = this,
- $form = $elem.closest('form'),
- result = $.formUtils.validateInput(
- $elem,
- language,
- conf,
- $form,
- eventType
- );
+ $form = $elem.closest('form'),
+ result = $.formUtils.validateInput(
+ $elem,
+ language,
+ conf,
+ $form,
+ eventContext
+ );
- if ( result.isValid ) {
- if( result.shouldChangeDisplay ) {
- $elem.addClass('valid');
- _getInputParentContainer($elem)
- .addClass(conf.inputParentClassOnSuccess);
+ var reValidate = function() {
+ $elem.validateInputOnBlur(language, conf, false, 'blur.revalidated');
+ };
+
+ if (eventContext === 'blur') {
+ $elem
+ .unbind('validation.revalidate', reValidate)
+ .one('validation.revalidate', reValidate);
+ }
+
+ if (attachKeyupEvent) {
+ $elem.removeKeyUpValidation();
+ }
+
+ if (result.shouldChangeDisplay) {
+ if (result.isValid) {
+ $.formUtils.dialogs.applyInputSuccessStyling($elem, conf);
+ } else {
+ $.formUtils.dialogs.setInlineMessage($elem, result.errorMsg, conf);
}
}
- else if (!result.isValid) {
- _applyErrorStyle($elem, conf);
- _setInlineErrorMessage($elem, result.errorMsg, conf,
conf.errorMessagePosition);
+ if (!result.isValid && attachKeyupEvent) {
+ $elem.validateOnKeyUp(language, conf);
+ }
- if (attachKeyupEvent) {
- $elem
- .unbind('keyup.validation')
- .bind('keyup.validation', function () {
- $(this).validateInputOnBlur(language, conf, false, 'keyup');
+ return this;
+ };
+
+ /**
+ * Validate element on keyup-event
+ */
+ $.fn.validateOnKeyUp = function(language, conf) {
+ this.each(function() {
+ var $input = $(this);
+ if (!$input.valAttr('has-keyup-event')) {
+ $input
+ .valAttr('has-keyup-event', 'true')
+ .bind('keyup.validation', function (evt) {
+ if( evt.keyCode !== 9 ) {
+ $input.validateInputOnBlur(language, conf, false, 'keyup');
+ }
});
}
- }
+ });
+ return this;
+ };
+ /**
+ * Remove validation on keyup
+ */
+ $.fn.removeKeyUpValidation = function() {
+ this.each(function() {
+ $(this)
+ .valAttr('has-keyup-event', false)
+ .unbind('keyup.validation');
+ });
return this;
};
@@ -329,7 +733,7 @@
*
* @param {String} name
* @param {String|Boolean} [val]
- * @return string|undefined
+ * @return {String|undefined|jQuery}
* @protected
*/
$.fn.valAttr = function (name, val) {
@@ -371,9 +775,6 @@
displayError = false;
}
- $.formUtils.isValidatingEntireForm = true;
- $.formUtils.haltValidation = false;
-
/**
* Adds message to error message stack if not already in the message stack
*
@@ -381,27 +782,27 @@
* @para {jQuery} $elem
*/
var addErrorMessage = function (mess, $elem) {
- if ($.inArray(mess, errorMessages) < 0) {
- errorMessages.push(mess);
- }
- errorInputs.push($elem);
- $elem.attr('current-error', mess);
- if (displayError) {
- _applyErrorStyle($elem, conf);
- }
- },
+ if ($.inArray(mess, errorMessages) < 0) {
+ errorMessages.push(mess);
+ }
+ errorInputs.push($elem);
+ $elem.attr('current-error', mess);
+ if (displayError) {
+ $.formUtils.dialogs.applyInputErrorStyling($elem, conf);
+ }
+ },
- /** Holds inputs (of type checkox or radio) already validated, to
prevent recheck of mulitple checkboxes & radios */
- checkedInputs = [],
+ /** Holds inputs (of type checkox or radio) already validated, to
prevent recheck of mulitple checkboxes & radios */
+ checkedInputs = [],
- /** Error messages for this validation */
- errorMessages = [],
+ /** Error messages for this validation */
+ errorMessages = [],
- /** Input elements which value was not valid */
- errorInputs = [],
+ /** Input elements which value was not valid */
+ errorInputs = [],
- /** Form instance */
- $form = this,
+ /** Form instance */
+ $form = this,
/**
* Tells whether or not to validate element with this name and of this
type
@@ -410,7 +811,7 @@
* @param {String} type
* @return {Boolean}
*/
- ignoreInput = function (name, type) {
+ ignoreInput = function (name, type) {
if (type === 'submit' || type === 'button' || type === 'reset') {
return true;
}
@@ -419,8 +820,7 @@
// Reset style and remove error class
if (displayError) {
- $form.find('.' + conf.errorMessageClass + '.alert').remove();
- _removeErrorStyle($form.find('.' + conf.errorElementClass + ',.valid'),
conf);
+ $.formUtils.dialogs.removeAllMessagesAndStyling($form, conf);
}
// Validate element values
@@ -437,26 +837,21 @@
}
var result = $.formUtils.validateInput(
- $elem,
- language,
- conf,
- $form,
- 'submit'
- );
+ $elem,
+ language,
+ conf,
+ $form,
+ 'submit'
+ );
- if( result.shouldChangeDisplay ) {
- if ( !result.isValid ) {
- addErrorMessage(result.errorMsg, $elem);
- } else if( result.isValid ) {
- $elem
- .valAttr('current-error', false)
- .addClass('valid');
-
- _getInputParentContainer($elem)
- .addClass(conf.inputParentClassOnSuccess);
- }
+ if (!result.isValid) {
+ addErrorMessage(result.errorMsg, $elem);
+ } else if (result.isValid && result.shouldChangeDisplay) {
+ $elem.valAttr('current-error', false);
+ $.formUtils.dialogs.applyInputSuccessStyling($elem, conf);
}
}
+
});
// Run validation callback
@@ -476,54 +871,29 @@
$.formUtils.isValidatingEntireForm = false;
// Validation failed
- if (!$.formUtils.haltValidation && errorInputs.length > 0) {
-
+ if (errorInputs.length > 0) {
if (displayError) {
- // display all error messages in top of form
if (conf.errorMessagePosition === 'top') {
- _templateMessage($form, language.errorTitle, errorMessages, conf);
- }
- // Customize display message
- else if (conf.errorMessagePosition === 'custom') {
- if (typeof conf.errorMessageCustom === 'function') {
- conf.errorMessageCustom($form, language.errorTitle, errorMessages,
conf);
- }
- }
- // Display error message below input field or in defined container
- else {
+ $.formUtils.dialogs.setMessageInTopOfForm($form, errorMessages,
conf, language);
+ } else {
$.each(errorInputs, function (i, $input) {
- _setInlineErrorMessage($input, $input.attr('current-error'), conf,
conf.errorMessagePosition);
+ $.formUtils.dialogs.setInlineMessage($input,
$input.attr('current-error'), conf);
});
}
-
if (conf.scrollToTopOnError) {
- $window.scrollTop($form.offset().top - 20);
+ $.formUtils.$win.scrollTop($form.offset().top - 20);
}
}
-
- return false;
}
if (!displayError && $.formUtils.haltValidation) {
$.formUtils.errorDisplayPreventedWhenHalted = true;
}
- return !$.formUtils.haltValidation;
+ return errorInputs.length === 0 && !$.formUtils.haltValidation;
};
/**
- * @deprecated
- * @param language
- * @param conf
- */
- $.fn.validateForm = function (language, conf) {
- if (window.console && typeof window.console.warn === 'function') {
- window.console.warn('Use of deprecated function $.validateForm, use
$.isValid instead');
- }
- return this.isValid(language, conf, true);
- };
-
- /**
* Plugin for displaying input length restriction
*/
$.fn.restrictLength = function (maxLengthElement) {
@@ -552,21 +922,180 @@
return this;
};
+
+})(jQuery, window);
+
+/**
+ * Utility methods used for handling loading of modules (attached to
$.formUtils)
+ */
+(function($) {
+
+ 'use strict';
+
+ $.formUtils = $.extend($.formUtils || {}, {
+
+ /**
+ * @var {Boolean}
+ */
+ isLoadingModules: false,
+
+ /**
+ * @var {Object}
+ */
+ loadedModules: {},
+
+ /**
+ * @example
+ * $.formUtils.loadModules('date, security.dev');
+ *
+ * Will load the scripts date.js and security.dev.js from the
+ * directory where this script resides. If you want to load
+ * the modules from another directory you can use the
+ * path argument.
+ *
+ * The script will be cached by the browser unless the module
+ * name ends with .dev
+ *
+ * @param {String} modules - Comma separated string with module file names
(no directory nor file extension)
+ * @param {String} [path] - Optional, path where the module files is
located if their not in the same directory as the core modules
+ * @param {function} [callback] - Optional, whether or not to fire event
'load' when modules finished loading
+ */
+ loadModules: function (modules, path, callback) {
+
+ if ($.formUtils.isLoadingModules) {
+ setTimeout(function () {
+ $.formUtils.loadModules(modules, path, callback);
+ }, 10);
+ return;
+ }
+
+ var hasLoadedAnyModule = false,
+ loadModuleScripts = function (modules, path) {
+
+ var moduleList = $.split(modules),
+ numModules = moduleList.length,
+ moduleLoadedCallback = function () {
+ numModules--;
+ if (numModules === 0) {
+ $.formUtils.isLoadingModules = false;
+ if (callback && hasLoadedAnyModule) {
+ if( typeof callback === 'function' ) {
+ callback();
+ }
+ }
+ }
+ };
+
+
+ if (numModules > 0) {
+ $.formUtils.isLoadingModules = true;
+ }
+
+ var cacheSuffix = '?_=' + ( new Date().getTime() ),
+ appendToElement = document.getElementsByTagName('head')[0] ||
document.getElementsByTagName('body')[0];
+
+ $.each(moduleList, function (i, modName) {
+ modName = $.trim(modName);
+ if (modName.length === 0) {
+ moduleLoadedCallback();
+ }
+ else {
+ var scriptUrl = path + modName + (modName.slice(-3) === '.js' ?
'' : '.js'),
+ script = document.createElement('SCRIPT');
+
+ if (scriptUrl in $.formUtils.loadedModules) {
+ // already loaded
+ moduleLoadedCallback();
+ }
+ else {
+
+ // Remember that this script is loaded
+ $.formUtils.loadedModules[scriptUrl] = 1;
+ hasLoadedAnyModule = true;
+
+ // Load the script
+ script.type = 'text/javascript';
+ script.onload = moduleLoadedCallback;
+ script.src = scriptUrl + ( scriptUrl.slice(-7) === '.dev.js' ?
cacheSuffix : '' );
+ script.onerror = function() {
+ $.formUtils.warn('Unable to load form validation module
'+scriptUrl);
+ };
+ script.onreadystatechange = function () {
+ // IE 7 fix
+ if (this.readyState === 'complete' || this.readyState ===
'loaded') {
+ moduleLoadedCallback();
+ // Handle memory leak in IE
+ this.onload = null;
+ this.onreadystatechange = null;
+ }
+ };
+ appendToElement.appendChild(script);
+ }
+ }
+ });
+ };
+
+ if (path) {
+ loadModuleScripts(modules, path);
+ } else {
+ var findScriptPathAndLoadModules = function () {
+ var foundPath = false;
+ $('script[src*="form-validator"]').each(function () {
+ var isScriptFromPluginNodeModulesDirectory =
this.src.split('form-validator')[1].split('node_modules').length > 1;
+ if (!isScriptFromPluginNodeModulesDirectory) {
+ foundPath = this.src.substr(0, this.src.lastIndexOf('/')) + '/';
+ if (foundPath === '/') {
+ foundPath = '';
+ }
+ return false;
+ }
+ });
+
+ if (foundPath !== false) {
+ loadModuleScripts(modules, foundPath);
+ return true;
+ }
+ return false;
+ };
+
+ if (!findScriptPathAndLoadModules()) {
+ $(findScriptPathAndLoadModules);
+ }
+ }
+ }
+
+ });
+
+})(jQuery);
+
+/**
+ * Setup function for the plugin
+ */
+(function ($) {
+
+ 'use strict';
+
+
/**
* A bit smarter split function
* delimiter can be space, comma, dash or pipe
* @param {String} val
* @param {Function|String} [callback]
+ * @param {Boolean} [allowSpaceAsDelimiter]
* @returns {Array|void}
*/
- $.split = function (val, callback) {
+ $.split = function (val, callback, allowSpaceAsDelimiter) {
+ // default to true
+ allowSpaceAsDelimiter = allowSpaceAsDelimiter === undefined ||
allowSpaceAsDelimiter === true;
+ var pattern = '[,|\-'+(allowSpaceAsDelimiter ? '\\s':'')+']\\s*',
+ regex = new RegExp(pattern, 'g');
if (typeof callback !== 'function') {
// return array
if (!val) {
return [];
}
var values = [];
- $.each(val.split(callback ? callback : /[,|\-\s]\s*/g),
+ $.each(val.split(callback ? callback : regex),
function (i, str) {
str = $.trim(str);
if (str.length) {
@@ -577,7 +1106,7 @@
return values;
} else if (val) {
// exec callback func on each
- $.each(val.split(/[,|\-\s]\s*/g),
+ $.each(val.split(regex),
function (i, str) {
str = $.trim(str);
if (str.length) {
@@ -596,9 +1125,6 @@
var defaultConf = $.extend($.formUtils.defaultConfig(), {
form: 'form',
- /*
- * Enable custom event for validation
- */
validateOnEvent: false,
validateOnBlur: true,
validateCheckboxRadioOnClick: true,
@@ -609,11 +1135,13 @@
language: false,
onSuccess: false,
onError: false,
- onElementValidate: false,
+ onElementValidate: false
});
conf = $.extend(defaultConf, conf || {});
+ $(window).trigger('formValidationPluginInit', [conf]);
+
if( conf.lang && conf.lang !== 'en' ) {
var langModule = 'lang/'+conf.lang+'.js';
conf.modules += conf.modules.length ? ','+langModule : langModule;
@@ -625,9 +1153,9 @@
// Make a reference to the config for this form
form.validationConfig = conf;
- // Trigger jQuery event that we're about to setup va
+ // Trigger jQuery event that we're about to setup validation
var $form = $(form);
- $window.trigger('formValidationSetup', [$form, conf]);
+ $form.trigger('formValidationSetup', [$form, conf]);
// Remove classes and event handlers that might have been
// added by a previous call to $.validate
@@ -643,45 +1171,46 @@
.unbind('blur.validation');
// Validate when submitted
- $form.bind('submit.validation', function () {
+ $form.bind('submit.validation', function (evt) {
- var $form = $(this);
+ var $form = $(this),
+ stop = function() {
+ evt.stopImmediatePropagation();
+ return false;
+ };
if ($.formUtils.haltValidation) {
// pressing several times on submit button while validation is halted
- return false;
+ return stop();
}
if ($.formUtils.isLoadingModules) {
setTimeout(function () {
$form.trigger('submit.validation');
}, 200);
- return false;
+ return stop();
}
var valid = $form.isValid(conf.language, conf);
-
if ($.formUtils.haltValidation) {
// Validation got halted by one of the validators
- return false;
+ return stop();
} else {
if (valid && typeof conf.onSuccess === 'function') {
var callbackResponse = conf.onSuccess($form);
if (callbackResponse === false) {
- return false;
+ return stop();
}
} else if (!valid && typeof conf.onError === 'function') {
conf.onError($form);
- return false;
+ return stop();
} else {
- return valid;
+ return valid ? true : stop();
}
}
})
.bind('reset.validation', function () {
- // remove messages
- $(this).find('.' + conf.errorMessageClass + '.alert').remove();
- _removeErrorStyle($(this).find('.' + conf.errorElementClass +
',.valid'), conf);
+ $.formUtils.dialogs.removeAllMessagesAndStyling($form, conf);
})
.addClass('has-validation-callback');
@@ -707,34 +1236,44 @@
if (typeof conf.onModulesLoaded === 'function') {
conf.onModulesLoaded();
}
- $window.trigger('validatorsLoaded', [typeof conf.form === 'string' ?
$(conf.form) : conf.form, conf]);
+ var $form = typeof conf.form === 'string' ? $(conf.form) : conf.form;
+ $.formUtils.$win.trigger('validatorsLoaded', [$form, conf]);
});
}
};
- /**
- * Object containing utility methods for this plugin
- */
- $.formUtils = {
+})(jQuery);
+/**
+ * Utility methods and properties attached to $.formUtils
+ */
+(function($, window) {
+
+ 'use strict';
+
+ var $win = $(window);
+
+ $.formUtils = $.extend($.formUtils || {}, {
+
+ $win: $win,
+
/**
* Default config for $(...).isValid();
*/
defaultConfig: function () {
return {
- ignore: [], // Names of inputs not to be validated even though node
attribute containing the validation rules tells us to
+ ignore: [], // Names of inputs not to be validated even though
`validationRuleAttribute` containing the validation rules tells us to
errorElementClass: 'error', // Class that will be put on elements
which value is invalid
borderColorOnError: '#b94a48', // Border color of elements which value
is invalid, empty string to not change border color
errorMessageClass: 'form-error', // class name of div containing error
messages when validation fails
validationRuleAttribute: 'data-validation', // name of the attribute
holding the validation rules
validationErrorMsgAttribute: 'data-validation-error-msg', // define
custom err msg inline with element
- errorMessagePosition: 'element', // Can be either "top" or "element"
or "custom"
+ errorMessagePosition: 'inline', // Can be either "top" or "inline"
errorMessageTemplate: {
container: '<div class="{errorMessageClass} alert
alert-danger">{messages}</div>',
messages: '<strong>{errorTitle}</strong><ul>{fields}</ul>',
field: '<li>{msg}</li>'
},
- errorMessageCustom: _templateMessage,
scrollToTopOnError: true,
dateFormat: 'yyyy-mm-dd',
addValidClassOnAll: false, // whether or not to apply class="valid"
even if the input wasn't validated
@@ -742,6 +1281,8 @@
inputParentClassOnError: 'has-error', // twitter-bootstrap default
class name
inputParentClassOnSuccess: 'has-success', // twitter-bootstrap default
class name
validateHiddenInputs: false, // whether or not hidden inputs should be
validated
+ inlineErrorMessageCallback: false,
+ submitErrorMessageCallback: false
};
},
@@ -763,12 +1304,6 @@
haltValidation: false,
/**
- * This variable will be true $.fn.isValid() is called
- * and false when $.fn.validateOnBlur is called
- */
- isValidatingEntireForm: false,
-
- /**
* Function for adding a validator
* @param {Object} validator
*/
@@ -782,138 +1317,42 @@
},
/**
- * @var {Boolean}
+ * Warn user via the console if available
*/
- isLoadingModules: false,
+ warn: function(msg) {
+ if( 'console' in window ) {
+ if( typeof window.console.warn === 'function' ) {
+ window.console.warn(msg);
+ } else if( typeof window.console.log === 'function' ) {
+ window.console.log(msg);
+ }
+ } else {
+ alert(msg);
+ }
+ },
/**
- * @var {Object}
- */
- loadedModules: {},
-
- /**
+ * Same as input $.fn.val() but also supporting input of typ radio or
checkbox
* @example
- * $.formUtils.loadModules('date, security.dev');
*
- * Will load the scripts date.js and security.dev.js from the
- * directory where this script resides. If you want to load
- * the modules from another directory you can use the
- * path argument.
+ * $.formUtils.getValue('.myRadioButtons', $('#some-form'));
+ * $.formUtils.getValue($('#some-form').find('.check-boxes'));
*
- * The script will be cached by the browser unless the module
- * name ends with .dev
- *
- * @param {String} modules - Comma separated string with module file names
(no directory nor file extension)
- * @param {String} [path] - Optional, path where the module files is
located if their not in the same directory as the core modules
- * @param {Boolean|function} [fireEvent] - Optional, whether or not to
fire event 'load' when modules finished loading
+ * @param query
+ * @param $parent
+ * @returns {String|Boolean}
*/
- loadModules: function (modules, path, fireEvent) {
-
- if (fireEvent === undefined) {
- fireEvent = true;
- }
-
- if ($.formUtils.isLoadingModules) {
- setTimeout(function () {
- $.formUtils.loadModules(modules, path, fireEvent);
- });
- return;
- }
-
- var hasLoadedAnyModule = false,
- loadModuleScripts = function (modules, path) {
-
- var moduleList = $.split(modules),
- numModules = moduleList.length,
- moduleLoadedCallback = function () {
- numModules--;
- if (numModules === 0) {
- $.formUtils.isLoadingModules = false;
- if (fireEvent && hasLoadedAnyModule) {
- if( typeof fireEvent === 'function' ) {
- fireEvent();
- } else {
- $window.trigger('validatorsLoaded');
- }
- }
- }
- };
-
-
- if (numModules > 0) {
- $.formUtils.isLoadingModules = true;
- }
-
- var cacheSuffix = '?_=' + ( new Date().getTime() ),
- appendToElement = document.getElementsByTagName('head')[0] ||
document.getElementsByTagName('body')[0];
-
- $.each(moduleList, function (i, modName) {
- modName = $.trim(modName);
- if (modName.length === 0) {
- moduleLoadedCallback();
- }
- else {
- var scriptUrl = path + modName + (modName.slice(-3) === '.js' ?
'' : '.js'),
- script = document.createElement('SCRIPT');
-
- if (scriptUrl in $.formUtils.loadedModules) {
- // already loaded
- moduleLoadedCallback();
- }
- else {
-
- // Remember that this script is loaded
- $.formUtils.loadedModules[scriptUrl] = 1;
- hasLoadedAnyModule = true;
-
- // Load the script
- script.type = 'text/javascript';
- script.onload = moduleLoadedCallback;
- script.src = scriptUrl + ( scriptUrl.slice(-7) === '.dev.js' ?
cacheSuffix : '' );
- script.onerror = function() {
- if( 'console' in window && window.console.log ) {
- window.console.log('Unable to load form validation module
'+scriptUrl);
- }
- };
- script.onreadystatechange = function () {
- // IE 7 fix
- if (this.readyState === 'complete' || this.readyState ===
'loaded') {
- moduleLoadedCallback();
- // Handle memory leak in IE
- this.onload = null;
- this.onreadystatechange = null;
- }
- };
- appendToElement.appendChild(script);
- }
- }
- });
- };
-
- if (path) {
- loadModuleScripts(modules, path);
- } else {
- var findScriptPathAndLoadModules = function () {
- var foundPath = false;
- $('script[src*="form-validator"]').each(function () {
- foundPath = this.src.substr(0, this.src.lastIndexOf('/')) + '/';
- if (foundPath === '/') {
- foundPath = '';
- }
- return false;
- });
-
- if (foundPath !== false) {
- loadModuleScripts(modules, foundPath);
- return true;
- }
- return false;
- };
-
- if (!findScriptPathAndLoadModules()) {
- $(findScriptPathAndLoadModules);
+ getValue: function(query, $parent) {
+ var $inputs = $parent ? $parent.find(query) : query;
+ if ($inputs.length > 0 ) {
+ var type = $inputs.eq(0).attr('type');
+ if (type === 'radio' || type === 'checkbox') {
+ return $inputs.filter(':checked').val() || '';
+ } else {
+ return $inputs.val() || '';
}
}
+ return false;
},
/**
@@ -929,85 +1368,61 @@
*/
validateInput: function ($elem, language, conf, $form, eventContext) {
- $elem.trigger('beforeValidation');
conf = conf || $.formUtils.defaultConfig();
language = language || $.formUtils.LANG;
- var value = $elem.val() || '',
- result = {isValid: true, shouldChangeDisplay:true, errorMsg:''},
- optional = $elem.valAttr('optional'),
+ var value = this.getValue($elem);
- // test if a checkbox forces this element to be validated
- validationDependsOnCheckedInput = false,
- validationDependentInputIsChecked = false,
- validateIfCheckedElement = false,
+ $elem
+ .valAttr('skipped', false)
+ .one('beforeValidation', function() {
+ // Skip input because its hidden or disabled
+ // Doing this in a callback makes it possible for others to prevent
the default
+ // behaviour by binding to the same event and call
evt.stopImmediatePropagation()
+ if ($elem.attr('disabled') || (!$elem.is(':visible') &&
!conf.validateHiddenInputs)) {
+ $elem.valAttr('skipped', 1);
+ }
+ })
+ .trigger('beforeValidation', [value, conf, language]);
- // get value of this element's attribute "... if-checked"
- validateIfCheckedElementName = $elem.valAttr('if-checked'),
- // get expected radio button value for "if-checked" optional
validation
- validateIfCheckedElementValue = $elem.valAttr('if-checked-value');
+ var inputIsOptional = $elem.valAttr('optional') === 'true',
+ skipBecauseItsEmpty = !value && inputIsOptional,
+ validationRules = $elem.attr(conf.validationRuleAttribute),
+ isValid = true,
+ errorMsg = '',
+ result = {isValid: true, shouldChangeDisplay:true, errorMsg:''};
- if ($elem.attr('disabled') || (!$elem.is(':visible') &&
!conf.validateHiddenInputs)) {
- result.shouldChangeDisplay = false;
- return result;
- }
+ // For input type="number", browsers attempt to parse the entered value
into a number.
+ // If the input is not numeric, browsers handle the situation
differently:
+ // Chrome 48 simply disallows non-numeric input; FF 44 clears out the
input box on blur;
+ // Safari 5 parses the entered string to find a leading number.
+ // If the input fails browser validation, the browser sets the input
value equal to an empty string.
+ // Therefore, we cannot distinguish (apart from hacks) between an empty
input type="text" and one with a
+ // value that can't be parsed by the browser.
- // make sure we can proceed
- if (validateIfCheckedElementName != null) {
-
- // Set the boolean telling us that the validation depends
- // on another input being checked
- validationDependsOnCheckedInput = true;
-
- // select the checkbox type element in this form
- validateIfCheckedElement = $form.find('input[name="' +
validateIfCheckedElementName + '"]');
-
- // test if check input value
- if (validateIfCheckedElementValue != null) {
- validateIfCheckedElement.each(function(index, el) {
- // test if it's property "checked" is checked and value equals
expected value
- if ($(el).prop('checked') && $(el).val() ===
validateIfCheckedElementValue) {
- validationDependentInputIsChecked = true;
- }
- });
- }
- else {
- // test if it's property "checked" is checked
- if (validateIfCheckedElement.prop('checked')) {
- // set value for validation checkpoint
- validationDependentInputIsChecked = true;
- }
- }
- }
-
- // validation checkpoint
- // if empty AND optional attribute is present
- // OR depending on a checkbox being checked AND checkbox is checked,
return true
- var isInvalidNumberInput = !value && $elem[0].type === 'number';
- if ((!value && optional === 'true' && !isInvalidNumberInput) ||
(validationDependsOnCheckedInput && !validationDependentInputIsChecked)) {
+ if (!validationRules || skipBecauseItsEmpty || $elem.valAttr('skipped'))
{
result.shouldChangeDisplay = conf.addValidClassOnAll;
return result;
}
- var validationRules = $elem.attr(conf.validationRuleAttribute),
-
- // see if form element has inline err msg attribute
- validationErrorMsg = true;
-
- if (!validationRules) {
- result.shouldChangeDisplay = conf.addValidClassOnAll;
- return result;
+ // Filter out specified characters
+ var ignore = $elem.valAttr('ignore');
+ if (ignore) {
+ $.each(ignore.split(''), function(i, character) {
+ value = value.replace(new RegExp('\\'+character, 'g'), '');
+ });
}
$.split(validationRules, function (rule) {
+
if (rule.indexOf('validate_') !== 0) {
rule = 'validate_' + rule;
}
var validator = $.formUtils.validators[rule];
- if (validator && typeof validator.validatorFunction === 'function') {
+ if (validator) {
// special change of element for checkbox_group rule
if (rule === 'validate_checkbox_group') {
@@ -1015,56 +1430,52 @@
$elem = $form.find('[name="' + $elem.attr('name') + '"]:eq(0)');
}
- var isValid = null;
if (eventContext !== 'keyup' || validator.validateOnKeyUp) {
- isValid = validator.validatorFunction(value, $elem, conf,
language, $form);
+ // A validator can prevent itself from getting triggered on keyup
+ isValid = validator.validatorFunction(value, $elem, conf,
language, $form, eventContext);
}
if (!isValid) {
- validationErrorMsg = null;
- if (isValid !== null) {
- validationErrorMsg = $elem.attr(conf.validationErrorMsgAttribute
+ '-' + rule.replace('validate_', ''));
- if (!validationErrorMsg) {
- validationErrorMsg =
$elem.attr(conf.validationErrorMsgAttribute);
- if (!validationErrorMsg) {
- if (typeof validator.errorMessageKey !== 'function') {
- validationErrorMsg = language[validator.errorMessageKey];
- }
- else {
- validationErrorMsg =
language[validator.errorMessageKey(conf)];
- }
- if (!validationErrorMsg) {
- validationErrorMsg = validator.errorMessage;
- }
- }
- }
+ if (conf.validateOnBlur) {
+ $elem.validateOnKeyUp(language, conf);
}
+ errorMsg = $.formUtils.dialogs.resolveErrorMessage($elem,
validator, rule, conf, language);
return false; // break iteration
}
} else {
- throw new Error('Using undefined validator "' + rule + '"');
+
+ // todo: Add some validator lookup function and tell immediately
which module is missing
+ throw new Error('Using undefined validator "' + rule +
+ '". Maybe you have forgotten to load the module that "' + rule +'"
belongs to?');
+
}
- }, ' ');
+ });
- if (typeof validationErrorMsg === 'string') {
+
+ if (isValid === false) {
$elem.trigger('validation', false);
- result.errorMsg = validationErrorMsg;
+ result.errorMsg = errorMsg;
result.isValid = false;
result.shouldChangeDisplay = true;
- } else if (validationErrorMsg === null) {
- result.shouldChangeDisplay = conf.addValidClassOnAll;
+ } else if (isValid === null) {
+ // A validatorFunction returning null means that it's not able to
validate
+ // the input at this time. Most probably some async stuff need to gets
finished
+ // first and then the validator will re-trigger the validation.
+ result.shouldChangeDisplay = false;
} else {
$elem.trigger('validation', true);
result.shouldChangeDisplay = true;
}
// Run element validation callback
- if (typeof conf.onElementValidate === 'function' && validationErrorMsg
!== null) {
- conf.onElementValidate(result.isValid, $elem, $form,
validationErrorMsg);
+ if (typeof conf.onElementValidate === 'function' && errorMsg !== null) {
+ conf.onElementValidate(result.isValid, $elem, $form, errorMsg);
}
+ $elem.trigger('afterValidation', [result, eventContext]);
+
return result;
},
@@ -1074,9 +1485,10 @@
*
* @param {String} val
* @param {String} dateFormat
+ * @param {Boolean} [addMissingLeadingZeros]
* @return {Array}|{Boolean}
*/
- parseDate: function (val, dateFormat) {
+ parseDate: function (val, dateFormat, addMissingLeadingZeros) {
var divider = dateFormat.replace(/[a-zA-Z]/gi, '').substring(0, 1),
regexp = '^',
formatParts = dateFormat.split(divider || null),
@@ -1088,6 +1500,17 @@
regexp += '$';
+ if (addMissingLeadingZeros) {
+ var newValueParts = [];
+ $.each(val.split(divider), function(i, part) {
+ if(part.length === 1) {
+ part = '0'+part;
+ }
+ newValueParts.push(part);
+ });
+ val = newValueParts.join(divider);
+ }
+
matches = val.match(new RegExp(regexp));
if (matches === null) {
return false;
@@ -1107,8 +1530,8 @@
year = findDateUnit('y', formatParts, matches);
if ((month === 2 && day > 28 && (year % 4 !== 0 || year % 100 === 0 &&
year % 400 !== 0)) ||
- (month === 2 && day > 29 && (year % 4 === 0 || year % 100 !== 0 && year
% 400 === 0)) ||
- month > 12 || month === 0) {
+ (month === 2 && day > 29 && (year % 4 === 0 || year % 100 !== 0 &&
year % 400 === 0)) ||
+ month > 12 || month === 0) {
return false;
}
if ((this.isShortMonth(month) && day > 30) || (!this.isShortMonth(month)
&& day > 31) || day === 0) {
@@ -1122,7 +1545,7 @@
* skum fix. är talet 05 eller lägre ger parseInt rätt int annars får man
0 när man kör parseInt?
*
* @param {String} val
- * @param {Number}
+ * @return {Number}
*/
parseDateInt: function (val) {
if (val.indexOf('0') === 0) {
@@ -1193,8 +1616,8 @@
numericRangeCheck: function (value, rangeAllowed) {
// split by dash
var range = $.split(rangeAllowed),
- // min or max
- minmax = parseInt(rangeAllowed.substr(3), 10);
+ // min or max
+ minmax = parseInt(rangeAllowed.substr(3), 10);
if( range.length === 1 && rangeAllowed.indexOf('min') === -1 &&
rangeAllowed.indexOf('max') === -1 ) {
range = [rangeAllowed, rangeAllowed]; // only a number, checking
agains an exact number of characters
@@ -1265,7 +1688,7 @@
if (this._numSuggestionElements === 0) {
// Re-position suggestion container if window size changes
- $window.bind('resize', function () {
+ $win.bind('resize', function () {
$('.jquery-form-suggestions').each(function () {
var $container = $(this),
suggestID = $container.attr('data-suggest-container');
@@ -1367,6 +1790,7 @@
.click(function () {
$input.focus();
$input.val($(this).text());
+ $input.trigger('change');
onSelectSuggestion($input);
});
});
@@ -1385,6 +1809,7 @@
if ($suggestionContainer.length > 0) {
var newText =
$suggestionContainer.find('div').eq($.formUtils._selectedSuggestion).text();
$input.val(newText);
+ $input.trigger('change');
onSelectSuggestion($input);
e.preventDefault();
}
@@ -1473,6 +1898,8 @@
badInt: 'The input value was not a correct number',
badSecurityNumber: 'Your social security number was incorrect',
badUKVatAnswer: 'Incorrect UK VAT Number',
+ badUKNin: 'Incorrect UK NIN',
+ badUKUtr: 'Incorrect UK UTR Number',
badStrength: 'The password isn\'t strong enough',
badNumberOfSelectedOptionsStart: 'You have to choose at least ',
badNumberOfSelectedOptionsEnd: ' answers',
@@ -1495,16 +1922,28 @@
imageRatioNotAccepted : 'Image ratio is not be accepted',
badBrazilTelephoneAnswer: 'The phone number entered is invalid',
badBrazilCEPAnswer: 'The CEP entered is invalid',
- badBrazilCPFAnswer: 'The CPF entered is invalid'
+ badBrazilCPFAnswer: 'The CPF entered is invalid',
+ badPlPesel: 'The PESEL entered is invalid',
+ badPlNip: 'The NIP entered is invalid',
+ badPlRegon: 'The REGON entered is invalid',
+ badreCaptcha: 'Please confirm that you are not a bot',
+ passwordComplexityStart: 'Password must contain at least ',
+ passwordComplexitySeparator: ', ',
+ passwordComplexityUppercaseInfo: ' uppercase letter(s)',
+ passwordComplexityLowercaseInfo: ' lowercase letter(s)',
+ passwordComplexitySpecialCharsInfo: ' special character(s)',
+ passwordComplexityNumericCharsInfo: ' numeric character(s)',
+ passwordComplexityEnd: '.'
}
- };
+ });
+})(jQuery, window);
- /* * * * * * * * * * * * * * * * * * * * * *
- CORE VALIDATORS
- * * * * * * * * * * * * * * * * * * * * */
+/**
+ * File declaring all default validators.
+ */
+(function($) {
-
/*
* Validate email
*/
@@ -1513,8 +1952,8 @@
validatorFunction: function (email) {
var emailParts = email.toLowerCase().split('@'),
- localPart = emailParts[0],
- domain = emailParts[1];
+ localPart = emailParts[0],
+ domain = emailParts[1];
if (localPart && domain) {
@@ -1527,10 +1966,10 @@
}
return
$.formUtils.validators.validate_domain.validatorFunction(emailParts[1]) &&
- localPart.indexOf('.') !== 0 &&
- localPart.substring(localPart.length-1, localPart.length) !==
'.' &&
- localPart.indexOf('..') === -1 &&
- !(/[^\w\+\.\-\#\-\_\~\!\$\&\'\(\)\*\+\,\;\=\:]/.test(localPart));
+ localPart.indexOf('.') !== 0 &&
+ localPart.substring(localPart.length-1, localPart.length) !== '.' &&
+ localPart.indexOf('..') === -1 &&
+ !(/[^\w\+\.\-\#\-\_\~\!\$\&\'\(\)\*\+\,\;\=\:]/.test(localPart));
}
return false;
@@ -1572,7 +2011,7 @@
},
errorMessage: '',
errorMessageKey: function(config) {
- if (config.errorMessagePosition === 'top' || config.errorMessagePosition
=== 'custom') {
+ if (config.errorMessagePosition === 'top' || typeof
config.errorMessagePosition === 'function') {
return 'requiredFields';
}
else {
@@ -1665,8 +2104,21 @@
allowsRange = false,
begin, end,
steps = $el.valAttr('step') || '',
- allowsSteps = false;
+ allowsSteps = false,
+ sanitize = $el.attr('data-sanitize') || '',
+ isFormattedWithNumeral =
sanitize.match(/(^|[\s])numberFormat([\s]|$)/i);
+ if (isFormattedWithNumeral) {
+ if (!window.numeral) {
+ throw new ReferenceError('The data-sanitize value numberFormat
cannot be used without the numeral' +
+ ' library. Please see Data Validation in
http://www.formvalidator.net for more information.');
+ }
+ //Unformat input first, then convert back to String
+ if (val.length) {
+ val = String(numeral().unformat(val));
+ }
+ }
+
if (allowing.indexOf('number') === -1) {
allowing += ',number';
}
@@ -1692,10 +2144,10 @@
// Fix for checking range with floats using ,
val = val.replace(',', '.');
}
-
- if (allowing.indexOf('number') > -1 && val.replace(/[0-9-]/g, '') ===
'' && (!allowsRange || (val >= begin && val <= end)) && (!allowsSteps || (val %
steps === 0))) {
+ if (val.replace(/[0-9-]/g, '') === '' && (!allowsRange || (val >=
begin && val <= end)) && (!allowsSteps || (val % steps === 0))) {
return true;
}
+
if (allowing.indexOf('float') > -1 && val.match(new
RegExp('^([0-9-]+)\\.([0-9]+)$')) !== null && (!allowsRange || (val >= begin &&
val <= end)) && (!allowsSteps || (val % steps === 0))) {
return true;
}
@@ -1755,8 +2207,9 @@
$.formUtils.addValidator({
name: 'date',
validatorFunction: function (date, $el, conf) {
- var dateFormat = $el.valAttr('format') || conf.dateFormat ||
'yyyy-mm-dd';
- return $.formUtils.parseDate(date, dateFormat) !== false;
+ var dateFormat = $el.valAttr('format') || conf.dateFormat ||
'yyyy-mm-dd',
+ addMissingLeadingZeros = $el.valAttr('require-leading-zero') ===
'false';
+ return $.formUtils.parseDate(date, dateFormat, addMissingLeadingZeros)
!== false;
},
errorMessage: '',
errorMessageKey: 'badDate'
@@ -1776,12 +2229,12 @@
validatorFunction: function (val, $el, conf, lang, $form) {
// preset return var
var isValid = true,
- // get name of element. since it is a checkbox group, all checkboxes
will have same name
+ // get name of element. since it is a checkbox group, all checkboxes
will have same name
elname = $el.attr('name'),
- // get checkboxes and count the checked ones
+ // get checkboxes and count the checked ones
$checkBoxes = $('input[type=checkbox][name^="' + elname + '"]', $form),
checkedCount = $checkBoxes.filter(':checked').length,
- // get el attr that specs qty required / allowed
+ // get el attr that specs qty required / allowed
qtyAllowed = $el.valAttr('qty');
if (qtyAllowed === undefined) {
@@ -1829,3 +2282,6 @@
});
})(jQuery);
+
+
+}));
Modified:
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/jquery.form-validator.min.js
===================================================================
---
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/jquery.form-validator.min.js
2016-10-18 02:30:07 UTC (rev 15849)
+++
branches/Version-2_0-branch/phpgwapi/js/jquery/validator/jquery.form-validator.min.js
2016-10-18 08:17:04 UTC (rev 15850)
@@ -1,8 +1,9 @@
-/**
+/** File generated by Grunt -- do not modify
* JQUERY-FORM-VALIDATOR
*
- * @website by
+ * @version 2.3.49
+ * @website http://formvalidator.net/
+ * @author Victor Jonsson, http://victorjonsson.se
* @license MIT
- * @version 2.2.83
*/
-!function(a){"use strict";var
b=a(window),c=function(b){if(b.valAttr("error-msg-container"))return
a(b.valAttr("error-msg-container"));var
c=b.parent();if(!c.hasClass("form-group")&&!c.closest("form").hasClass("form-horizontal")){var
d=c.closest(".form-group");if(d.length)return d.eq(0)}return
c},d=function(a,b){a.addClass(b.errorElementClass).removeClass("valid"),c(a).addClass(b.inputParentClassOnError).removeClass(b.inputParentClassOnSuccess),""!==b.borderColorOnError&&a.css("border-color",b.borderColorOnError)},e=function(b,d){b.each(function(){var
b=a(this);f(b,"",d,d.errorMessagePosition),b.removeClass("valid").removeClass(d.errorElementClass).css("border-color",""),c(b).removeClass(d.inputParentClassOnError).removeClass(d.inputParentClassOnSuccess).find("."+d.errorMessageClass).remove()})},f=function(d,e,f,g){var
h=document.getElementById(d.attr("name")+"_err_msg"),i=function(a){b.trigger("validationErrorDisplay",[d,a]),a.html(e)},j={};if(h)i(a(h));else
if("object"==typeof g){var
k=!1;g.find("."+f.errorMessageClass).each(function(){return
this.inputReferer===d[0]?(k=a(this),!1):void 0}),k?e?i(k):k.remove():(j=a('<div
class="'+f.errorMessageClass+'"></div>'),i(j),j[0].inputReferer=d[0],g.prepend(j))}else{var
l=c(d);j=l.find("."+f.errorMessageClass+".help-block"),0===j.length&&(j=a("<span></span>").addClass("help-block").addClass(f.errorMessageClass),j.appendTo(l)),i(j)}},g=function(b,c,d,e){var
f,g=e.errorMessageTemplate.messages.replace(/\{errorTitle\}/g,c),h=[];a.each(d,function(a,b){h.push(e.errorMessageTemplate.field.replace(/\{msg\}/g,b))}),g=g.replace(/\{fields\}/g,h.join("")),f=e.errorMessageTemplate.container.replace(/\{errorMessageClass\}/g,e.errorMessageClass),f=f.replace(/\{messages\}/g,g),b.children().eq(0).before(f)};a.fn.validateOnBlur=function(b,c){return
this.find("*[data-validation]").bind("blur.validation",function(){a(this).validateInputOnBlur(b,c,!0,"blur")}),c.validateCheckboxRadioOnClick&&this.find("input[type=checkbox][data-validation],input[type=radio][data-validation]").bind("click.validation",function(){a(this).validateInputOnBlur(b,c,!0,"click")}),this},a.fn.validateOnEvent=function(b,c){return
this.find("*[data-validation-event]").each(function(){var
d=a(this),e=d.valAttr("event");e&&d.unbind(e+".validation").bind(e+".validation",function(){a(this).validateInputOnBlur(b,c,!0,e)})}),this},a.fn.showHelpOnFocus=function(b){return
b||(b="data-validation-help"),this.find(".has-help-txt").valAttr("has-keyup-event",!1).removeClass("has-help-txt"),this.find("textarea,input").each(function(){var
c=a(this),d="jquery_form_help_"+(c.attr("name")||"").replace(/(:|\.|\[|\])/g,""),e=c.attr(b);e&&c.addClass("has-help-txt").unbind("focus.help").bind("focus.help",function(){var
b=c.parent().find("."+d);0===b.length&&(b=a("<span
/>").addClass(d).addClass("help").addClass("help-block").text(e).hide(),c.after(b)),b.fadeIn()}).unbind("blur.help").bind("blur.help",function(){a(this).parent().find("."+d).fadeOut("slow")})}),this},a.fn.validate=function(b,c,d){var
e=a.extend({},a.formUtils.LANG,d||{});this.each(function(){var
d=a(this),f=d.closest("form").get(0).validationConfig||{};d.one("validation",function(a,c){"function"==typeof
b&&b(c,this,a)}),d.validateInputOnBlur(e,a.extend({},f,c||{}),!0)})},a.fn.willPostponeValidation=function(){return(this.valAttr("suggestion-nr")||this.valAttr("postpone")||this.hasClass("hasDatepicker"))&&!window.postponedValidation},a.fn.validateInputOnBlur=function(b,g,h,i){if(a.formUtils.eventType=i,this.willPostponeValidation()){var
j=this,k=this.valAttr("postpone")||200;return
window.postponedValidation=function(){j.validateInputOnBlur(b,g,h,i),window.postponedValidation=!1},setTimeout(function(){window.postponedValidation&&window.postponedValidation()},k),this}b=a.extend({},a.formUtils.LANG,b||{}),e(this,g);var
l=this,m=l.closest("form"),n=a.formUtils.validateInput(l,b,g,m,i);return
n.isValid?n.shouldChangeDisplay&&(l.addClass("valid"),c(l).addClass(g.inputParentClassOnSuccess)):n.isValid||(d(l,g),f(l,n.errorMsg,g,g.errorMessagePosition),h&&l.unbind("keyup.validation").bind("keyup.validation",function(){a(this).validateInputOnBlur(b,g,!1,"keyup")})),this},a.fn.valAttr=function(a,b){return
void
0===b?this.attr("data-validation-"+a):b===!1||null===b?this.removeAttr("data-validation-"+a):(a=a.length>0?"-"+a:"",this.attr("data-validation"+a,b))},a.fn.isValid=function(h,i,j){if(a.formUtils.isLoadingModules){var
k=this;return
setTimeout(function(){k.isValid(h,i,j)},200),null}i=a.extend({},a.formUtils.defaultConfig(),i||{}),h=a.extend({},a.formUtils.LANG,h||{}),j=j!==!1,a.formUtils.errorDisplayPreventedWhenHalted&&(delete
a.formUtils.errorDisplayPreventedWhenHalted,j=!1),a.formUtils.isValidatingEntireForm=!0,a.formUtils.haltValidation=!1;var
l=function(b,c){a.inArray(b,n)<0&&n.push(b),o.push(c),c.attr("current-error",b),j&&d(c,i)},m=[],n=[],o=[],p=this,q=function(b,c){return"submit"===c||"button"===c||"reset"===c?!0:a.inArray(b,i.ignore||[])>-1};if(j&&(p.find("."+i.errorMessageClass+".alert").remove(),e(p.find("."+i.errorElementClass+",.valid"),i)),p.find("input,textarea,select").filter(':not([type="submit"],[type="button"])').each(function(){var
b=a(this),d=b.attr("type"),e="radio"===d||"checkbox"===d,f=b.attr("name");if(!q(f,d)&&(!e||a.inArray(f,m)<0)){e&&m.push(f);var
g=a.formUtils.validateInput(b,h,i,p,"submit");g.shouldChangeDisplay&&(g.isValid?g.isValid&&(b.valAttr("current-error",!1).addClass("valid"),c(b).addClass(i.inputParentClassOnSuccess)):l(g.errorMsg,b))}}),"function"==typeof
i.onValidate){var
r=i.onValidate(p);a.isArray(r)?a.each(r,function(a,b){l(b.message,b.element)}):r&&r.element&&r.message&&l(r.message,r.element)}return
a.formUtils.isValidatingEntireForm=!1,!a.formUtils.haltValidation&&o.length>0?(j&&("top"===i.errorMessagePosition?g(p,h.errorTitle,n,i):"custom"===i.errorMessagePosition?"function"==typeof
i.errorMessageCustom&&i.errorMessageCustom(p,h.errorTitle,n,i):a.each(o,function(a,b){f(b,b.attr("current-error"),i,i.errorMessagePosition)}),i.scrollToTopOnError&&b.scrollTop(p.offset().top-20)),!1):(!j&&a.formUtils.haltValidation&&(a.formUtils.errorDisplayPreventedWhenHalted=!0),!a.formUtils.haltValidation)},a.fn.validateForm=function(a,b){return
window.console&&"function"==typeof
window.console.warn&&window.console.warn("Use of deprecated function
$.validateForm, use $.isValid
instead"),this.isValid(a,b,!0)},a.fn.restrictLength=function(b){return new
a.formUtils.lengthRestriction(this,b),this},a.fn.addSuggestions=function(b){var
c=!1;return this.find("input").each(function(){var
d=a(this);c=a.split(d.attr("data-suggestions")),c.length>0&&!d.hasClass("has-suggestions")&&(a.formUtils.suggest(d,c,b),d.addClass("has-suggestions"))}),this},a.split=function(b,c){if("function"!=typeof
c){if(!b)return[];var d=[];return
a.each(b.split(c?c:/[,|\-\s]\s*/g),function(b,c){c=a.trim(c),c.length&&d.push(c)}),d}b&&a.each(b.split(/[,|\-\s]\s*/g),function(b,d){return
d=a.trim(d),d.length?c(d,b):void 0})},a.validate=function(c){var
d=a.extend(a.formUtils.defaultConfig(),{form:"form",validateOnEvent:!1,validateOnBlur:!0,validateCheckboxRadioOnClick:!0,showHelpOnFocus:!0,addSuggestions:!0,modules:"",onModulesLoaded:null,language:!1,onSuccess:!1,onError:!1,onElementValidate:!1});if(c=a.extend(d,c||{}),c.lang&&"en"!==c.lang){var
f="lang/"+c.lang+".js";c.modules+=c.modules.length?","+f:f}a(c.form).each(function(d,f){f.validationConfig=c;var
g=a(f);b.trigger("formValidationSetup",[g,c]),g.find(".has-help-txt").unbind("focus.validation").unbind("blur.validation"),g.removeClass("has-validation-callback").unbind("submit.validation").unbind("reset.validation").find("input[data-validation],textarea[data-validation]").unbind("blur.validation"),g.bind("submit.validation",function(){var
b=a(this);if(a.formUtils.haltValidation)return!1;if(a.formUtils.isLoadingModules)return
setTimeout(function(){b.trigger("submit.validation")},200),!1;var
d=b.isValid(c.language,c);if(a.formUtils.haltValidation)return!1;if(!d||"function"!=typeof
c.onSuccess)return d||"function"!=typeof c.onError?d:(c.onError(b),!1);var
e=c.onSuccess(b);return e===!1?!1:void
0}).bind("reset.validation",function(){a(this).find("."+c.errorMessageClass+".alert").remove(),e(a(this).find("."+c.errorElementClass+",.valid"),c)}).addClass("has-validation-callback"),c.showHelpOnFocus&&g.showHelpOnFocus(),c.addSuggestions&&g.addSuggestions(),c.validateOnBlur&&(g.validateOnBlur(c.language,c),g.bind("html5ValidationAttrsFound",function(){g.validateOnBlur(c.language,c)})),c.validateOnEvent&&g.validateOnEvent(c.language,c)}),""!==c.modules&&a.formUtils.loadModules(c.modules,!1,function(){"function"==typeof
c.onModulesLoaded&&c.onModulesLoaded(),b.trigger("validatorsLoaded",["string"==typeof
c.form?a(c.form):c.form,c])})},a.formUtils={defaultConfig:function(){return{ignore:[],errorElementClass:"error",borderColorOnError:"#b94a48",errorMessageClass:"form-error",validationRuleAttribute:"data-validation",validationErrorMsgAttribute:"data-validation-error-msg",errorMessagePosition:"element",errorMessageTemplate:{container:'<div
class="{errorMessageClass} alert
alert-danger">{messages}</div>',messages:"<strong>{errorTitle}</strong><ul>{fields}</ul>",field:"<li>{msg}</li>"},errorMessageCustom:g,scrollToTopOnError:!0,dateFormat:"yyyy-mm-dd",addValidClassOnAll:!1,decimalSeparator:".",inputParentClassOnError:"has-error",inputParentClassOnSuccess:"has-success",validateHiddenInputs:!1}},validators:{},_events:{load:[],valid:[],invalid:[]},haltValidation:!1,isValidatingEntireForm:!1,addValidator:function(a){var
b=0===a.name.indexOf("validate_")?a.name:"validate_"+a.name;void
0===a.validateOnKeyUp&&(a.validateOnKeyUp=!0),this.validators[b]=a},isLoadingModules:!1,loadedModules:{},loadModules:function(c,d,e){if(void
0===e&&(e=!0),a.formUtils.isLoadingModules)return void
setTimeout(function(){a.formUtils.loadModules(c,d,e)});var
f=!1,g=function(c,d){var
g=a.split(c),h=g.length,i=function(){h--,0===h&&(a.formUtils.isLoadingModules=!1,e&&f&&("function"==typeof
e?e():b.trigger("validatorsLoaded")))};h>0&&(a.formUtils.isLoadingModules=!0);var
j="?_="+(new
Date).getTime(),k=document.getElementsByTagName("head")[0]||document.getElementsByTagName("body")[0];a.each(g,function(b,c){if(c=a.trim(c),0===c.length)i();else{var
e=d+c+(".js"===c.slice(-3)?"":".js"),g=document.createElement("SCRIPT");e in
a.formUtils.loadedModules?i():(a.formUtils.loadedModules[e]=1,f=!0,g.type="text/javascript",g.onload=i,g.src=e+(".dev.js"===e.slice(-7)?j:""),g.onerror=function(){"console"in
window&&window.console.log&&window.console.log("Unable to load form validation
module
"+e)},g.onreadystatechange=function(){("complete"===this.readyState||"loaded"===this.readyState)&&(i(),this.onload=null,this.onreadystatechange=null)},k.appendChild(g))}})};if(d)g(c,d);else{var
h=function(){var b=!1;return
a('script[src*="form-validator"]').each(function(){return
b=this.src.substr(0,this.src.lastIndexOf("/"))+"/","/"===b&&(b=""),!1}),b!==!1?(g(c,b),!0):!1};h()||a(h)}},validateInput:function(b,c,d,e,f){b.trigger("beforeValidation"),d=d||a.formUtils.defaultConfig(),c=c||a.formUtils.LANG;var
g=b.val()||"",h={isValid:!0,shouldChangeDisplay:!0,errorMsg:""},i=b.valAttr("optional"),j=!1,k=!1,l=!1,m=b.valAttr("if-checked"),n=b.valAttr("if-checked-value");if(b.attr("disabled")||!b.is(":visible")&&!d.validateHiddenInputs)return
h.shouldChangeDisplay=!1,h;null!=m&&(j=!0,l=e.find('input[name="'+m+'"]'),null!=n?l.each(function(b,c){a(c).prop("checked")&&a(c).val()===n&&(k=!0)}):l.prop("checked")&&(k=!0));var
o=!g&&"number"===b[0].type;if(!g&&"true"===i&&!o||j&&!k)return
h.shouldChangeDisplay=d.addValidClassOnAll,h;var
p=b.attr(d.validationRuleAttribute),q=!0;return
p?(a.split(p,function(h){0!==h.indexOf("validate_")&&(h="validate_"+h);var
i=a.formUtils.validators[h];if(!i||"function"!=typeof i.validatorFunction)throw
new Error('Using undefined validator
"'+h+'"');"validate_checkbox_group"===h&&(b=e.find('[name="'+b.attr("name")+'"]:eq(0)'));var
j=null;return("keyup"!==f||i.validateOnKeyUp)&&(j=i.validatorFunction(g,b,d,c,e)),j?void
0:(q=null,null!==j&&(q=b.attr(d.validationErrorMsgAttribute+"-"+h.replace("validate_","")),q||(q=b.attr(d.validationErrorMsgAttribute),q||(q=c[i.errorMessageKey],q||(q=i.errorMessage)))),!1)},"
"),"string"==typeof
q?(b.trigger("validation",!1),h.errorMsg=q,h.isValid=!1,h.shouldChangeDisplay=!0):null===q?h.shouldChangeDisplay=d.addValidClassOnAll:(b.trigger("validation",!0),h.shouldChangeDisplay=!0),"function"==typeof
d.onElementValidate&&null!==q&&d.onElementValidate(h.isValid,b,e,q),h):(h.shouldChangeDisplay=d.addValidClassOnAll,h)},parseDate:function(b,c){var
d,e,f,g,h=c.replace(/[a-zA-Z]/gi,"").substring(0,1),i="^",j=c.split(h||null);if(a.each(j,function(a,b){i+=(a>0?"\\"+h:"")+"(\\d{"+b.length+"})"}),i+="$",d=b.match(new
RegExp(i)),null===d)return!1;var k=function(b,c,d){for(var
e=0;e<c.length;e++)if(c[e].substring(0,1)===b)return
a.formUtils.parseDateInt(d[e+1]);return-1};return
f=k("m",j,d),e=k("d",j,d),g=k("y",j,d),2===f&&e>28&&(g%4!==0||g%100===0&&g%400!==0)||2===f&&e>29&&(g%4===0||g%100!==0&&g%400===0)||f>12||0===f?!1:this.isShortMonth(f)&&e>30||!this.isShortMonth(f)&&e>31||0===e?!1:[g,f,e]},parseDateInt:function(a){return
0===a.indexOf("0")&&(a=a.replace("0","")),parseInt(a,10)},isShortMonth:function(a){return
a%2===0&&7>a||a%2!==0&&a>7},lengthRestriction:function(b,c){var
d=parseInt(c.text(),10),e=0,f=function(){var a=b.val().length;if(a>d){var
f=b.scrollTop();b.val(b.val().substring(0,d)),b.scrollTop(f)}e=d-a,0>e&&(e=0),c.text(e)};a(b).bind("keydown
keyup keypress focus blur",f).bind("cut
paste",function(){setTimeout(f,100)}),a(document).bind("ready",f)},numericRangeCheck:function(b,c){var
d=a.split(c),e=parseInt(c.substr(3),10);return
1===d.length&&-1===c.indexOf("min")&&-1===c.indexOf("max")&&(d=[c,c]),2===d.length&&(b<parseInt(d[0],10)||b>parseInt(d[1],10))?["out",d[0],d[1]]:0===c.indexOf("min")&&e>b?["min",e]:0===c.indexOf("max")&&b>e?["max",e]:["ok"]},_numSuggestionElements:0,_selectedSuggestion:null,_previousTypedVal:null,suggest:function(c,d,e){var
f={css:{maxHeight:"150px",background:"#FFF",lineHeight:"150%",textDecoration:"underline",overflowX:"hidden",overflowY:"auto",border:"#CCC
solid
1px",borderTop:"none",cursor:"pointer"},activeSuggestionCSS:{background:"#E9E9E9"}},g=function(a,b){var
c=b.offset();a.css({width:b.outerWidth(),left:c.left+"px",top:c.top+b.outerHeight()+"px"})};e&&a.extend(f,e),f.css.position="absolute",f.css["z-index"]=9999,c.attr("autocomplete","off"),0===this._numSuggestionElements&&b.bind("resize",function(){a(".jquery-form-suggestions").each(function(){var
b=a(this),c=b.attr("data-suggest-container");g(b,a(".suggestions-"+c).eq(0))})}),this._numSuggestionElements++;var
h=function(b){var
c=b.valAttr("suggestion-nr");a.formUtils._selectedSuggestion=null,a.formUtils._previousTypedVal=null,a(".jquery-form-suggestion-"+c).fadeOut("fast")};return
c.data("suggestions",d).valAttr("suggestion-nr",this._numSuggestionElements).unbind("focus.suggest").bind("focus.suggest",function(){a(this).trigger("keyup"),a.formUtils._selectedSuggestion=null}).unbind("keyup.suggest").bind("keyup.suggest",function(){var
b=a(this),d=[],e=a.trim(b.val()).toLocaleLowerCase();if(e!==a.formUtils._previousTypedVal){a.formUtils._previousTypedVal=e;var
i=!1,j=b.valAttr("suggestion-nr"),k=a(".jquery-form-suggestion-"+j);if(k.scrollTop(0),""!==e){var
l=e.length>2;a.each(b.data("suggestions"),function(a,b){var
c=b.toLocaleLowerCase();return
c===e?(d.push("<strong>"+b+"</strong>"),i=!0,!1):void((0===c.indexOf(e)||l&&c.indexOf(e)>-1)&&d.push(b.replace(new
RegExp(e,"gi"),"<strong>$&</strong>")))})}i||0===d.length&&k.length>0?k.hide():d.length>0&&0===k.length?(k=a("<div></div>").css(f.css).appendTo("body"),c.addClass("suggestions-"+j),k.attr("data-suggest-container",j).addClass("jquery-form-suggestions").addClass("jquery-form-suggestion-"+j)):d.length>0&&!k.is(":visible")&&k.show(),d.length>0&&e.length!==d[0].length&&(g(k,b),k.html(""),a.each(d,function(c,d){a("<div></div>").append(d).css({overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"5px"}).addClass("form-suggest-element").appendTo(k).click(function(){b.focus(),b.val(a(this).text()),h(b)})}))}}).unbind("keydown.validation").bind("keydown.validation",function(b){var
c,d,e=b.keyCode?b.keyCode:b.which,g=a(this);if(13===e&&null!==a.formUtils._selectedSuggestion){if(c=g.valAttr("suggestion-nr"),d=a(".jquery-form-suggestion-"+c),d.length>0){var
i=d.find("div").eq(a.formUtils._selectedSuggestion).text();g.val(i),h(g),b.preventDefault()}}else{c=g.valAttr("suggestion-nr"),d=a(".jquery-form-suggestion-"+c);var
j=d.children();if(j.length>0&&a.inArray(e,[38,40])>-1){38===e?(null===a.formUtils._selectedSuggestion?a.formUtils._selectedSuggestion=j.length-1:a.formUtils._selectedSuggestion--,a.formUtils._selectedSuggestion<0&&(a.formUtils._selectedSuggestion=j.length-1)):40===e&&(null===a.formUtils._selectedSuggestion?a.formUtils._selectedSuggestion=0:a.formUtils._selectedSuggestion++,a.formUtils._selectedSuggestion>j.length-1&&(a.formUtils._selectedSuggestion=0));var
k=d.innerHeight(),l=d.scrollTop(),m=d.children().eq(0).outerHeight(),n=m*a.formUtils._selectedSuggestion;return(l>n||n>l+k)&&d.scrollTop(n),j.removeClass("active-suggestion").css("background","none").eq(a.formUtils._selectedSuggestion).addClass("active-suggestion").css(f.activeSuggestionCSS),b.preventDefault(),!1}}}).unbind("blur.suggest").bind("blur.suggest",function(){h(a(this))}),c},LANG:{errorTitle:"Form
submission failed!",requiredFields:"You have not answered all required
fields",badTime:"You have not given a correct time",badEmail:"You have not
given a correct e-mail address",badTelephone:"You have not given a correct
phone number",badSecurityAnswer:"You have not given a correct answer to the
security question",badDate:"You have not given a correct
date",lengthBadStart:"The input value must be between ",lengthBadEnd:"
characters",lengthTooLongStart:"The input value is longer than
",lengthTooShortStart:"The input value is shorter than ",notConfirmed:"Input
values could not be confirmed",badDomain:"Incorrect domain value",badUrl:"The
input value is not a correct URL",badCustomVal:"The input value is
incorrect",andSpaces:" and spaces ",badInt:"The input value was not a correct
number",badSecurityNumber:"Your social security number was
incorrect",badUKVatAnswer:"Incorrect UK VAT Number",badStrength:"The password
isn't strong enough",badNumberOfSelectedOptionsStart:"You have to choose at
least ",badNumberOfSelectedOptionsEnd:" answers",badAlphaNumeric:"The input
value can only contain alphanumeric characters ",badAlphaNumericExtra:" and
",wrongFileSize:"The file you are trying to upload is too large (max
%s)",wrongFileType:"Only files of type %s is
allowed",groupCheckedRangeStart:"Please choose between
",groupCheckedTooFewStart:"Please choose at least
",groupCheckedTooManyStart:"Please choose a maximum of ",groupCheckedEnd:"
item(s)",badCreditCard:"The credit card number is not correct",badCVV:"The CVV
number was not correct",wrongFileDim:"Incorrect image
dimensions,",imageTooTall:"the image can not be taller than",imageTooWide:"the
image can not be wider than",imageTooSmall:"the image was too
small",min:"min",max:"max",imageRatioNotAccepted:"Image ratio is not be
accepted",badBrazilTelephoneAnswer:"The phone number entered is
invalid",badBrazilCEPAnswer:"The CEP entered is
invalid",badBrazilCPFAnswer:"The CPF entered is
invalid"}},a.formUtils.addValidator({name:"email",validatorFunction:function(b){var
c=b.toLowerCase().split("@"),d=c[0],e=c[1];if(d&&e){if(0===d.indexOf('"')){var
f=d.length;if(d=d.replace(/\"/g,""),d.length!==f-2)return!1}return
a.formUtils.validators.validate_domain.validatorFunction(c[1])&&0!==d.indexOf(".")&&"."!==d.substring(d.length-1,d.length)&&-1===d.indexOf("..")&&!/[^\w\+\.\-\#\-\_\~\!\$\&\'\(\)\*\+\,\;\=\:]/.test(d)}return!1},errorMessage:"",errorMessageKey:"badEmail"}),a.formUtils.addValidator({name:"domain",validatorFunction:function(a){return
a.length>0&&a.length<=253&&!/[^a-zA-Z0-9]/.test(a.slice(-2))&&!/[^a-zA-Z0-9]/.test(a.substr(0,1))&&!/[^a-zA-Z0-9\.\-]/.test(a)&&1===a.split("..").length&&a.split(".").length>1},errorMessage:"",errorMessageKey:"badDomain"}),a.formUtils.addValidator({name:"required",validatorFunction:function(b,c,d,e,f){switch(c.attr("type")){case"checkbox":return
c.is(":checked");case"radio":return
f.find('input[name="'+c.attr("name")+'"]').filter(":checked").length>0;default:return""!==a.trim(b)}},errorMessage:"",errorMessageKey:"requiredFields"}),a.formUtils.addValidator({name:"length",validatorFunction:function(b,c,d,e){var
f=c.valAttr("length"),g=c.attr("type");if(void 0===f)return alert('Please add
attribute "data-validation-length" to '+c[0].nodeName+" named
"+c.attr("name")),!0;var h,i="file"===g&&void
0!==c.get(0).files?c.get(0).files.length:b.length,j=a.formUtils.numericRangeCheck(i,f);switch(j[0]){case"out":this.errorMessage=e.lengthBadStart+f+e.lengthBadEnd,h=!1;break;case"min":this.errorMessage=e.lengthTooShortStart+j[1]+e.lengthBadEnd,h=!1;break;case"max":this.errorMessage=e.lengthTooLongStart+j[1]+e.lengthBadEnd,h=!1;break;default:h=!0}return
h},errorMessage:"",errorMessageKey:""}),a.formUtils.addValidator({name:"url",validatorFunction:function(b){var
c=/^(https?|ftp):\/\/((((\w|-|\.|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])(\w|-|\.|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])(\w|-|\.|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/(((\w|-|\.|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/((\w|-|\.|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|\[|\]|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#(((\w|-|\.|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i;if(c.test(b)){var
d=b.split("://")[1],e=d.indexOf("/");return
e>-1&&(d=d.substr(0,e)),a.formUtils.validators.validate_domain.validatorFunction(d)}return!1},errorMessage:"",errorMessageKey:"badUrl"}),a.formUtils.addValidator({name:"number",validatorFunction:function(a,b,c){if(""!==a){var
d,e,f=b.valAttr("allowing")||"",g=b.valAttr("decimal-separator")||c.decimalSeparator,h=!1,i=b.valAttr("step")||"",j=!1;if(-1===f.indexOf("number")&&(f+=",number"),-1===f.indexOf("negative")&&0===a.indexOf("-"))return!1;if(f.indexOf("range")>-1&&(d=parseFloat(f.substring(f.indexOf("[")+1,f.indexOf(";"))),e=parseFloat(f.substring(f.indexOf(";")+1,f.indexOf("]"))),h=!0),""!==i&&(j=!0),","===g){if(a.indexOf(".")>-1)return!1;a=a.replace(",",".")}if(f.indexOf("number")>-1&&""===a.replace(/[0-9-]/g,"")&&(!h||a>=d&&e>=a)&&(!j||a%i===0))return!0;if(f.indexOf("float")>-1&&null!==a.match(new
RegExp("^([0-9-]+)\\.([0-9]+)$"))&&(!h||a>=d&&e>=a)&&(!j||a%i===0))return!0}return!1},errorMessage:"",errorMessageKey:"badInt"}),a.formUtils.addValidator({name:"alphanumeric",validatorFunction:function(b,c,d,e){var
f="^([a-zA-Z0-9",g="]+)$",h=c.valAttr("allowing"),i="";if(h){i=f+h+g;var
j=h.replace(/\\/g,"");j.indexOf(" ")>-1&&(j=j.replace("
",""),j+=e.andSpaces||a.formUtils.LANG.andSpaces),this.errorMessage=e.badAlphaNumeric+e.badAlphaNumericExtra+j}else
i=f+g,this.errorMessage=e.badAlphaNumeric;return new
RegExp(i).test(b)},errorMessage:"",errorMessageKey:""}),a.formUtils.addValidator({name:"custom",validatorFunction:function(a,b){var
c=new RegExp(b.valAttr("regexp"));return
c.test(a)},errorMessage:"",errorMessageKey:"badCustomVal"}),a.formUtils.addValidator({name:"date",validatorFunction:function(b,c,d){var
e=c.valAttr("format")||d.dateFormat||"yyyy-mm-dd";return
a.formUtils.parseDate(b,e)!==!1},errorMessage:"",errorMessageKey:"badDate"}),a.formUtils.addValidator({name:"checkbox_group",validatorFunction:function(b,c,d,e,f){var
g=!0,h=c.attr("name"),i=a('input[type=checkbox][name^="'+h+'"]',f),j=i.filter(":checked").length,k=c.valAttr("qty");if(void
0===k){var l=c.get(0).nodeName;alert('Attribute "data-validation-qty" is
missing from '+l+" named "+c.attr("name"))}var
m=a.formUtils.numericRangeCheck(j,k);switch(m[0]){case"out":this.errorMessage=e.groupCheckedRangeStart+k+e.groupCheckedEnd,g=!1;break;case"min":this.errorMessage=e.groupCheckedTooFewStart+m[1]+e.groupCheckedEnd,g=!1;break;case"max":this.errorMessage=e.groupCheckedTooManyStart+m[1]+e.groupCheckedEnd,g=!1;break;default:g=!0}if(!g){var
n=function(){i.unbind("click",n),i.filter("*[data-validation]").validateInputOnBlur(e,d,!1,"blur")};i.bind("click",n)}return
g}})}(jQuery);
\ No newline at end of file
@@ Diff output truncated at 153600 characters. @@
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [15850] Stable: Merge 15819:15849 from trunk,
sigurdne <=