Huwebes, Pebrero 26, 2015

Scroll bar won't show on touch devices

I have this program using tabs jquery with a css overflow:scroll. It shows in PC but not in touch devices such as IPAD.


And what I just did is to add the css code below:

::-webkit-scrollbar {
    -webkit-appearance: none;
    width: 7px;
}
::-webkit-scrollbar-thumb {
    border-radius: 4px;
    background-color: rgba(0,0,0,.5);
    -webkit-box-shadow: 0 0 1px rgba(255,255,255,.5);
}
And it works.



Hope this helps!


Martes, Pebrero 17, 2015

Draggable for PC and Touch devices

Creating draggables that works on PC and other devices. JQuery UI does not support the use of touch events when using touch devices, drag won't work. Now I found this plug-in to listen on touch events—touchstart, touchmove and touchend. 3 steps is all you need:

  1. Save below as jquery.ui.touch-punch.min.js :
 /*
 * jQuery UI Touch Punch 0.2.2
 *
 * Copyright 2011, Dave Furfero
 * Dual licensed under the MIT or GPL Version 2 licenses.
 *
 * Depends:
 *  jquery.ui.widget.js
 *  jquery.ui.mouse.js
 */
(function(b){b.support.touch="ontouchend" in document;if(!b.support.touch){return;}var c=b.ui.mouse.prototype,e=c._mouseInit,a;function d(g,h){if(g.originalEvent.touches.length>1){return;}g.preventDefault();var i=g.originalEvent.changedTouches[0],f=document.createEvent("MouseEvents");f.initMouseEvent(h,true,true,window,1,i.screenX,i.screenY,i.clientX,i.clientY,false,false,false,false,0,null);g.target.dispatchEvent(f);}c._touchStart=function(g){var f=this;if(a||!f._mouseCapture(g.originalEvent.changedTouches[0])){return;}a=true;f._touchMoved=false;d(g,"mouseover");d(g,"mousemove");d(g,"mousedown");};c._touchMove=function(f){if(!a){return;}this._touchMoved=true;d(f,"mousemove");};c._touchEnd=function(f){if(!a){return;}d(f,"mouseup");d(f,"mouseout");if(!this._touchMoved){d(f,"click");}a=false;};c._mouseInit=function(){var f=this;f.element.bind("touchstart",b.proxy(f,"_touchStart")).bind("touchmove",b.proxy(f,"_touchMove")).bind("touchend",b.proxy(f,"_touchEnd"));e.call(f);};})(jQuery);

 
        2. Include jQuery and jQuery UI on your page then the file we made.
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script> <script src="http://code.jquery.com/ui/1.8.21/jquery-ui.min.js"></script>
<script src="jquery.ui.touch-punch.min.js"></script>

  3. Use jQuery UI and watch it work.
<script>$('#widget').draggable();</script>


Hope it hepls!

Martes, Enero 27, 2015

How to add a simple WYSIWYG editor (Web text editor)

I've been looking for a free editor and this is the simplest I got. Download fckeditor and place it to your site directory. Include the following to your code:

<?php
include("../fckeditor/fckeditor.php");

$oFCKeditor = new FCKeditor('FCKeditor1') ;
$oFCKeditor->BasePath = 'fckeditor/' ;
$oFCKeditor->Value      = $_POST["respond"] ;
$oFCKeditor->Create() ;
?>

Where $_POST["respond"] is your variable. And that's it.


Hope this helps.

How to download your report as Excel

First, is to download PHPExcel Library and place it to your site directory. Open the file and see the examples folder. From there, you can edit the details and set your preferences. See more details below:

Requirements
------------

The following requirements should be met prior to using PHPExcel:
* PHP version 5.2.0 or higher
* PHP extension php_zip enabled *)
* PHP extension php_xml enabled
* PHP extension php_gd2 enabled (if not compiled in)

*) php_zip is only needed by PHPExcel_Reader_Excel2007, PHPExcel_Writer_Excel2007,
   PHPExcel_Reader_OOCalc. In other words, if you need PHPExcel to handle .xlsx or .ods
   files you will need the zip extension, but otherwise not.



Installation instructions
-------------------------

Installation is quite easy: copy the contents of the Classes folder to any location
in your application required.

Example:

If your web root folder is /var/www/ you may want to create a subfolder called
/var/www/Classes/ and copy the files into that folder so you end up with files:

/var/www/Classes/PHPExcel.php
/var/www/Classes/PHPExcel/Calculation.php
/var/www/Classes/PHPExcel/Cell.php
...



Getting started
---------------

A good way to get started is to run some of the tests included in the download.
Copy the "Examples" folder next to your "Classes" folder from above so you end up with:

/var/www/Examples/01simple.php
/var/www/Examples/02types.php
...

Start running the test by pointing your browser to the test scripts:

http://example.com/Examples/01simple.php
http://example.com/Examples/02types.php
...

Note: It may be necessary to modify the include/require statements at the beginning of
each of the test scripts if your "Classes" folder from above is named differently.

Biyernes, Marso 1, 2013

How to control emails when server(cPanel) is limited.

Having problems sending 5000 or more emails?. That had been my problem before and now I got my solution. For example your server can only send 400 emails per hour. My solution, use your database.

Save your email details in the database. Email address, attachments, and message.

Example:

$sql = insert into tosentbox email, message values ('a@a.aaa','sample email');
mysql_query($sql);

Now we create your cron file.

$sql = select * from tosentbox limit 0,30;
$query = mysql_query($sql);

while($row = mysql_fetch_array($query))
{
mail($row['email'],'SUBJECT',$row['message']);


Meaning your only to select the first 30 data from your database. Save as cron.php.

Final step is to set it in your server.
In your cpanel look for the advance tab and click cron job icon. This settings is to read your cron file every 5 minutes.


Add this line in the command textbox:

cd '/home/mintcoll/public_html/' ; php -q 'cron.php' > /dev/null

This is the path where your cron file is located. Then click add new cron job and youre done.

Summary, every 5 minutes the server will read your cron file that selects every 30 emails in your database to send. thus, making it 360 per hour.

Hope that helps!!..

Thanks..