Exemplo n.º 1
0
 public function build()
 {
     $output = "";
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "disabled":
         case "show":
             if ($this->type == 'hidden' || $this->value == "") {
                 $output = "";
             } elseif (!isset($this->value)) {
                 $output = $this->layout['null_label'];
             } else {
                 $output = nl2br(htmlspecialchars($this->value));
             }
             $output = "<div class='help-block'>" . $output . "&nbsp;</div>";
             break;
         case "create":
         case "modify":
             $output = Form::text($this->name, $this->value, $this->attributes);
             break;
         case "hidden":
             $output = Form::hidden($this->name, $this->value);
             break;
         default:
     }
     $this->output = "\n" . $output . "\n" . $this->extra_output . "\n";
 }
Exemplo n.º 2
0
 public function build()
 {
     $output = "";
     $this->attributes["class"] = "form-control";
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "disabled":
         case "show":
             if ($this->type == 'hidden' || $this->value == "") {
                 $output = "";
             } elseif (!isset($this->value)) {
                 $output = $this->layout['null_label'];
             } else {
                 //immagine statica della mappa su lat e lon  su api google
             }
             $output = "<div class='help-block'>" . $output . "</div>";
             break;
         case "create":
         case "modify":
             $output = Form::text($this->lat, $this->attributes);
             $output .= Form::text($this->lon, $this->attributes);
             $output .= '<div id="map" style="width:500px; height:500px"></div>';
             $output .= '<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>';
             Rapyd::script("\n        \n            function initialize()\n            {\n                var latitude = document.getElementById('latitude');\n                var longitude = document.getElementById('longitude');\n                var zoom = 7;\n        \n                var LatLng = new google.maps.LatLng(latitude, longitude);\n        \n                var mapOptions = {\n                    zoom: zoom,\n                    center: LatLng,\n                    panControl: false,\n                    zoomControl: false,\n                    scaleControl: true,\n                    mapTypeId: google.maps.MapTypeId.ROADMAP\n                }\n        \n                var map = new google.maps.Map(document.getElementById('map'),mapOptions);\n        \n                var marker = new google.maps.Marker({\n                    position: LatLng,\n                    map: map,\n                    title: 'Drag Me!',\n                    draggable: true\n                });\n        \n                google.maps.event.addListener(marker, 'dragend', function (marker) {\n                    var latLng = marker.latLng;\n                    latitude.value = LatLng.lat();\n                    longitude.value = LatLng.lng();\n                });\n        \n            }\n            initialize();\n        ");
             break;
         case "hidden":
             $output = '';
             //Form::hidden($this->db_name, $this->value);
             break;
         default:
     }
     $this->output = "\n" . $output . "\n" . $this->extra_output . "\n";
 }
 public function build()
 {
     $output = "";
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "show":
             $output = $this->value;
             $output = "<div class='help-block' style='background-color:" . $output . "'>&nbsp;</div>";
             break;
         case "create":
         case "modify":
             Rapyd::css('colorpicker/css/bootstrap-colorpicker.min.css');
             Rapyd::js('colorpicker/js/bootstrap-colorpicker.min.js');
             $output = Form::text($this->name, $this->value, $this->attributes);
             $output .= Rapyd::script("\n                        \$('#" . $this->name . "').colorpicker({\n                            format: 'hex'\n                        });");
             break;
         case "hidden":
             $output = Form::hidden($this->name, $this->value);
             break;
         default:
     }
     $this->output = $output;
 }
Exemplo n.º 4
0
 public function build()
 {
     $output = "";
     unset($this->attributes['type']);
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "show":
             if (!isset($this->value)) {
                 $value = $this->layout['null_label'];
             } else {
                 $value = str_replace($this->serialization_sep, ' ', $this->value);
             }
             $output = $value;
             $output = "<div class='help-block'>" . $output . "&nbsp;</div>";
             break;
         case "create":
         case "modify":
             Rapyd::css('datepicker/datepicker3.css');
             Rapyd::js('datepicker/bootstrap-datepicker.js');
             if ($this->language != "en") {
                 Rapyd::js('datepicker/locales/bootstrap-datepicker.' . $this->language . '.js');
             }
             unset($this->attributes['id']);
             //$this->attributes['class'] = "form-control";
             $from = Form::text($this->name . '[from]', @$this->values[0], $this->attributes);
             $to = Form::text($this->name . '[to]', @$this->values[1], $this->attributes);
             $output = '
                         <div id="range_' . $this->name . '_container">
                             <div class="input-daterange">
                                <div class="input-group">
                                    <div class="input-group-addon">&ge;</div>
                                    ' . $from . '
                                </div>
                                <div class="input-group">
                                     <div class="input-group-addon">&le;</div>
                                     ' . $to . '
                                </div>
                             </div>
                         </div>';
             Rapyd::pop_script();
             Rapyd::script("\n                        \$('#range_{$this->name}_container .input-daterange').datepicker({\n                            format: '{$this->formatToDate()}',\n                            language: '{$this->language}',\n                            todayBtn: 'linked',\n                            autoclose: true\n                        });");
             break;
         case "hidden":
             $output = Form::hidden($this->name, $this->value);
             break;
         default:
     }
     $this->output = $output;
 }
    public function build()
    {
        $output = "";

        unset($this->attributes['type']);
        if (parent::build() === false) return;

        switch ($this->status) {

            case "show":
                if (!isset($this->value)) {
                    $value = $this->layout['null_label'];
                } else {
                    $value = $this->isoDateToHuman($this->value);
                }
                $output = $value;
                $output = "<div class='help-block'>".$output."&nbsp;</div>";
                break;

            case "create":
            case "modify":
                if ($this->value != "") {
                    if (!$this->is_refill) {
                        $this->value = $this->isoDateToHuman($this->value);
                    }
                }

                Rapyd::css('datepicker/datepicker3.css');
                Rapyd::js('datepicker/bootstrap-datepicker.js');
                if ($this->language != "en") {
                    Rapyd::js('datepicker/locales/bootstrap-datepicker.'.$this->language.'.js');
                }

                $output  = Form::text($this->name, $this->value,  $this->attributes);
                Rapyd::script("
                        $('#".$this->name."').datepicker({
                            format: '{$this->formatToDate()}',
                            language: '{$this->language}',
                            todayBtn: 'linked',
                            autoclose: true
                        });");

                break;
            case "hidden":
                $output = Form::hidden($this->db_name, $this->value);
                break;
            default:;
        }
        $this->output = $output;
    }
Exemplo n.º 6
0
    public function build()
    {
        $output = "";
        Rapyd::css('autocomplete/autocomplete.css');
        Rapyd::js('autocomplete/typeahead.bundle.min.js');
        Rapyd::js('template/handlebars.js');
        unset($this->attributes['type']);
        if (parent::build() === false) {
            return;
        }
        switch ($this->status) {
            case "disabled":
            case "show":
                if (!isset($this->value)) {
                    $output = $this->layout['null_label'];
                } elseif ($this->value == "") {
                    $output = "";
                } else {
                    if ($this->relation != null) {
                        $name = $this->rel_field;
                        $value = @$this->relation->get()->first()->{$name};
                    } else {
                        $value = $this->value;
                    }
                    $output = nl2br(htmlspecialchars($value));
                }
                $output = "<div class='help-block'>" . $output . "&nbsp;</div>";
                break;
            case "create":
            case "modify":
                if (Input::get("auto_" . $this->name)) {
                    $autocomplete = Input::get("auto_" . $this->name);
                } elseif ($this->relation != null) {
                    $name = $this->rel_field;
                    $autocomplete = @$this->relation->get()->first()->{$name};
                } elseif (count($this->local_options)) {
                    $autocomplete = $this->description;
                } else {
                    $autocomplete = $this->value;
                }
                $output = Form::text("auto_" . $this->name, $autocomplete, array_merge($this->attributes, array('id' => "auto_" . $this->name))) . "\n";
                $output .= Form::hidden($this->name, $this->value, array('id' => $this->name));
                $output = '<span id="th_' . $this->name . '">' . $output . '</span>';
                if ($this->remote) {
                    $script = <<<acp

                    var blod_{$this->name} = new Bloodhound({
                        datumTokenizer: Bloodhound.tokenizers.obj.whitespace('auto_{$this->name}'),
                        queryTokenizer: Bloodhound.tokenizers.whitespace,
                        remote: '{$this->remote}?q=%QUERY'
                    });
                    blod_{$this->name}.initialize();

                    \$('#th_{$this->name} .typeahead').typeahead(null, {
                        name: '{$this->name}',
                        displayKey: '{$this->record_label}',
                        highlight: true,
                        minLength: {$this->min_chars},
                        source: blod_{$this->name}.ttAdapter(),
                        templates: {
                            suggestion: Handlebars.compile('{{{$this->record_label}}}')
                        }
                    }).on("typeahead:selected typeahead:autocompleted",
                        function (e,data) { \$('#{$this->name}').val(data.{$this->record_id});

                    }).on("typeahead:closed",
                        function (e,data) {
                            if (\$(this).val() == '') {
                                \$('#{$this->name}').val('');
                            }
                    });
acp;
                    Rapyd::script($script);
                } elseif (count($this->options)) {
                    $options = json_encode($this->local_options);
                    //options
                    $script = <<<acp

                    var {$this->name}_options = {$options};
                    var blod_{$this->name} = new Bloodhound({
                        datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
                        queryTokenizer: Bloodhound.tokenizers.whitespace,
                        local: {$this->name}_options
                    });


                    blod_{$this->name}.initialize();

                    \$('#th_{$this->name} .typeahead').typeahead({
                         hint: true,
                         highlight: true,
                         minLength: {$this->min_chars}
                    },
                    {
                        name: '{$this->name}',
                        displayKey: 'value',
                        source: blod_{$this->name}.ttAdapter()
                    }).on("typeahead:selected typeahead:autocompleted",
                        function (e,data) {
                            \$('#{$this->name}').val(data.key);
                    }).on("typeahead:closed",
                        function (e,data) {
                            if (\$(this).val() == '') {
                                \$('#{$this->name}').val('');
                            }
                    });
acp;
                    Rapyd::script($script);
                }
                break;
            case "hidden":
                $output = Form::hidden($this->db_name, $this->value);
                break;
            default:
        }
        $this->output = "\n" . $output . "\n" . $this->extra_output . "\n";
    }
Exemplo n.º 7
0
    public function build()
    {
        $output = "";
        //typeahead
        Rapyd::css('autocomplete/autocomplete.css');
        Rapyd::js('autocomplete/typeahead.bundle.min.js');
        Rapyd::js('template/handlebars.js');
        //tagsinput
        Rapyd::css('autocomplete/bootstrap-tagsinput.css');
        Rapyd::js('autocomplete/bootstrap-tagsinput.min.js');
        unset($this->attributes['type']);
        if (parent::build() === false) {
            return;
        }
        switch ($this->status) {
            case "disabled":
            case "show":
                if (!isset($this->value)) {
                    $output = $this->layout['null_label'];
                } else {
                    $output = $this->description;
                }
                $output = "<div class='help-block'>" . $output . "&nbsp;</div>";
                break;
            case "create":
            case "modify":
                $output = Form::text($this->name, '', array_merge($this->attributes, array('id' => "" . $this->name))) . "\n";
                if ($this->remote) {
                    $script = <<<acp

                    \$('#{$this->name}').tagsinput({
                      itemValue: '{$this->record_id}',
                      itemText: '{$this->record_label}'
                    });
                    {$this->fill_tags}

                    var blod_{$this->name} = new Bloodhound({
                        datumTokenizer: Bloodhound.tokenizers.obj.whitespace('{$this->name}'),
                        queryTokenizer: Bloodhound.tokenizers.whitespace,
                        remote: '{$this->remote}?q=%QUERY'
                    });
                    blod_{$this->name}.initialize();

                    \$('#{$this->name}').tagsinput('input').typeahead(null, {
                        name: '{$this->name}',
                        displayKey: '{$this->record_label}',
                        highlight: true,
                        minLength: {$this->min_chars},
                        source: blod_{$this->name}.ttAdapter()
                    }).bind('typeahead:selected', \$.proxy(function (obj, data) {
                        this.tagsinput('add', data);
                        this.tagsinput('input').typeahead('val', '');
                    }, \$('#{$this->name}')));


acp;
                    Rapyd::script($script);
                } elseif (count($this->options)) {
                    $options = json_encode($this->local_options);
                    //options
                    $script = <<<acp

                    var {$this->name}_options = {$options};


                    \$('#{$this->name}').tagsinput({
                      itemValue: 'key',
                      itemText: 'value'
                    });
                    {$this->fill_tags}


                    var blod_{$this->name} = new Bloodhound({
                        datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
                        queryTokenizer: Bloodhound.tokenizers.whitespace,
                        local: {$this->name}_options
                    });


                    blod_{$this->name}.initialize();
                    \$('#{$this->name}').tagsinput('input').typeahead({
                         hint: true,
                         highlight: true,
                         minLength: {$this->min_chars}
                    },
                    {
                        name: '{$this->name}',
                        displayKey: 'value',
                        source: blod_{$this->name}.ttAdapter()
                    }).bind('typeahead:selected', \$.proxy(function (obj, data) {
                        this.tagsinput('add', data);
                        this.tagsinput('input').typeahead('val', '');
                    }, \$('#{$this->name}')));

acp;
                    Rapyd::script($script);
                }
                break;
            case "hidden":
                $output = Form::hidden($this->db_name, $this->value);
                break;
            default:
        }
        $this->output = "\n" . $output . "\n" . $this->extra_output . "\n";
    }