Skip to content
Browse files

ticket #1094: javascript components of jforms should have the possibi…

…lity to access to jelixWWWPath to have the true path of jelix/. these components receive a configuration object instead of several arguments.
  • Loading branch information...
1 parent 1cd2444 commit 84109e60e952c3cba87cc998b95f6a33b0c4af0c @laurentj laurentj committed Sep 26, 2010
View
26 TODO_RELEASE
@@ -1,25 +1 @@
-What should have been done to release a new version of jelix
-
-- check if this files are updated :
- README
- lib/jelix/CREDITS
- lib/jelix/INSTALL
- lib/jelix-modules/CREDITS
-- update changelogs in the web site
-- svn: Copy the branch/trunk into the tags
-- modify this files into the tag directory to reflect the new version
- lib/jelix/VERSION
- testapp/VERSION
-- modify this files into the branch or trunk directory to reflect the next future version
- lib/jelix/VERSION
- testapp/VERSION
-- create packages
- - test them with testapp
- - check if all needed files are here
-- download packages on berlios.de
-- download packages on download.jelix.org
-- update home page of the web site
-- update the download page on the web site
-- update the API documentation on the web site
-- create package for the API documentation on the web site
-- news
+See http://developer.jelix.org/wiki/en/howto_release
View
12 lib/jelix-www/js/jforms/datepickers/default/init.js
@@ -8,7 +8,7 @@
* @licence GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html
*/
-function jelix_datepicker_default(control,locale,basePath, jqueryPath){
+function jelix_datepicker_default(control, config){
if(typeof this._controls !== 'undefined'){
this._controls.push(control);
return;
@@ -17,18 +17,18 @@ function jelix_datepicker_default(control,locale,basePath, jqueryPath){
this._controls = [];
this._controls.push(control);
- this._config = {locale:locale, basePath:basePath, jqueryPath:jqueryPath};
+ this._config = config;
this._jsFiles = [];
if(typeof jQuery.ui == 'undefined')
this._jsFiles.push(this._config.jqueryPath+'ui/jquery-ui-core-widg-mous-posi.custom.min.js');
if(typeof jQuery.datepicker == 'undefined'){
jQuery.include(this._config.jqueryPath+'themes/base/jquery.ui.all.css');
this._jsFiles.push(this._config.jqueryPath+'ui/jquery.ui.datepicker.min.js');
- var lang = locale.substr(0,2).toLowerCase();
+ var lang = this._config.locale.substr(0,2).toLowerCase();
if(lang != 'en')
this._jsFiles.push(this._config.jqueryPath+'ui/i18n/jquery.ui.datepicker-'+lang+'.js');
- this._jsFiles.push(this._config.basePath+'jelix/js/jforms/datepickers/default/ui.'+lang+'.js');
+ this._jsFiles.push(this._config.jelixWWWPath+'js/jforms/datepickers/default/ui.'+lang+'.js');
}
this._loadJS = function (i){
if(i<this._jsFiles.length){
@@ -66,7 +66,7 @@ function jelix_datepicker_default(control,locale,basePath, jqueryPath){
showButtonPanel: true,
showOn: "button",
buttonImageOnly: true,
- buttonImage: config.basePath+'jelix/design/jforms/calendar.gif',
+ buttonImage: config.jelixWWWPath+'design/jforms/calendar.gif',
onSelect : function(date){
if(!control.multiFields)
return;
@@ -112,7 +112,7 @@ function jelix_datepicker_default(control,locale,basePath, jqueryPath){
var triggerIcon = elt.parent().children('img.ui-datepicker-trigger').eq(0);
if(!control.required){
- triggerIcon.after(' <img class="ui-datepicker-reset" src="'+config.basePath+'jelix/design/jforms/cross.png" alt="'+elt.datepicker('option','resetButtonText')+'" title="'+elt.datepicker('option','resetButtonText')+'" />');
+ triggerIcon.after(' <img class="ui-datepicker-reset" src="'+config.jelixWWWPath+'design/jforms/cross.png" alt="'+elt.datepicker('option','resetButtonText')+'" title="'+elt.datepicker('option','resetButtonText')+'" />');
var cleanTriggerIcon = elt.parent().children('img').eq(1);
cleanTriggerIcon.click(function(e){
if(elt.datepicker('isDisabled'))
View
4 lib/jelix-www/js/jforms/htmleditors/ckeditor_basic.js
@@ -1,11 +1,11 @@
-function jelix_ckeditor_ckbasic(textarea_id, form_id, skin, lang){
+function jelix_ckeditor_ckbasic(textarea_id, form_id, skin, config){
var conf = {toolbar:'Basic',
removePlugins : 'elementspath',
scayt_autoStartup : false
};
if (skin !='default')
conf['skin'] = skin;
- conf["language"] = lang.substr(0,2).toLowerCase();
+ conf["language"] = config.locale.substr(0,2).toLowerCase();
var editor = CKEDITOR.replace(textarea_id, conf);
jQuery('#'+form_id).bind('jFormsUpdateFields', function(event){
View
4 lib/jelix-www/js/jforms/htmleditors/ckeditor_default.js
@@ -1,4 +1,4 @@
-function jelix_ckeditor_ckdefault(textarea_id, form_id, skin, lang){
+function jelix_ckeditor_ckdefault(textarea_id, form_id, skin, config){
var conf = {
toolbar:
[
@@ -16,7 +16,7 @@ function jelix_ckeditor_ckdefault(textarea_id, form_id, skin, lang){
};
if (skin !='default')
conf['skin'] = skin;
- conf["language"] = lang.substr(0,2).toLowerCase();
+ conf["language"] = config.locale.substr(0,2).toLowerCase();
var editor = CKEDITOR.replace(textarea_id, conf);
jQuery('#'+form_id).bind('jFormsUpdateFields', function(event){
View
4 lib/jelix-www/js/jforms/htmleditors/ckeditor_full.js
@@ -1,8 +1,8 @@
-function jelix_ckeditor_ckfull(textarea_id, form_id, skin, lang){
+function jelix_ckeditor_ckfull(textarea_id, form_id, skin, config){
var conf = {};
if (skin !='default')
conf['skin'] = skin;
- conf["language"] = lang.substr(0,2).toLowerCase();
+ conf["language"] = config.locale.substr(0,2).toLowerCase();
var editor = CKEDITOR.replace(textarea_id, conf);
jQuery('#'+form_id).bind('jFormsUpdateFields', function(event){
editor.updateElement();
View
2 lib/jelix-www/js/jforms/htmleditors/wymeditor_default.js
@@ -1,5 +1,5 @@
-function jelix_wymeditor_default(textarea_id, form_id, skin, lang) {
+function jelix_wymeditor_default(textarea_id, form_id, skin, config) {
jQuery(function() {
jQuery("#"+textarea_id).wymeditor({
View
2 lib/jelix-www/js/jforms_jquery.js
@@ -37,6 +37,8 @@ var jFormsJQ = {
tForm: null,
selectFillUrl : '',
+ config : {},
+
/**
* @param jFormsJQForm aForm
*/
View
2 lib/jelix-www/js/jforms_light.js
@@ -37,6 +37,8 @@ var jForms = {
tForm: null,
frmElt: null,
+ config : {},
+
declareForm : function(aForm){
this._forms[aForm.name]=aForm;
if(window.jQuery)
View
2 lib/jelix/forms/jFormsBuilderHtml.class.php
@@ -789,7 +789,7 @@ protected function jsHtmleditor($ctrl) {
$this->jsContent .="c = new ".$this->jFormsJsVarName."ControlHtml('".$ctrl->ref."', ".$this->escJsStr($ctrl->label).");\n";
$this->jsTextarea($ctrl, false);
$engine = $GLOBALS['gJConfig']->htmleditors[$ctrl->config.'.engine.name'];
- $this->jsContent .= 'jelix_'.$engine.'_'.$ctrl->config.'("'.$this->_name.'_'.$ctrl->ref.'","'.$this->_name.'","'.$ctrl->skin.'","'.$GLOBALS['gJConfig']->locale."\");\n";
+ $this->jsContent .= 'jelix_'.$engine.'_'.$ctrl->config.'("'.$this->_name.'_'.$ctrl->ref.'","'.$this->_name.'","'.$ctrl->skin."\",".$this->jFormsJsVarName.".config);\n";
}
protected function outputWikieditor($ctrl, &$attr) {
View
7 lib/jelix/plugins/jforms/html/html.jformsbuilder.php
@@ -76,10 +76,15 @@ public function outputMetaContent($t) {
}
protected function outputHeaderScript(){
+ global $gJConfig;
// no scope into an anonymous js function, because jFormsJQ.tForm is used by other generated source code
echo '<script type="text/javascript">
//<![CDATA[
jFormsJQ.selectFillUrl=\''.jUrl::get('jelix~jforms:getListData').'\';
+jFormsJQ.config = {locale:'.$this->escJsStr($gJConfig->locale).
+ ',basePath:'.$this->escJsStr($gJConfig->urlengine['basePath']).
+ ',jqueryPath:'.$this->escJsStr($gJConfig->urlengine['jqueryPath']).
+ ',jelixWWWPath:'.$this->escJsStr($gJConfig->urlengine['jelixWWWPath']).'};
jFormsJQ.tForm = new jFormsJQForm(\''.$this->_name.'\',\''.$this->_form->getSelector().'\',\''.$this->_form->getContainer()->formId.'\');
jFormsJQ.tForm.setErrorDecorator(new '.$this->options['errorDecorator'].'());
jFormsJQ.declareForm(jFormsJQ.tForm);
@@ -108,7 +113,7 @@ protected function commonJs($ctrl) {
if($ctrl instanceof jFormsControlDate || get_class($ctrl->datatype) == 'jDatatypeDate' || get_class($ctrl->datatype) == 'jDatatypeLocaleDate'){
$config = isset($ctrl->datepickerConfig)?$ctrl->datepickerConfig:$GLOBALS['gJConfig']->forms['datepicker'];
- $this->jsContent .= 'jelix_datepicker_'.$config.'(c,'.$this->escJsStr($GLOBALS['gJConfig']->locale).','.$this->escJsStr($GLOBALS['gJConfig']->urlengine['basePath']).','.$this->escJsStr($GLOBALS['gJConfig']->urlengine['jqueryPath']).");\n";
+ $this->jsContent .= 'jelix_datepicker_'.$config."(c, jFormsJQ.config);\n";
}
if ($this->isRootControl) $this->jsContent .="jFormsJQ.tForm.addControl(c);\n";
View
17 testapp/modules/jelix_tests/tests/jforms.htmlbuilder.html_cli.php
@@ -48,6 +48,7 @@ function testOutputHeader(){
$result ='<form action="'.$GLOBALS['gJConfig']->urlengine['basePath'].'index.php" method="post" id="'.$this->builder->getName().'"><script type="text/javascript">
//<![CDATA[
jFormsJQ.selectFillUrl=\''.$GLOBALS['gJConfig']->urlengine['basePath'].'index.php?module=jelix&action=jforms:getListData\';
+jFormsJQ.config = {locale:\'en_EN\',basePath:\'/\',jqueryPath:\'/jelix/jquery/\',jelixWWWPath:\'/jelix/\'};
jFormsJQ.tForm = new jFormsJQForm(\'jforms_formtest\',\'formtest\',\'0\');
jFormsJQ.tForm.setErrorDecorator(new jFormsJQErrorDecoratorHtml());
jFormsJQ.declareForm(jFormsJQ.tForm);
@@ -66,6 +67,7 @@ function testOutputHeader(){
$result ='<form action="'.$GLOBALS['gJConfig']->urlengine['basePath'].'index.php" method="get" id="'.$this->builder->getName().'"><script type="text/javascript">
//<![CDATA[
jFormsJQ.selectFillUrl=\''.$GLOBALS['gJConfig']->urlengine['basePath'].'index.php?module=jelix&action=jforms:getListData\';
+jFormsJQ.config = {locale:\'en_EN\',basePath:\'/\',jqueryPath:\'/jelix/jquery/\',jelixWWWPath:\'/jelix/\'};
jFormsJQ.tForm = new jFormsJQForm(\'jforms_formtest1\',\'formtest\',\'0\');
jFormsJQ.tForm.setErrorDecorator(new jFormsJQErrorDecoratorHtml());
jFormsJQ.declareForm(jFormsJQ.tForm);
@@ -1289,6 +1291,7 @@ function testOutputUpload(){
$result ='<form action="'.$GLOBALS['gJConfig']->urlengine['basePath'].'index.php" method="post" id="'.$this->formname.'" enctype="multipart/form-data"><script type="text/javascript">
//<![CDATA[
jFormsJQ.selectFillUrl=\''.$GLOBALS['gJConfig']->urlengine['basePath'].'index.php?module=jelix&action=jforms:getListData\';
+jFormsJQ.config = {locale:\'en_EN\',basePath:\'/\',jqueryPath:\'/jelix/jquery/\',jelixWWWPath:\'/jelix/\'};
jFormsJQ.tForm = new jFormsJQForm(\'jforms_formtest1\',\'formtest\',\'0\');
jFormsJQ.tForm.setErrorDecorator(new jFormsJQErrorDecoratorHtml());
jFormsJQ.declareForm(jFormsJQ.tForm);
@@ -1382,6 +1385,7 @@ function testOutputHidden(){
$result ='<form action="'.$GLOBALS['gJConfig']->urlengine['basePath'].'index.php" method="post" id="'.$this->formname.'"><script type="text/javascript">
//<![CDATA[
jFormsJQ.selectFillUrl=\''.$GLOBALS['gJConfig']->urlengine['basePath'].'index.php?module=jelix&action=jforms:getListData\';
+jFormsJQ.config = {locale:\'en_EN\',basePath:\'/\',jqueryPath:\'/jelix/jquery/\',jelixWWWPath:\'/jelix/\'};
jFormsJQ.tForm = new jFormsJQForm(\'jforms_formtest1\',\'formtest\',\'0\');
jFormsJQ.tForm.setErrorDecorator(new jFormsJQErrorDecoratorHtml());
jFormsJQ.declareForm(jFormsJQ.tForm);
@@ -1403,6 +1407,7 @@ function testOutputHidden(){
$result ='<form action="'.$GLOBALS['gJConfig']->urlengine['basePath'].'index.php" method="post" id="'.$this->formname.'"><script type="text/javascript">
//<![CDATA[
jFormsJQ.selectFillUrl=\''.$GLOBALS['gJConfig']->urlengine['basePath'].'index.php?module=jelix&action=jforms:getListData\';
+jFormsJQ.config = {locale:\'en_EN\',basePath:\'/\',jqueryPath:\'/jelix/jquery/\',jelixWWWPath:\'/jelix/\'};
jFormsJQ.tForm = new jFormsJQForm(\'jforms_formtest1\',\'formtest\',\'0\');
jFormsJQ.tForm.setErrorDecorator(new jFormsJQErrorDecoratorHtml());
jFormsJQ.declareForm(jFormsJQ.tForm);
@@ -1494,7 +1499,7 @@ function testOutputHtmleditor(){
$this->assertEqualOrDiff('c = new jFormsJQControlHtml(\'contenu\', \'Texte\');
c.errInvalid=\'"Texte" field is invalid\';
jFormsJQ.tForm.addControl(c);
-jelix_wymeditor_default("jforms_formtest1_contenu","jforms_formtest1","default","en_EN");
+jelix_wymeditor_default("jforms_formtest1_contenu","jforms_formtest1","default",jFormsJQ.config);
', $this->builder->getJsContent());
$ctrl->setReadOnly(true);
@@ -1503,7 +1508,7 @@ function testOutputHtmleditor(){
$this->assertEqualOrDiff('c = new jFormsJQControlHtml(\'contenu\', \'Texte\');
c.errInvalid=\'"Texte" field is invalid\';
jFormsJQ.tForm.addControl(c);
-jelix_wymeditor_default("jforms_formtest1_contenu","jforms_formtest1","default","en_EN");
+jelix_wymeditor_default("jforms_formtest1_contenu","jforms_formtest1","default",jFormsJQ.config);
', $this->builder->getJsContent());
$ctrl->hint='ceci est un tooltip';
@@ -1515,7 +1520,7 @@ function testOutputHtmleditor(){
$this->assertEqualOrDiff('c = new jFormsJQControlHtml(\'contenu\', \'Texte\');
c.errInvalid=\'"Texte" field is invalid\';
jFormsJQ.tForm.addControl(c);
-jelix_wymeditor_default("jforms_formtest1_contenu","jforms_formtest1","default","en_EN");
+jelix_wymeditor_default("jforms_formtest1_contenu","jforms_formtest1","default",jFormsJQ.config);
', $this->builder->getJsContent());
@@ -1525,7 +1530,7 @@ function testOutputHtmleditor(){
$this->assertEqualOrDiff('c = new jFormsJQControlHtml(\'contenu\', \'Texte\');
c.errInvalid=\'"Texte" field is invalid\';
jFormsJQ.tForm.addControl(c);
-jelix_wymeditor_default("jforms_formtest1_contenu","jforms_formtest1","default","en_EN");
+jelix_wymeditor_default("jforms_formtest1_contenu","jforms_formtest1","default",jFormsJQ.config);
', $this->builder->getJsContent());
@@ -1535,7 +1540,7 @@ function testOutputHtmleditor(){
$this->assertEqualOrDiff('c = new jFormsJQControlHtml(\'contenu\', \'Texte\');
c.errInvalid=\'"Texte" field is invalid\';
jFormsJQ.tForm.addControl(c);
-jelix_wymeditor_default("jforms_formtest1_contenu","jforms_formtest1","default","en_EN");
+jelix_wymeditor_default("jforms_formtest1_contenu","jforms_formtest1","default",jFormsJQ.config);
', $this->builder->getJsContent());
$ctrl->required=true;
@@ -1546,7 +1551,7 @@ function testOutputHtmleditor(){
c.errRequired=\'"Texte" field is required\';
c.errInvalid=\'"Texte" field is invalid\';
jFormsJQ.tForm.addControl(c);
-jelix_wymeditor_default("jforms_formtest1_contenu","jforms_formtest1","default","en_EN");
+jelix_wymeditor_default("jforms_formtest1_contenu","jforms_formtest1","default",jFormsJQ.config);
', $this->builder->getJsContent());
}
}
View
3 testapp/modules/jelix_tests/tests/jforms.htmlbuilder2.html_cli.php
@@ -372,6 +372,7 @@ public function testFormWithExternalUrlAsAction(){
$result ='<form action="http://www.jelix.org/dummy.php" method="post" id="'.$this->builder->getName().'"><script type="text/javascript">
//<![CDATA[
jFormsJQ.selectFillUrl=\''.$GLOBALS['gJConfig']->urlengine['basePath'].'index.php?module=jelix&action=jforms:getListData\';
+jFormsJQ.config = {locale:\'en_EN\',basePath:\'/\',jqueryPath:\'/jelix/jquery/\',jelixWWWPath:\'/jelix/\'};
jFormsJQ.tForm = new jFormsJQForm(\'jforms_formtesthtmlbuilder\',\'formtesthtmlbuilder\',\'0\');
jFormsJQ.tForm.setErrorDecorator(new jFormsJQErrorDecoratorHtml());
jFormsJQ.declareForm(jFormsJQ.tForm);
@@ -390,6 +391,7 @@ public function testFormWithExternalUrlAsAction(){
$result ='<form action="http://www.jelix.org/dummy.php" method="post" id="'.$this->builder->getName().'"><script type="text/javascript">
//<![CDATA[
jFormsJQ.selectFillUrl=\''.$GLOBALS['gJConfig']->urlengine['basePath'].'index.php?module=jelix&action=jforms:getListData\';
+jFormsJQ.config = {locale:\'en_EN\',basePath:\'/\',jqueryPath:\'/jelix/jquery/\',jelixWWWPath:\'/jelix/\'};
jFormsJQ.tForm = new jFormsJQForm(\'jforms_formtesthtmlbuilder1\',\'formtesthtmlbuilder\',\'0\');
jFormsJQ.tForm.setErrorDecorator(new jFormsJQErrorDecoratorHtml());
jFormsJQ.declareForm(jFormsJQ.tForm);
@@ -409,6 +411,7 @@ public function testFormWithExternalUrlAsAction(){
$result ='<form action="https://www.jelix.org/dummy.php" method="get" id="'.$this->builder->getName().'"><script type="text/javascript">
//<![CDATA[
jFormsJQ.selectFillUrl=\''.$GLOBALS['gJConfig']->urlengine['basePath'].'index.php?module=jelix&action=jforms:getListData\';
+jFormsJQ.config = {locale:\'en_EN\',basePath:\'/\',jqueryPath:\'/jelix/jquery/\',jelixWWWPath:\'/jelix/\'};
jFormsJQ.tForm = new jFormsJQForm(\'jforms_formtesthtmlbuilder2\',\'formtesthtmlbuilder\',\'0\');
jFormsJQ.tForm.setErrorDecorator(new jFormsJQErrorDecoratorHtml());
jFormsJQ.declareForm(jFormsJQ.tForm);
View
12 testapp/modules/jelix_tests/tests/jforms.htmllightbuilder.html_cli.php
@@ -1371,7 +1371,7 @@ function testOutputHtmleditor(){
$this->assertEqualOrDiff('c = new jFormsControlHtml(\'contenu\', \'Texte\');
c.errInvalid=\'"Texte" field is invalid\';
jForms.tForm.addControl(c);
-jelix_wymeditor_default("jforms_formtestlight1_contenu","jforms_formtestlight1","default","en_EN");
+jelix_wymeditor_default("jforms_formtestlight1_contenu","jforms_formtestlight1","default",jForms.config);
', $this->builder->getJsContent());
$ctrl->setReadOnly(true);
@@ -1380,7 +1380,7 @@ function testOutputHtmleditor(){
$this->assertEqualOrDiff('c = new jFormsControlHtml(\'contenu\', \'Texte\');
c.errInvalid=\'"Texte" field is invalid\';
jForms.tForm.addControl(c);
-jelix_wymeditor_default("jforms_formtestlight1_contenu","jforms_formtestlight1","default","en_EN");
+jelix_wymeditor_default("jforms_formtestlight1_contenu","jforms_formtestlight1","default",jForms.config);
', $this->builder->getJsContent());
$ctrl->hint='ceci est un tooltip';
@@ -1392,7 +1392,7 @@ function testOutputHtmleditor(){
$this->assertEqualOrDiff('c = new jFormsControlHtml(\'contenu\', \'Texte\');
c.errInvalid=\'"Texte" field is invalid\';
jForms.tForm.addControl(c);
-jelix_wymeditor_default("jforms_formtestlight1_contenu","jforms_formtestlight1","default","en_EN");
+jelix_wymeditor_default("jforms_formtestlight1_contenu","jforms_formtestlight1","default",jForms.config);
', $this->builder->getJsContent());
@@ -1402,7 +1402,7 @@ function testOutputHtmleditor(){
$this->assertEqualOrDiff('c = new jFormsControlHtml(\'contenu\', \'Texte\');
c.errInvalid=\'"Texte" field is invalid\';
jForms.tForm.addControl(c);
-jelix_wymeditor_default("jforms_formtestlight1_contenu","jforms_formtestlight1","default","en_EN");
+jelix_wymeditor_default("jforms_formtestlight1_contenu","jforms_formtestlight1","default",jForms.config);
', $this->builder->getJsContent());
@@ -1412,7 +1412,7 @@ function testOutputHtmleditor(){
$this->assertEqualOrDiff('c = new jFormsControlHtml(\'contenu\', \'Texte\');
c.errInvalid=\'"Texte" field is invalid\';
jForms.tForm.addControl(c);
-jelix_wymeditor_default("jforms_formtestlight1_contenu","jforms_formtestlight1","default","en_EN");
+jelix_wymeditor_default("jforms_formtestlight1_contenu","jforms_formtestlight1","default",jForms.config);
', $this->builder->getJsContent());
$ctrl->required=true;
@@ -1423,7 +1423,7 @@ function testOutputHtmleditor(){
c.errRequired=\'"Texte" field is required\';
c.errInvalid=\'"Texte" field is invalid\';
jForms.tForm.addControl(c);
-jelix_wymeditor_default("jforms_formtestlight1_contenu","jforms_formtestlight1","default","en_EN");
+jelix_wymeditor_default("jforms_formtestlight1_contenu","jforms_formtestlight1","default",jForms.config);
', $this->builder->getJsContent());
}
}

0 comments on commit 84109e6

Please sign in to comment.
Something went wrong with that request. Please try again.