PHP Classes

File: ajax_jquery

Recommend this page to a friend!
  Classes of Allan Kibet   jQuery Generator   ajax_jquery   Download  
File: ajax_jquery
Role: Application script
Content type: text/plain
Description: php to jquery converter
Class: jQuery Generator
Generate HTML to use the jQuery library
Author: By
Last change:
Date: 11 years ago
Size: 4,624 bytes
 

Contents

Class file image Download
<?php

/*
 * This is JQuery lazy loading library
 * Script designed and assembled by Allan Kibet
 */

class JQuery
{
    public static function
loadAjax($form_id, $event, $script_processor, $output_div, $method){
   
?>
<script type="text/javascript">
            $(document).ready(function(){
                $('#<?=$form_id; ?>').<?=$event; ?>(function(){
                    $.<?=$method; ?>("<?=$script_processor; ?>", $("#<?=$form_id; ?>").serialize(), function(data){
                            $("#<?=$output_div; ?>").text(data);
                        });
                    return false;
                });
            });
        </script>
      <?
   
}
   
    public static function
hideElement($invoker, $event, $target, $speed){
   
?>
<script type="text/javascript">
            $(document).ready(function(){
                $('<?=$invoker; ?>').<?=$event; ?>(function(){
                    $('<?=$target; ?>').hide(<?=$speed; ?>);
                });
            });
        </script>
    <?
   
}
   
    public static function
showElement($invoker, $event, $target, $speed){
   
?>
<script type="text/javascript">
            $(document).ready(function(){
                $('<?=$invoker; ?>').<?=$event; ?>(function(){
                    $('<?=$target; ?>').show(<?=$speed; ?>);
                });
            });
        </script>
    <?php
   
}
   
    public static function
slideElement($invoker, $event, $target, $animation_type, $speed){
   
?>
<script type="text/javascript">
            $(document).ready(function(){
                 $('<?=$invoker; ?>').<?=$event; ?>(function(){
                    $('<?=$target; ?>').<?=$animation_type; ?>('<?=$speed; ?>');
                });
            });
        </script>
    <?
   
}
   
    public static function
toggleElement($invoker, $event, $target, $speed){
   
?>
<script type="text/javascript">
            $(document).ready(function(){
                $('<?=$invoker; ?>').<?=$event; ?>(function(){
                    $('<?=$target; ?>').toggle(<?=$speed; ?>);
                });
            });
        </script>
    <?
   
}
   
    public static function
disableField($invoker, $event, $target){
   
?>
<script type="text/javascript">
            $(document).ready(function(){
                $('<?=$invoker; ?>').<?=$event; ?>(function() {
                    $('<?=$target; ?>').attr('disabled', true);
                });
            });
        </script>
    <?php
   
}
   
    public static function
enableField($invoker, $event, $target){
   
?>
<script type="text/javascript">
            $(document).ready(function(){
                $('<?=$invoker; ?>').<?=$event; ?>(function() {
                    $('<?=$target; ?>').attr('disabled', false);
                });
            });
        </script>
    <?php
   
}
}

###### THIRD PARTY ######

/*
 * GoMap ~ Courtesy of Jevgenijs Shtrauss
 */

class GoMaps
{

   
//Used for debbugging purposes only :: Loads an abstract unspecified map
   
public static function loadMap($target){
   
?>
<script type="text/javascript">
            $(document).ready(function(){
                $('<?=$target; ?>').goMap();
            });
        </script>
    <?php
   
}
   
    public static function
loadMapByCordinates($target, $latitude, $longitude, $zoom){
   
?>
<script type="text/javascript">
            $(document).ready(function(){
                $('<?=$target; ?>').goMap({
                    latitude : <?=$latitude; ?>,
                    longitude : <?=$longitude; ?>,
                    zoom : <?=$zoom; ?>
}); // end goMap
            });
        </script>
    <?
   
}
   
    public static function
loadMapWithTracker($target, $address, $title, $content, $zoom){
   
?>
<script type="text/javascript">
            $(document).ready(function(){
                $('<?=$target; ?>').goMap({
                    markers : [{
                        address : '<?=$address; ?>',
                        title : '<?=$title; ?>',
                        html : {
                            content : '<?=$content; ?>',
                            popup : true
                        }
                    }],
                    zoom : <?=$zoom; ?>,
                }); // end goMap
            });
        </script>
    <?php
   
}
}

?>