RSS
Link

http://kennykee.com/138/codeigniter-resize-and-crop-image-to-fit-container-div-example/

 
Leave a comment

Posted by on September 14, 2015 in Codeigniter

 

Tags:

Google Map InfoBox

<!DOCTYPE html> 
<html> 
<head> 
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> 
<script type="text/javascript" src="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/src/infobox.js"></script> 
<script type="text/javascript"> 
    var ib = null;
    var theMap = null; 
function initialize() {
    var latlng = new google.maps.LatLng(55.672962361614566, 12.56587028503418);

    var myMapOptions = {
         zoom: 15
        ,center: latlng
        ,mapTypeId: google.maps.MapTypeId.ROADMAP
        ,streetViewControl: false
    };
    theMap = new google.maps.Map(document.getElementById("map_canvas"), myMapOptions);
// namn
var name=[];
name.push('Test 1');
name.push('Test 2');

// positioner
var position=[];
position.push(new google.maps.LatLng(55.667093265894245,12.581255435943604));
position.push(new google.maps.LatLng(55.66453963191134, 12.584795951843262));

// infoboxes
var infobox = [];
infobox.push("<div>Hello 1</div>");
infobox.push("<div>Hello 2</div>");

  ib = new InfoBox({});

for (i = 0; i < position.length; i += 1) {
// Call function
createMarkers(position[i], infobox[i], name[i]);
}

function createMarkers(position,content,name) {
    // alert("createMarkers("+position+","+content+","+name+")");
    var marker = new google.maps.Marker({
        map: theMap,
        draggable: false,
        position: position,
        visible: true,
        title: name
    });

    var boxText = document.createElement("div");
    boxText.style.cssText = "background: yellow; width: 300px; height: 70px; padding: 5px;";
    boxText.innerHTML = content;

    var myOptions = {
         content: boxText
        ,disableAutoPan: false
        ,maxWidth: 0
        ,pixelOffset: new google.maps.Size(-37, -120)
        ,zIndex: null
        ,boxStyle: { 
            background: "url('tipbox.gif') no-repeat"
            ,opacity: 1
            ,width: "300px"
         }
        ,closeBoxMargin: "5px 5px 5px 5px"
        ,closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif"
        ,infoBoxClearance: new google.maps.Size(1, 1)
        ,isHidden: false
        ,pane: "floatPane"
        ,enableEventPropagation: false
    };

    google.maps.event.addListener(marker, "click", function (e) {
     alert("click");
        ib.setOptions(myOptions);
        ib.open(theMap, this);
    });

    ib.open(theMap, marker);
    ib.hide();

    }

}
</script> 

<title>Creating and Using an InfoBox</title> 
</head> 
<body onload="initialize()"> 
<div id="map_canvas" style="width: 100%; height: 400px"></div></body>
</html>

 
Leave a comment

Posted by on September 14, 2015 in Geo Programming

 

Tags: ,

Prepend Items to Bootstrap Typeahead

This is a little code snippet for manually adding static items along with typeahead suggestions list. This can be used to prepend or append items. I’m using biggora/bootstrap-ajax-typeahead

You only need to look for render event of the plugin and inject your code.

$("#customer").typeahead({
        onSelect: function(item) {
            ...
        },
        updater: function(item) {
            return item;
        },
        highlighter: function(name) {
           ...
        },
        ajax: {
            ...
            },
            
        render: function(items) {
            var uber = {render: $.fn.typeahead.Constructor.prototype.render};
            uber.render.call(this, items);
            this.$menu.prepend('<li class="nostyle"><a href="#" autocomplete="off" data-toggle="modal" data-target="#itemModal"><i class="fa fa-plus"></i> New Customer</a></li>');
            return this;
        }
    });

 

 
Leave a comment

Posted by on August 27, 2015 in Bootstrap, jQuery

 

Tags:

Disable right click and F12 in jQuery

$(document).ready(function(){
$("body").bind("contextmenu", function(e) {
    e.preventDefault();
});
document.onkeypress = function (event) {
        event = (event || window.event);
        if (event.keyCode == 123) {
            return false;
        }
    }
    document.onmousedown = function (event) {
        event = (event || window.event);
        if (event.keyCode == 123) {
            return false;
        }
    }
document.onkeydown = function (event) {
        event = (event || window.event);
        if (event.keyCode == 123) {
            return false;
        }
    }
});
 
Leave a comment

Posted by on July 16, 2015 in jQuery

 

Bootstrap3 Ajax Typeahead Templating

Plugin URL : https://github.com/biggora/bootstrap-ajax-typeahead

