Welcome Guest, Not a member yet? Register   Sign In
Jcrop Library Support for codeIgniter ( part IV ) view
#1

[eluser]Agung Wahyudiono[/eluser]
Code:
[removed]

<?php if(isset($ratio) && isset($orig_w) && isset($orig_h) && isset($target_w) && isset($target_h)): ?>

$(function(){

    $('#cropbox').Jcrop({

        aspectRatio: <?php echo $ratio ?>,

        setSelect: [0,0,<?php echo $orig_w.','.$orig_h;?>],

        onSelect: updateCoords,

        onChange: updateCoords

    });

});

function updateCoords(c)

{

    showPreview(c);

    $("#x").val(c.x);

    $("#y").val(c.y);

    $("#w").val(c.w);

    $("#h").val(c.h);

}

        

function showPreview(coords)

{

    var rx = <?php echo $target_w;?> / coords.w;

    var ry = <?php echo $target_h;?> / coords.h;

    

    $("#preview img").css({

        width: Math.round(rx*<?php echo $orig_w;?>)+'px',

        height: Math.round(ry*<?php echo $orig_h;?>)+'px',

        marginLeft:'-'+  Math.round(rx*coords.x)+'px',

        marginTop: '-'+ Math.round(ry*coords.y)+'px'

    });

}



function limiter(textid, limit, infodiv){

    var text = $("#"+textid).val();

    var textlength = text.length;

    

    if (textlength > limit) {

        $("#"+infodiv).html("You cannot write more then "+limit+" characters!");

        $("#"+textid).val(text.substr(0,limit));

        return false;

    } else {

        $("#"+infodiv).html("You have "+(limit - textlength)+" character left !");

        return true;

    }

};



$(document).ready(function(){

    $(function(){$("#fdesc").keyup(function(){limiter("fdesc","150","finfo")})});

});

<?php endif; ?>

[removed]



<style type="text/css">

    #preview

    {

        width: <?php echo $target_w?>px;

        height: <?php echo $target_h?>px;

        overflow:hidden;

    }

</style>

        <div id="containerHolder">

            <div id="container">

                <div id="sidebar">

                    <ul class="sideNav">

                        <li>&lt;?php echo anchor('djawaadmin/feature/list','List') ?&gt;</li>

                        <li>&lt;?php echo anchor('djawaadmin/feature/upload','Upload','class="active"') ?&gt;</li>

                    </ul>

                    &lt;!-- // .sideNav --&gt;

                </div>    

                &lt;!-- // #sidebar --&gt;

                

                &lt;!-- h2 stays for breadcrumbs --&gt;

              

                  

                   <div id="main" style="padding-bottom:10px;">

                    <h3>Upload Picture for Feature</h3>

                    

                        &lt;?php if(isset($status)){echo $status;}?&gt;

                        

                        &lt;?php if(isset($error_notification)){echo $error_notification.'<br /><br />';}?&gt;

                        &lt;?php if(isset($thepicture)){echo '<div class="imageborder">Original Picture <br /><br /><img src="'.$thepicture.'" id="cropbox" alt="cropbox"></div>';} ?&gt;

                        &lt;?php if(isset($thepicture)){echo '<div style="clear:both; margin-bottom:20px;"></div>';} ?&gt;

                        &lt;?php

                            if(isset($thepicture)){

                                echo '

                                <div class="imageborder" align="center">

                                    Image Preview for Feature ( Fixed Size 600 x 400 px ) <br /><br />

                                    <div id="preview"><img src="'.$thepicture.'" alt="thumb"></div>

                                </div><br /><br />';

                            }

                        ?&gt;

                        

                        &lt;?php if(isset($form)){echo $form;} ?&gt;

                </div>

                

                

                &lt;!-- // #main --&gt;

                

                <div class="clear"></div>

            </div>

            &lt;!-- // #container --&gt;

            

        </div>    

        &lt;!-- // #containerHolder --&gt;

and This is for the view.
At Last iwll say...
This library has alot of weaknes , so I want you to give contribution for this library.
Thanks


Messages In This Thread
Jcrop Library Support for codeIgniter ( part IV ) view - by El Forum - 02-16-2010, 02:28 AM



Theme © iAndrew 2016 - Forum software by © MyBB