Exemplo n.º 1
0
 protected function fixupPlaceholder($inputOptions)
 {
     $id = $inputOptions['id'];
     $placeholder = $this->inputPlaceholder($inputOptions);
     $script = "\n      var \$input = \$j('#" . $id . "');\n      if (\$input.is(':enabled'))\n        \$input.attr('placeholder', '" . $placeholder . "');\n    ";
     Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $script, $afterReady = true);
 }
Exemplo n.º 2
0
 protected function fixupValidation($inputOptions)
 {
     // fixup para remover caracteres não numericos
     // inclusive pontos '.', não removidos pela super classe
     $js = " \$j('#" . $inputOptions['id'] . "').keyup(function(){\n      var oldValue = this.value;\n\n      this.value = this.value.replace(/[^0-9\\.]/g, '');\n      this.value = this.value.replace('.', '');\n\n      if (oldValue != this.value)\n        messageUtils.error('Informe apenas números.', this);\n\n    });";
     Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = false);
 }
Exemplo n.º 3
0
 protected function fixupOptions($inputOptions)
 {
     $id = $inputOptions['id'];
     $sizeFixup = "\$input.attr('size', " . $inputOptions['size'] . ");";
     $disableFixup = $inputOptions['disabled'] ? "\$input.attr('disabled', 'disabled');" : '';
     $script = "\n      var \$input = \$j('#" . $id . "');\n      {$sizeFixup}\n      {$disableFixup}\n    ";
     Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $script, $afterReady = true);
 }
Exemplo n.º 4
0
 public function checkbox($attrName, $options = array())
 {
     $defaultOptions = array('options' => array(), 'objectName' => '');
     $options = $this->mergeOptions($options, $defaultOptions);
     $spacer = !empty($options['objectName']) && !empty($attrName) ? '_' : '';
     $defaultInputOptions = array('id' => $options['objectName'] . $spacer . $attrName, 'label' => ucwords($attrName), 'value' => '', 'label_hint' => '', 'inline' => false, 'script' => 'fixupCheckboxValue(this)', 'disabled' => false);
     $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions);
     // fixup para enviar um valor, junto ao param do checkbox.
     $js = "var fixupCheckboxValue = function(input) {\n      var \$this = \$j(input);\n      \$this.val(\$this.is(':checked') ? 'on' : '');\n    }";
     Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = false);
     call_user_func_array(array($this->viewInstance, 'campoCheck'), $inputOptions);
 }
Exemplo n.º 5
0
 protected function js($objectName, $attrName, $options)
 {
     // setup multiple search
     /*
       all search options (including the option chosenOptions, that is passed for chosen plugin),
       can be overwritten adding "var = multipleSearch<ObjectName>Options = { 'options' : 'val', option2 : '_' };"
       in the script file for the resource controller.
     */
     $resourceOptions = "multipleSearch" . Portabilis_String_Utils::camelize($objectName) . "Options";
     $js = "{$resourceOptions} = typeof {$resourceOptions} == 'undefined' ? {} : {$resourceOptions};\n           multipleSearchHelper.setup('{$objectName}', '{$attrName}', '" . $options['searchPath'] . "', {$resourceOptions});";
     // this script will be executed after the script for the current controller (if it was loaded in the view);
     Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = true);
 }
    public function bibliotecaPesquisaCliente($options = array())
    {
        $defaultOptions = array('id' => null, 'options' => array(), 'hiddenInputOptions' => array());
        $options = $this->mergeOptions($options, $defaultOptions);
        $inputHint = "<img border='0' onclick='pesquisaCliente();' id='lupa_pesquisa_cliente' name='lupa_pesquisa_cliente' src='imagens/lupa.png' />";
        // input
        $defaultInputOptions = array('id' => 'nome_cliente', 'label' => 'Cliente', 'value' => '', 'size' => '30', 'max_length' => '255', 'required' => true, 'expressao' => false, 'inline' => false, 'label_hint' => '', 'input_hint' => $inputHint, 'callback' => '', 'event' => 'onKeyUp', 'disabled' => true);
        $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions);
        call_user_func_array(array($this->viewInstance, 'campoTexto'), $inputOptions);
        // hidden input
        $defaultHiddenInputOptions = array('id' => 'ref_cod_cliente', 'value' => $this->getResourceId($options['id']));
        $hiddenInputOptions = $this->mergeOptions($options['hiddenInputOptions'], $defaultHiddenInputOptions);
        call_user_func_array(array($this->viewInstance, 'campoOculto'), $hiddenInputOptions);
        // js
        Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, '
      var resetCliente = function(){
        $("#ref_cod_cliente").val("");
        $("#nome_cliente").val("");
      }

      $("#ref_cod_biblioteca").change(resetCliente);', true);
        Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, "\n      function pesquisaCliente() {\n        var additionalFields = getElementFor('biblioteca');\n        var exceptFields     = getElementFor('nome_cliente');\n\n        if (validatesPresenseOfValueInRequiredFields(additionalFields, exceptFields)) {\n  \t      var bibliotecaId   = getElementFor('biblioteca').val();\n          var attrIdName     = getElementFor('cliente').attr('id');\n\n\t        pesquisa_valores_popless('educar_pesquisa_cliente_lst.php?campo1='+attrIdName+'&campo2=nome_cliente&ref_cod_biblioteca='+bibliotecaId);\n        }\n      }\n    ");
    }