<script type="text/javascript">
    var items;
$("#search_item").typeahead({
    onSelect: function(item) {
        add_order_item(item.value);
    },
      updater: function (item) {
        return item;
    },
    highlighter: function(name){
         var item = _.find(items, function (c) {
                        return c.name == name;
                    });
           
        var itm = ''
                 + "<div class='typeahead_wrapper'>"
                 + "<div class='typeahead_labels'>"
                 + "<div class='typeahead_primary'><span class='pname'>" + item.name + "</span></div>"
                 + "<div class='typeahead_secondary'><span class='pprice'>Rs. "+ item.purchase_price +"</span><div>"
                 + "<div class='typeahead_secondary'>Code: "+ item.code +" / SKU: " + item.sku + "</div>"
                 + "</div>"
                 + "</div>";
                    return itm;
    },
            
    ajax: {
        url: "<?php echo base_url('items/suggest_json');?>",
        timeout: 500,
        item: '<li><a href="#"></a><p>fgfg</p></li>' ,
        scrollBar: true,
        valueField: "id",
        displayField: "name",
        triggerLength: 1,
        method: "get",
        loadingClass: "loading-circle",
        preDispatch: function (query) {
            //showLoadingMask(true);
            return {
                search: query
            }
        },
        preProcess: function (data) {
            //showLoadingMask(false);
            if (data.success === false) {
                // Hide the list, there was some error
                return false;
            }
            // We good!
            items = data.results;
            return data.results;
        }         
    }
});

function add_order_item(item_id){
alert(item_id);
</script>
 
Leave a comment

Posted by on May 29, 2015 in jQuery, plugins

 

Tags:

DataTables Server Side Processing with CodeIgniter

DataTables

DataTables

In this tutorial, we will see how to use popular dataTables with CodeIgniter framework. Note that, pagination is done in client side for this tutorial. Hence this example is not ideal for a big data set. Handling pagination in server side will be discussed in  a future tutorial.

Table format

                             <th>Need identified thru</th>
                                        <th>Total Estimate</th> 
                                        <th class="no-sort"></th>
                                        <th class="no-sort"></th>

                                    </tr>
                                </thead>

                            </table>

Initializing and fetching data with ajax


<script>
    $(document).ready(function() {
        $('#dataTables').dataTable({
            "ajax": "<?php echo base_url('test/get_json'); ?>",
            "pageLength": <?php echo $this->config->item('results_per_page'); ?>,
            "order": [[ 0, "desc" ]],
            "aoColumnDefs": [
                { "bVisible": false, "aTargets": [0] },
                {
                    "bSortable": false,
                    "aTargets": ["no-sort"]  
                }],
            "dom": 'T<"clear">lfrtip',
            tableTools: {
                "sSwfPath": "<?php echo base_url("plugins/data_tables/extensions/TableTools/swf/copy_csv_xls_pdf.swf"); ?>"
            }
        });
});
</script>

Test Controller

class Test extends CI_Controller {
public function get_json() {
        $this->load->model('test_model');
        $results = $this->test_model->load_grid();
        $data = array();
        foreach ($results  as $r) {
            array_push($data, array(
                $r['rname'],
                $r['year'],
                $r['mname'],
                $r['need'],
                $r['total_cost'],
                anchor('test/view/' . $r['id'], 'View'),
                anchor('test/edit/' . $r['id'], 'Edit')
            ));
        }

        echo json_encode(array('data' => $data));
    }
}

Model

class Test_model extends CI_Model {
public function load_grid() {
        $this->db->select("$this->tbl_urgent_needs.unid,$this->tbl_urgent_needs.year,$this->tbl_urgent_needs.needi,$this->tbl_urgent_needs.total_cost,$this->tbl_maintenance_type.name AS mname,$this->tbl_roads.name AS rname");
        $this->db->from("$this->tbl_urgent_needs");
        $this->db->join("$this->tbl_roads", "$this->tbl_roads.rid = $this->tbl_urgent_needs.rd_id");
        $this->db->join("$this->tbl_maintenance_type", "$this->tbl_maintenance_type.id = $this->tbl_urgent_needs.maint_type_id", "left");
        $this->db->order_by("$this->tbl_urgent_needs.unid", 'ASC');

        $query = $this->db->get();
        return $query->result_array();
    }
}

 
2 Comments

Posted by on May 20, 2015 in Codeigniter, PHP

 

Tags:

Link

http://gis.stackexchange.com/a/34613/14109

 
Leave a comment

Posted by on May 5, 2015 in Geo Programming

 

Tags: