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 { $output = "<img border=\"0\" src=\"//maps.googleapis.com/maps/api/staticmap?center={$this->value['lat']},{$this->value['lon']}&zoom={$this->zoom}&size=500x500\">"; } $output = "<div class='help-block'>" . $output . "</div>"; break; case "create": case "modify": $output = Form::hidden($this->lat, $this->value['lat'], ['id' => $this->lat]); $output .= Form::hidden($this->lon, $this->value['lon'], ['id' => $this->lon]); $output .= '<div id="map_' . $this->name . '" 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('{$this->lat}');\n var longitude = document.getElementById('{$this->lon}');\n var zoom = {$this->zoom};\n \n var LatLng = new google.maps.LatLng(latitude.value, longitude.value);\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_{$this->name}'),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 (event) {\n latitude.value = event.latLng.lat();\n longitude.value = event.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 "disabled": case "show": case "create": case "modify": $output = $this->iframe(); \Rapyd::script("\n if(typeof iframeAutoResize != 'function'){\n window.iframeAutoResize = function(id){\n var newheight;\n var newwidth;\n \n if(document.getElementById){\n newheight = document.getElementById(id).contentWindow.document .body.scrollHeight;\n newwidth = document.getElementById(id).contentWindow.document .body.scrollWidth;\n }\n \n document.getElementById(id).height = (newheight) + 'px';\n document.getElementById(id).width = (newwidth) + 'px';\n };\n \n };\n "); break; case "hidden": $output = ""; break; default: } $this->output = "\n" . $output . "\n" . $this->extra_output . "\n"; }
public function initJsWidget() { $onChange = $this->onChange ?: ''; $ajax = $this->autoSave ? '$.post("", {"' . $this->name() . '": $(this).nestable("serialize")});' : ''; $script = ' $("[data-instance-id=\\"' . $this->attributes['data-instance-id'] . '\\"]").each(function(){ var root = $(this); var form = root.find(".datatree-values"); root.find(".datatree-inner-wrapper").nestable({ listNodeName: "ol", itemNodeName: "li", rootClass: "datatree-inner-wrapper", listClass: "datatree-list", itemClass: "datatree-item", dragClass: "datatree-dragel", handleClass: "datatree-handle", collapsedClass: "datatree-collapsed", placeClass: "datatree-placeholder", noDragClass: "datatree-nodrag", emptyClass: "datatree-empty", expandBtnHTML: "<button data-action=\\"expand\\" type=\\"button\\">Expand</button>", collapseBtnHTML: "<button data-action=\\"collapse\\" type=\\"button\\">Collapse</button>", group: ' . $this->group . ', maxDepth: ' . $this->maxDepth . ', threshold: 20 }).on("mousedown", "a", function (e) { e.stopImmediatePropagation(); }).each(function () { var ol = $(this).children(".datatree-list"); if (ol.length) rapyd.datatree.updateDepth(ol); rapyd.datatree.updateForm($(this), form, "' . $this->name . '"); }).on("change", function () { var ol = $(this).children(".datatree-list"); if (ol.length) rapyd.datatree.updateDepth(ol); var updated = rapyd.datatree.updateForm($(this), form, "' . $this->name . '"); ' . $ajax . ' ' . $onChange . ' }); $(".datatree").submit(function () { var action = $(this).attr("action") || document.location.href; //return false; }); }); '; \Rapyd::script($script); }