Exemplo n.º 7
0
 protected function js($objectName, $attrName, $options)
 {
     // load simple search js
     $jsFile = '/modules/Portabilis/Assets/Javascripts/Frontend/Inputs/SimpleSearch.js';
     Portabilis_View_Helper_Application::loadJavascript($this->viewInstance, $jsFile);
     // setup simple search
     /*
       all search options (including the option autocompleteOptions, that is passed for jquery autocomplete plugin),
       can be overwritten adding "var = simpleSearch<ObjectName>Options = { option : '...', optionName : '...' };"
       in the script file for the resource controller.
     */
     $resourceOptions = "simpleSearch" . Portabilis_String_Utils::camelize($objectName) . "Options";
     $js = "{$resourceOptions} = typeof {$resourceOptions} == 'undefined' ? {} : {$resourceOptions};\n           simpleSearchHelper.setup('{$objectName}', '{$attrName}', '" . $options['searchPath'] . "', {$resourceOptions});";
     // this script will be executed after the script for the current controller (if it was loaded in the view);
     Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = true);
 }
 protected function placeholderJs($options)
 {
     $optionsVarName = "multipleSearch" . Portabilis_String_Utils::camelize($options['objectName']) . "Options";
     $js = "if (typeof {$optionsVarName} == 'undefined') { {$optionsVarName} = {} };\n                       {$optionsVarName}.placeholder = safeUtf8Decode('Selecione os assuntos');";
     Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = true);
 }
Exemplo n.º 9
0
 public static function embedJavascriptToFixupFieldsWidth($viewInstance)
 {
     Portabilis_View_Helper_Application::loadJQueryLib($viewInstance);
     Portabilis_View_Helper_Application::loadJavascript($viewInstance, '/modules/Portabilis/Assets/Javascripts/Utils.js');
     Portabilis_View_Helper_Application::embedJavascript($viewInstance, 'fixupFieldsWidth();', $afterReady = true);
 }
    public function bibliotecaPesquisaObra($options = array())
    {
        $defaultOptions = array('id' => null, 'options' => array(), 'hiddenInputOptions' => array());
        $options = $this->mergeOptions($options, $defaultOptions);
        $inputHint = "<img border='0' onclick='pesquisaObra();' id='lupa_pesquisa_obra' name='lupa_pesquisa_obra' src='imagens/lupa.png' />";
        // se não recuperar obra, deixa titulo em branco
        $obra = $this->getObra($options['id']);
        $tituloObra = $obra ? $obra['titulo'] : '';
        $defaultInputOptions = array('id' => 'titulo_obra', 'label' => 'Obra', 'value' => $tituloObra, 'size' => '30', 'max_length' => '255', 'required' => true, 'expressao' => false, 'inline' => false, 'label_hint' => '', 'input_hint' => $inputHint, 'callback' => '', 'event' => 'onKeyUp', 'disabled' => true);
        $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions);
        call_user_func_array(array($this->viewInstance, 'campoTexto'), $inputOptions);
        // hidden input
        $defaultHiddenInputOptions = array('id' => 'ref_cod_acervo', 'value' => $this->getAcervoId($options['id']));
        $hiddenInputOptions = $this->mergeOptions($options['hiddenInputOptions'], $defaultHiddenInputOptions);
        call_user_func_array(array($this->viewInstance, 'campoOculto'), $hiddenInputOptions);
        // Ao selecionar obra, na pesquisa de obra é setado o value deste elemento
        $this->viewInstance->campoOculto("cod_biblioteca", "");
        Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, '
      var resetObra = function(){
        $("#ref_cod_acervo").val("");
        $("#titulo_obra").val("");
      }

      $("#ref_cod_biblioteca").change(resetObra);', true);
        Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, '
      function pesquisaObra() {

        var additionalFields = getElementFor("biblioteca");
        var exceptFields     = getElementFor("titulo_obra");

        if (validatesPresenseOfValueInRequiredFields(additionalFields, exceptFields)) {
  	      var bibliotecaId = getElementFor("biblioteca").val();

          pesquisa_valores_popless("educar_pesquisa_obra_lst.php?campo1=ref_cod_acervo&campo2=titulo_obra&campo3="+bibliotecaId)
        }
      }');
    }
 protected function reCaptchaFixup()
 {
     $this->campoRotulo('replace_by_recaptcha_widget_wrapper', 'Confirma&ccedil;&atilde;o visual', '<div id="replace_by_recaptcha_widget"></div>');
     $js = "function replaceRecaptchaWidget() {\n              var emptyElement = document.getElementById('replace_by_recaptcha_widget');\n              var originElement = document.getElementById('recaptcha_widget_div');\n              emptyElement.parentNode.replaceChild(originElement, emptyElement);\n            }\n\n            window.onload = replaceRecaptchaWidget;";
     Portabilis_View_Helper_Application::embedJavascript($this, $js);
 }
