Commit a650da84 authored by Tatuya Kamada's avatar Tatuya Kamada

Add a small javascript function to use datepicker with ERP5 DateTimeField.

To make enable this function, you need to overwrite
ERP5Site_getJavaScriptRelativeUrlList.
This means it does nothing by default even if you install this bussiness template.
parent 9244433d
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>erp5_datepicker_ui</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>"""\n
\n
To extend your current ERP5Site_getJavaScriptRelativeUrlList,\n
first, find ERP5Site_getJavaScriptRelativeUrlList,\n
then put \'erp5_datepicker_ui.js\' at the last.\n
\n
The following is an example. To enable datepicker, you must include\n
\'erp5_datepicker_ui.js\' in the list.\n
\n
"""\n
js_list = (\'jquery/core/jquery.min.js\', \'erp5.js\', \'erp5_datepicker_ui.js\')\n
return js_list\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>README_HOWTO_CUSTOMISE@@@ERP5Site_getJavaScriptRelativeUrlList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts25433708.96</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>erp5_datepicker_ui.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string>//\n
//\n
(function($) {\n
var setDate = function(dateText, inst) {\n
var date = $.datepicker.parseDate($(this).datepicker(\'option\', \'dateFormat\'), dateText);\n
var date_map = {\n
year: date.getFullYear(),\n
month: date.getMonth() + 1,\n
day: date.getDate()\n
};\n
$(\'input\', this.parentNode).each(function() {\n
var name = jQuery(this).attr(\'name\');\n
if (name !== undefined) {\n
var word_list = name.split(\'_\');\n
var last_word = word_list[word_list.length - 1];\n
var value = date_map[last_word];\n
if (value == null) {\n
value = \'\';\n
}\n
this.value = value.toString();\n
}\n
});\n
};\n
\n
$.fn.erp5DatePicker = function() {\n
this.each(function() {\n
var input = $(\'input\', this);\n
var size = input.size();\n
input.each(function(index) {\n
$(this).datepicker({\n
onSelect: setDate\n
});\n
});\n
});\n
};\n
})(jQuery);\n
$(document).ready(function(){\n
$(\'div.date_field div.input\').erp5DatePicker();\n
});\n
</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>1069</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
2015-03-04 tatuya
* Initially add
\ No newline at end of file
To enable date picker you must extend your ERP5Site_getJavaScriptRelativeUrlList!
See README_HOWTO_CUSTOMISE@@@ERP5Site_getJavaScriptRelativeUrlList.
\ No newline at end of file
Add jquery datepicker ui to ERP5 date field.
tatuya
\ No newline at end of file
1
\ No newline at end of file
erp5_datepicker_ui
\ No newline at end of file
erp5_datepicker_ui
\ No newline at end of file
1.0
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment