/**
  * Clear the field
  * @param $form_name Form name
  * @param $field Field name
  */
 public static function clearField($form_name, $field)
 {
     $script = new TElement('script');
     $script->{'language'} = 'JavaScript';
     $script->setUseSingleQuotes(TRUE);
     $script->setUseLineBreaks(FALSE);
     $script->add(" setTimeout(function(){ \$('[name={$field}]').cleditor()[0].clear(); },1);");
     $script->show();
 }
 /**
  * Disable the field
  * @param $form_name Form name
  * @param $field Field name
  */
 public static function disableField($form_name, $field)
 {
     $script = new TElement('script');
     $script->{'language'} = 'JavaScript';
     $script->setUseSingleQuotes(TRUE);
     $script->setUseLineBreaks(FALSE);
     $script->add(" setTimeout(function(){ \$('[name={$field}]').attr('disabled', true) },1); ");
     $script->add(" setTimeout(function(){ \$('[name={$field}]').next().hide() },1);");
     $script->show();
 }
Example #3
0
 /**
  * Reload combobox items after it is already shown
  * @param $formname form name (used in gtk version)
  * @param $name field name
  * @param $items array with items
  */
 public static function reload($formname, $name, $items)
 {
     $script = new TElement('script');
     $script->{'language'} = 'JavaScript';
     $script->setUseSingleQuotes(TRUE);
     $script->setUseLineBreaks(FALSE);
     $code = '$(function() {';
     $code .= '$(\'select[name="' . $name . '"]\').html("");';
     foreach ($items as $key => $value) {
         $code .= '$("<option value=\'' . $key . '\'>' . $value . '</option>").appendTo(\'select[name="' . $name . '"]\');';
     }
     $code .= '});';
     $script->add($code);
     $script->show();
 }
Example #4
0
 /**
  * Send data for a form located in the parent window
  * @param $form_name  Form Name
  * @param $object     An Object containing the form data
  */
 public static function sendData($form_name, $object, $aggregate = FALSE)
 {
     // iterate the object properties
     if ($object) {
         foreach ($object as $field => $value) {
             if (is_object($value)) {
                 foreach ($value as $property => $data) {
                     // if inside ajax request, then utf8_encode if isn't utf8
                     if (utf8_encode(utf8_decode($data)) !== $data) {
                         $data = utf8_encode(addslashes($data));
                     } else {
                         $data = addslashes($data);
                     }
                     // send the property value to the form
                     $script = new TElement('script');
                     $script->{'language'} = 'JavaScript';
                     $script->setUseSingleQuotes(TRUE);
                     $script->setUseLineBreaks(FALSE);
                     $script->add(" try {\n                                                \$('form[name={$form_name}]').find('[name={$field}_{$property}]').val('{$data}');\n                                             } catch (e) { } ");
                     $script->show();
                 }
             } else {
                 // if inside ajax request, then utf8_encode if isn't utf8
                 if (utf8_encode(utf8_decode($value)) !== $value) {
                     $value = utf8_encode(addslashes($value));
                 } else {
                     $value = addslashes($value);
                 }
                 // send the property value to the form
                 $script = new TElement('script');
                 $script->{'language'} = 'JavaScript';
                 $script->setUseSingleQuotes(TRUE);
                 $script->setUseLineBreaks(FALSE);
                 if ($aggregate) {
                     $script->add("try\n                                        {\n                                            if (document.{$form_name}.{$field}.value == \"\")\n                                            {\n                                                \$('form[name={$form_name}]').find('[name={$field}]').val('{$value}');\n                                            }\n                                            else\n                                            {\n                                                document.{$form_name}.{$field}.value = document.{$form_name}.{$field}.value + ', {$value}'\n                                            }\n                                        } catch (e) { } ");
                 } else {
                     $script->add("\n                                            \$('form[name={$form_name}]').find('[name={$field}]').val('{$value}');\n                                            if (\$('form[name={$form_name}]').find('[name={$field}]').attr('exitaction'))\n                                            {\n                                                eval(\$('form[name={$form_name}]').find('[name={$field}]').attr('exitaction'));\n                                            }\n                                        ");
                 }
                 $script->show();
             }
         }
     }
 }