Exemplo n.º 12
0
 function afterChangePessoa($id)
 {
     Portabilis_View_Helper_Application::embedJavascript($this, "\n\n      if(window.opener &&  window.opener.afterChangePessoa) {\n        var parentType = \$j('#parent_type').val();\n\n        if (parentType)\n          window.opener.afterChangePessoa(self, parentType, {$id}, \$j('#nm_pessoa').val());\n        else\n          window.opener.afterChangePessoa(self, {$id});\n      }\n      else\n        document.location = 'atendidos_lst.php';\n\n    ", $afterReady = true);
 }
Exemplo n.º 13
0
    public function pesquisaAluno($options = array())
    {
        $defaultOptions = array('id' => null, 'options' => array(), 'filterByEscola' => false);
        $options = $this->mergeOptions($options, $defaultOptions);
        $inputHint = "<img border='0' onclick='pesquisaAluno();' id='lupa_pesquisa_aluno' name='lupa_pesquisa_aluno' src='imagens/lupa.png' />";
        // se não recuperar recurso, deixa resourceLabel em branco
        $resource = $this->getResource($options['id']);
        $resourceLabel = $resource ? $resource['nome_aluno'] : '';
        $defaultInputOptions = array('id' => 'nm_aluno', 'label' => 'Aluno', 'value' => $resourceLabel, 'size' => '30', 'max_length' => '255', 'required' => true, 'expressao' => false, 'inline' => false, 'label_hint' => '', 'input_hint' => $inputHint, 'callback' => '', 'event' => 'onKeyUp', 'disabled' => true);
        $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions);
        call_user_func_array(array($this->viewInstance, 'campoTexto'), $inputOptions);
        $this->viewInstance->campoOculto("ref_cod_aluno", $this->inputValue($options['id']));
        Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, '
      var resetAluno = function(){
        $("#ref_cod_aluno").val("");
        $("#nm_aluno").val("");
      }

      $("#ref_cod_escola").change(resetAluno);', true);
        if ($options['filterByEscola']) {
            $js = 'function pesquisaAluno() {
          var additionalFields = [document.getElementById("ref_cod_escola")];
          var exceptFields     = [document.getElementById("nm_aluno")];

          if (validatesPresenseOfValueInRequiredFields(additionalFields, exceptFields)) {

    	      var escolaId = document.getElementById("ref_cod_escola").value;
            pesquisa_valores_popless("/intranet/educar_pesquisa_aluno.php?ref_cod_escola="+escolaId);
          }
        }';
        } else {
            $js = 'function pesquisaAluno() {
          var exceptFields     = [document.getElementById("nm_aluno")];

          if (validatesPresenseOfValueInRequiredFields([], exceptFields)) {
            pesquisa_valores_popless("/intranet/educar_pesquisa_aluno.php");
          }
        }';
        }
        Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js);
    }