Example #5
0
 /**
 Close all TJQueryDialog
 */
 public static function closeAll()
 {
     $script = new TElement('script');
     $script->{'language'} = 'JavaScript';
     $script->setUseLineBreaks(FALSE);
     $script->setUseSingleQuotes(TRUE);
     $script->add('$(\'[widget="T' . 'Window"]\').remove();');
     $script->show();
 }
 /**
  * Disable the field
  * @param $form_name Form name
  * @param $field Field name
  */
 public static function disableField($form_name, $field)
 {
     $script = new TElement('script');
     $script->{'language'} = 'JavaScript';
     $script->setUseSingleQuotes(TRUE);
     $script->setUseLineBreaks(FALSE);
     $script->add(" try { document.{$form_name}.{$field}.disabled = true; } catch (e) { } ");
     $script->add(" try { document.{$form_name}.{$field}.className = 'tfield_disabled'; } catch (e) { } ");
     $script->add(" setTimeout(function(){ \$('[name=_{$field}_link]').hide() },1); ");
     $script->show();
 }
Example #7
0
 /**
  * Disable the field
  * @param $form_name Form name
  * @param $field Field name
  */
 public static function disableField($form_name, $field)
 {
     $script = new TElement('script');
     $script->{'language'} = 'JavaScript';
     $script->setUseSingleQuotes(TRUE);
     $script->setUseLineBreaks(FALSE);
     $script->add(" try { document.{$form_name}.{$field}.disabled = true; } catch (e) { } ");
     $script->add(" try { document.{$form_name}.{$field}.className = 'tcombo_disabled'; } catch (e) { } ");
     $script->show();
 }
 /**
  * Clear the field
  * @param $form_name Form name
  * @param $field Field name
  */
 public static function clearField($form_name, $field)
 {
     $script = new TElement('script');
     $script->{'language'} = 'JavaScript';
     $script->setUseSingleQuotes(TRUE);
     $script->setUseLineBreaks(FALSE);
     $script->add(" try { document.{$form_name}.{$field}.value='' } catch (e) { } ");
     $script->add(" try { document.{$form_name}.{$field}.nextSibling.value='' } catch (e) { } ");
     $script->show();
 }
Example #9
0
 /**
  * Clear the field
  * @param $form_name Form name
  * @param $field Field name
  */
 public static function clearField($form_name, $field)
 {
     $script = new TElement('script');
     $script->{'language'} = 'JavaScript';
     $script->setUseSingleQuotes(TRUE);
     $script->setUseLineBreaks(FALSE);
     $script->add(" try {\n                                var parentDiv = document.{$form_name}.{$field}.parentNode;\n                                if( parentDiv.firstChild.tagName == 'IMG' )\n                                {\n                                    parentDiv.firstChild.remove();\n                                }\n                            } catch (e) { } ");
     $script->add(" try { document.{$form_name}.{$field}.value='' } catch (e) { } ");
     $script->add(" try { document.{$form_name}.file_{$field}.value='' } catch (e) { } ");
     $script->show();
 }
 /**
  * clear the field
  * @param $form_name Form name
  * @param $field Field name
  */
 public static function clearField($form_name, $field)
 {
     $script = new TElement('script');
     $script->{'language'} = 'JavaScript';
     $script->setUseSingleQuotes(TRUE);
     $script->setUseLineBreaks(FALSE);
     $script->add(" setTimeout(function(){ \$('[checkgroup={$field}]').attr('checked', false) },1);");
     $script->show();
 }
Example #11
0
 /**
  * Disable the field
  * @param $form_name Form name
  * @param $field Field name
  */
 public static function disableField($form_name, $field)
 {
     $script = new TElement('script');
     $script->{'language'} = 'JavaScript';
     $script->setUseSingleQuotes(TRUE);
     $script->setUseLineBreaks(FALSE);
     $script->add(" try { document.{$form_name}.{$field}.setAttribute('disabled', true); } catch (e) { } ");
     $script->show();
 }
 /**
  * Clear the field
  * @param $form_name Form name
  * @param $field Field name
  */
 public static function clearField($form_name, $field)
 {
     $script = new TElement('script');
     $script->{'language'} = 'JavaScript';
     $script->setUseSingleQuotes(TRUE);
     $script->setUseLineBreaks(FALSE);
     $script->add("\$('#{$field}mfTable .tmultifield_scrolling').html('');");
     $script->show();
 }