Saturday, 31 December 2011

css for a div round area

#content-w2 { 
    background-attachment: scroll;
    background-clip: border-box;
     background-origin: padding-box;
    background-position: 18px 20px;
    background-repeat: no-repeat;
    background-size: 55px auto;
    border: 2px solid red;
    border-radius: 5px 5px 5px 5px;
    float: left;
    font-weight: bold;
    margin-bottom: 30px;
    overflow: hidden;
    padding: 20px 15px 0 102px;
    width: 559px;
  -moz-border-radius:5px 5px 5px 5px;
  -webkit-border-radius:5px 5px 5px 5px;
  -khtml-border-radius:5px 5px 5px 5px;
}

Friday, 16 December 2011

Jquery print option

<script type="text/javascript" src="jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="jquery.jqprint.js"></script>
<script type="text/javascript">
    function print_it(){
        if($("#including").is(':checked')) // check the box.
        {
            $("#divToPrintAll").jqprint(); // div to be print
        }
        else{
            $("#divToPrint").jqprint(); // div to be print
        }
    }

function removeChar(item)
{
    var val = item.value;
    //alert(val)
      val = val.replace(/[^0-9]/g, ""); 
      if (val == ' '){val = ''};  
      item.value=val;
}
</script>

<input name="including" id="including" type="checkbox" value="ya" /> Print All/ Print
<div id="divToPrintAll">
            <div id="divToPrint">
<input type="" onkeyup="removeChar(this)" >
content
</div>
</div>

Friday, 30 September 2011

Docs Project work using git

Install the git-all and publican-fedora packages with yum:

su -c 'yum install git-all publican-fedora'
 
 
mkdir projects
cd projects
git clone git://git.fedorahosted.org/git/docs/install-guide.git 

Saturday, 27 August 2011

How to add pop-up calendar in backend of Joomla

Step 1: Add to header JHTML::_( 'behavior.calendar' );
 
<?php
defined( '_JEXEC' ) or die( 'Restricted access' ); 
JHTML::_( 'behavior.calendar' );  // <-- this line
?>
 
Step 2: Add your input field and image, with correct ids 
 
<input name="entrydate" id="entrydate" type="text" /> 
<img class="calendar" 
src="/templates/system/images/calendar.png" 
alt="calendar" id="entrydate_img" / >
 
Step 3: Add Mootools javascript code
 
<script  type="text/javascript">
window.addEvent('domready', function() {Calendar.setup({
        inputField     :    "entrydate",     // id of the input field
        ifFormat       :    "%Y-%m-%d",      // format of the input field
        button         :    "entrydate_img",  // trigger for the calendar (button ID)
        align          :    "Bl",           // alignment (defaults to "Bl" = Bottom Left, 
// "Tl" = Top Left, "Br" = Bottom Right, "Bl" = Botton Left)
        singleClick    :    true
    });});
</script> 

Thursday, 14 July 2011

Need to disable the right sidebar

<?php if ($this->countModules('top or right')) { ?>
<div id="rightColumn" class="column">
                  
                     <jdoc:include type="modules" name="top" style="rounded" />

                           
                        <jdoc:include type="modules" name="right" style="rounded" />
               </div>
<?php } ?>

Tuesday, 12 July 2011

Jquery Tab simple example

download latest jquery
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.tabify.js"></script>
<script type="text/javascript">
  $(document).ready(function () {
   $('#tabs').tabify();
  });
 </script>

jquery.tabify.js

(function(a){a.fn.extend({tabify:function(e){function c(b){hash=a(b).find("a").attr("href");return hash=hash.substring(0,hash.length-4)}function f(b){a(b).addClass("active");a(c(b)).show();a(b).siblings("li").each(function(){a(this).removeClass("active");a(c(this)).hide()})}return this.each(function(){function b(){location.hash&&a(d).find("a[href="+location.hash+"]").length>0&&f(a(d).find("a[href="+location.hash+"]").parent())}var d=this,g={ul:a(d)};a(this).find("li a").each(function(){a(this).attr("href", a(this).attr("href")+"-tab")});location.hash&&b();setInterval(b,100);a(this).find("li").each(function(){a(this).hasClass("active")?a(c(this)).show():a(c(this)).hide()});e&&e(g)})}})})(jQuery);


html
 <div id="main">
                    <ul id="tabs" class="tabs">
                    <li  class="active"><a href="#tab1">live! 24</a></li>
                    <li><a href="#tab2" class="second">Kategóriák</a></li>

                   <li><a href="#tab3" class="second">Kategóriák</a></li>
                   </ul>

<div id="tab1">
Tab1
</div>

<div id="tab2">
Tab 2
</div>

<div id="tab3">
Tab 3
</div>
 </div>






 css file

#main .tabs { padding: 0; clear: both; }
#main .tabs li { display: inline; }
#main .tabs li a {background: #BEB9B2;
    border-bottom: medium none;
    border-right: 1px solid #CCCCFF;
    color: #fff;
    float: left;
    font-weight: bold;
    margin-left: 3px;
    padding: 10px;
    position: relative;
    text-align: center;
    text-decoration: none;
    width: 100px;
    font-size:16px;
    height: 14px;
    line-height: 14px;
     }
#main .tabs li.active a {  text-decoration:none;
 background-color:#E60000; width: 100px;
 font-size:16px;
  color: #fff; }

Saturday, 9 July 2011

PHP Image width and height get

<?php

list($width$height$type$attr) = getimagesize("img/flag.jpg");
print $width;
print $height;
print $type ;
print $attr;
echo 
"<img src=\"img/flag.jpg\" $attr alt=\"getimagesize() example\" />";?>



.htaccess and from phpInfo I see that it's now using php5. Great!
AddHandler application/x-httpd-php5 .php 

AddHandler application/x-httpd-php5 .php
AddType application/x-httpd-php5 .php 

Thursday, 7 July 2011

Drupal: customize form label

I always enjoy Drupal Form API with the standard output, easy to use, and easy for extension. But sometime, due to special reason, you only want to display the form input itself, no wrapper div or label. In Drupal 7, it can be as simple as changing a boolean value, but for Drupal 6 it's a big trick. And here is the trick.
The main idea is all form element are run through theme_form_element, and this theme function adds label and wrapper to form output, so all we have to do is override this theme function to create an exception. Open your template.php in your theme and add the following code:

function themename_form_element($element, $value) {
  // This is also used in the installer, pre-database setup.
  $t = get_t();
 
  if (empty($element['#no_wrapper'])) {
      $output = '<div class="form-item"';
      if (!empty($element['#id'])) {
        $output .= ' id="'. $element['#id'] .'-wrapper"';
      }
      $output .= ">\n";
      $required = !empty($element['#required']) ? '<span class="form-required" title="'.  
$t('This field is required.') .'">*</span>' : '';
 
      if (!empty($element['#title'])) {
        $title = $element['#title'];
        if (!empty($element['#id'])) {
          $output .= ' <label for="'. $element['#id'] .'">'.  
$t('!title: !required', array('!title' => filter_xss_admin($title), '!required' => $required))  
."</label>\n";
        }
        else {
          $output .= ' <label>'. $t('!title: !required', array('!title' => filter_xss_admin($title), 
'!required' => $required)) ."</label>\n";
        }
      }
 
      $output .= " $value\n";
 
      if (!empty($element['#description'])) {
        $output .= ' <div class="description">'. $element['#description'] ."</div>\n";
      }
 
      $output .= "</div>\n";
  }
  else {
    return $value;
  }
 
  return $output;
}
 
function _render_element(&$element) {
    $element['#no_wrapper'] = true;
    $result = drupal_render($element);
 
    return $result;
}

Thursday, 30 June 2011

Fedo 14 help for package install etc

# SuPHP configuration for PHP5 
 
AddType application/x-httpd-php5 .php5 .php .html 
 
# End of autogenerated PHP configuration. 
 
To configure php,mysql,apache
 
yum install httpd
yum install ruby
yum install php php-pear
yum install php-mysql

All configuration for Apache is contained in the httpd.conf file,
which is located at /etc/httpd/conf.d/httpd.conf. We advise you
to make a backup of this file into your home directory by issuing the following commands:

cp /etc/httpd/conf/httpd.conf ~/httpd.conf.backup

How-To install Skype on Fedora Linux 14 x86_64

  • Install dependencies by running:
    yum install -y qt-x11.i686 libXScrnSaver.i686 alsa-plugins-pulseaudio.i686 libXv.i686
  • Install Skype by running:
    yum install --nogpgcheck -y skype-2.1.0.81-fc10.i586.rpm

    or download skype version and then

    beesu gedit /etc/yum.repos.d/skype.repo

    [skype]
    name=Skype Repository
    baseurl=http://download.skype.com/linux/repos/fedora/updates/i586
    enable=1
    gpgcheck=0
    gpgkey=http://www.skype.com/products/skype/linux/rpm-public-key.asc
    skype_fedora_1

    uninstall skype

    rm /usr/bin/skype
    rm /usr/share/applications/skype.desktop
    rm /usr/share/pixmaps/skype.png
    rm -rf /opt/skype-1.2.0.18



    Alternatively you can install the Skype repository. Open a terminal and type:

    su -c 'gedit /etc/yum.repos.d/skype.repo'
    In that file copy the following lines:

    [skype]
    name=Skype Repository
    baseurl=http://download.skype.com/linux/repos/fedora/updates/i586/
    enabled=1
    gpgkey=http://www.skype.com/products/skype/linux/rpm-public-key.asc
    gpgcheck=0

    Now you can easily install/update skype by typing:

    su -c 'yum install skype'
    su -c 'yum update skype'


    VLC install
    su -
    rpm -ivh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm
    yum install vlc
     
To add the google repository edit the file.
gedit /etc/yum.repos.d/google.repo
for 32 bit OS Version
[google]
name=Google - i386ff
baseurl=http://dl.google.com/linux/rpm/stable/i386
enabled=1
gpgcheck=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub
for 64-bit OS Version
[google64]
name=Google - x86_64
baseurl=http://dl.google.com/linux/rpm/stable/x86_64
enabled=1
gpgcheck=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub

Install Google Chrome Stable Version on Fedora 14

Just type this line on the root terminal
yum install google-chrome-stable
 
Mysqli configuration in fedora 14
 
su - 
~: yum install php-mysqli
~: service mysqld start
To update mysql root password 
~: mysql -u root -p
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD('new-password') WHERE user='root';
mysql> FLUSH PRIVILEGES;

> mysql -u root -p
Enter password:
mysql> create database demo;
mysql> GRANT ALL PRIVILEGES ON mytest.* TO 'guest'@'localhost' IDENTIFIED BY 'guest' WITH GRANT OPTION;
 

Flash player in Fedora

http://fedoraproject.org/wiki/Flash

the --disablerepo option.

su -c 'yum install nspluginwrapper.{x86_64,i686} alsa-plugins-pulseaudio.i686 --disablerepo=adobe-linux-i386'
su -c 'yum install flash-plugin'
You may see messages indicating that some of these packages are already installed. This is not a problem. (In particular, a default graphical install of 64-bit Fedora already includes nspluginwrapper.x86_64.)
To 'wrap' the plugin, run the following command:
su -c 'mozilla-plugin-config -i' In /usr/lib64/mozilla/plugins-wrapped, you should see a wrapped version of the flash plugin.

Installing the plugin on Chrome

Follow all of the instructions above. Then:
- create a Chrome plugin folder:
su -c 'mkdir /opt/google/chrome/plugins'
- on 32-bit, create a symbolic link that tells Chrome how to find the 32-bit plugin:
su -c 'ln -s /usr/lib/mozilla/plugins/libflashplayer.so /opt/google/chrome/plugins/libflashplayer.so'
- on 64-bit, create a symbolic link that tells Chrome how to find the 64-bit plugin:
- run Mozilla Firefox once so that it creates /usr/lib64/mozilla/plugins-wrapped/nswrapper_32_64.libflashplayer.so
su -c 'ln -s /usr/lib64/mozilla/plugins-wrapped/nswrapper_32_64.libflashplayer.so /opt/google/chrome/plugins/nswrapper_32_64.libflashplayer.so'

GIT
yum install git


More help: http://fclose.com/b/linux/366/set-up-git-server-through-ssh-connection/

su - # login as root
# install prerequisities
yum install mysql mysql-server php-mysql apache php-xml php-domxml-php4-php5 git
cd /var/www/html # the web server document directory
git clone git://gitorious.org/statusnet/mainline.git statusnet.testing # this takes a while
git checkout testing # checkout the testing branch
find -type d -name .git -exec  rm -rf {} \; # delete git junk (unless you want to update later)
find -type f -name .gitignore -exec  rm -f {} \;
chmod g+w . avatar background file # allow apache to make changes
chown apache . avatar background file
cp htaccess.sample  .htaccess #
vim .htaccess  # change line 10 to /statusnet/
mysqladmin -u (username) -p  create statusnet
mysql -u (username) -p
# Type your mysql root password (different than your Linux
# root password) to enter MySQL database client.
# Then in MySQL, type the following GRANT command:
#GRANT ALL on statusnet.* TO 'statusnetuser'@'localhost' IDENTIFIED BY 'statusnetpassword';
# Press CTRL-D to quit MySQL.
cd ..
ln -s statusnet.testing statusnet # I like a symlink to keep track of versions
vim /etc/httpd/conf/httpd.conf # at the end add the following three lines
#<Directory "/var/www/html/statusnet">
#AllowOverride All
#</Directory>
service httpd restart # restart Apache web serve
# Launch install in web browser.
# Do not install with localhost in URL if you want remote users to access it.
xdg-open http://public-server-name/statusnet/install.php
Installing Ruby has always been rather controversial. There are very few operating systems today that have a clean install and does not ass kick the system’s package manager. Ever since the introduction of RVM Ruby installs on Linux systems got so much easier. Today I reconfigured my workstation at home with Fedora 14, AwesomeWM and Dropbox (for config sharing across all workstations — sweet). RVM is a nice tool, but it shouldn’t be nescecary. Its nothing more than a crude hack to run multiple untested, possibly unstable Ruby versions. It saved lives during the switch to 1.9 and 1.9.2, but its not a long term solution for stable linux systems. But right now we need Ruby 1.9.2, so we will use RVM to fix that up.
On my mobile workstation I run archlinux, because battery matters, on which installing Ruby and Rails is rather painless.

$ pacman -S ruby
$ gem install rails

Done, easy, cheap shot and works like a charm and no need for RVM. Now, on to Fedora!
First we’ll install all packages RVM depends on:

$ yum install git ruby curl bison patch make

And install RVM for the current user only using RVM’s directive:

$ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )

Done! Make sure you add the [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" line to the end of your .bashrc. The skeleton /etc/bashrc does not contain any return statements, so no need to fix that. Then do a source ~/.bashrc to make sure your path is updated.
Lets install some dependencies:

# As stated by RVM
$ yum install gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel iconv-devel

# And the rest most Rails apps will eventuall need
$ yum install libxslt-devel sqlite-devel openssh openssl-devel

Easy enough, lets get, compile, install and use Ruby:

$ rvm install 1.9.2
$ rvm use 1.9.2 --default

Lets install rails!

$ gem install rails

Nice! Now you can install other gems, use rake or do ruby stuff as normal :-) Note that if you ever need to rebuild Ruby for it to have proper bindings add the --force parameter to RVM, else it will not be recompiled, even though it says so.

Force Caching With .htaccess Method To Increase Loading Speed Of Your Site


01. Search for a file named .htaccess(hypertext access) in the webroot of your server (FTP) and can be easily edited using any text editor (like Notepad). Open it and add below code in it:

FileETag MTime Size
ExpiresActive on
ExpiresDefault “access plus 86400 seconds”



  


Tuesday, 24 May 2011

PHP - Unzip an uploaded file using php

$zip = new ZipArchive;
     $res = $zip->open(’my_zip_file.zip’);
     if ($res === TRUE) {
         $zip->extractTo(’my_extract_to_dir/’);
         $zip->close();
         echo ‘ok’;
     } else {
         echo ‘failed’;
     }

Views3 view slideshow fixing

Well... I got it to work using the following:

<?phpfunction phptemplate_views_slideshow_thumbnailhover_no_display_section($view, $rows, $id, $options, $teaser = TRUE) {
 
// Add the slideshow elements.
 
$attributes['id'] = "views_slideshow_thumbnailhover_teaser_section_$id";
 
$attributes['class'] = 'views_slideshow_thumbnailhover_teaser_section views_slideshow_teaser_section';
 
$attributes = drupal_attributes($attributes);

 
$output = "<div$attributes>";
  foreach (
$view->result as $count => $node) {
    if (
$view->display_handler->uses_fields()) {
     
$rendered = '';
      foreach (
$options['views_slideshow_thumbnailhover']['main_fields'] as $field => $use) {
        if (
is_object($view->field[$field])) {
         
$rendered_field = $view->field[$field]->theme($node);
         
         
// If the field is excluded then don't display it.
          // It must be rendered first though so that Custom Text can use it.
         
if (!$view->field[$field]->options['exclude']) {
            if ((
$use !== 0) && !empty($rendered_field)) {
             
$rendered .= '<div class="views-field-'. views_css_safe($view->field[$field]->field) .'">';
              if (
$view->field[$field]->label()) {
               
$rendered .= '<label class="view-label-'. views_css_safe($view->field[$field]->field) . '">';
               
$rendered .= $view->field[$field]->label() . ':';
               
$rendered .= '</label>';
              }
             
$rendered .= '<div class="views-content-'. views_css_safe($view->field[$field]->field) .'">';
             
// !custom $rendered .=  $rendered_field;
             
if ($use == 'nid' && is_numeric($rendered_field)) {
               
$rendered .= node_view(node_load($rendered_field),true);
              } else {
               
$rendered .= $rendered_field;
              }
             
// end custom
             
$rendered .= '</div>';
             
$rendered .= '</div>';
            }
          }
        }
      }
    }
    else {
     
$rendered = node_view(node_load($node->nid), $teaser, FALSE, FALSE);
    }
   
$output .= theme('views_slideshow_thumbnailhover_no_display_teaser', $rendered, $id, $count);
  }
 
$output .= "</div>";
  return
$output;
}
?>
But it does seem a bit roundabout just to get the tpl-overridden teaser to display correctly.
Just to summarize what I did for reference:
* Create a view (Views Slideshow)
* Add set it to Thumbnail Hover
* Add two fields - Node:Nid and whatever other you want to use for breakouts
* Slideshow settings: set Node:Nid as the main frame and the other field as breakouts
* Override your node teaser display using node.tpl.php
* Use the above function to convert Node:Nid field into an overridden teaser display
Now the teaser shows up as it's overridden by node.tpl.php

and so on

Prerequisite

- 1 content type dedicated to this slideshow that I called Customer.
- This content type has 1 cck image field to store the ad.
- Mandatory Assigment of customer nodes to an Industry taxonomy
- Imagecache preset to display my node images with fixed dimensions
This tutorial is based on a page view using slideshow as style for the left side of the page, and an attachment view renders the right side of the screen (this is not a block, just a floated div).

View setup

Let's first build the view without the attachment which is only used to filter by industry
create a new view and under

Default basic settings

under Style choose slideshow:
mode ThumbnailHover
List type: ordered list
no grouping
Hover breakout: full node
Timer delay:5000
Initial fade delay:-2000
speed:400
Pause: yes when hovering the node
Pager event:hover
control:none
image counter:none
effect:fade
Row style: fields (will only apply to our node title in our case)
Items to display: unlimited
pager:none
ajax:yes
Header and page path: whatever

Fields and sorting

node:title (no option, just remove label)
node:title ascending

Filters

the usual filters: node published, node type Customer
=> you should now have a working view.

Layout the page

2 more things to do:

Layout the thumbnail

this is not done with the view templates but with the customer node template (because the thumbnailHover slideshow will show you the node just like you would see it from a direct link. I basically defined a template that displays the image with fixed dimensions (thanks to imagecache) above a background image for the frame.

adjust the CSS for the view to display the node list nicely

Main CSS characteristics: 3 main divs to layout (#views_slideshow_thumbnailhover_main_1 on the left, #views_slideshow_thumbnailhover_breakout_teasers_1 in the middle, div.attachment on the right)
- give a %width for each of them, float left the first 2 and right the attachment
- change the cursor to pointer for the middle div so that visitors understand they can mouse over the node titles to show a different ad

part2: add an ATTACHMENT VIEW for the Industries

change the PAGE display to add a view argument

-add new argument for field: taxonomy term
-Action to take if argument is not present: Provide default argument
-default argument type: fixed entry, default value: Apparel & Accessories (my first Industry term)
-Optional: Under validator, add the following pHP code:
$pattern = "/%26/";
   $handler -> argument = preg_replace($pattern,"&", $argument);
   return true;

==> This is to handle the special character & in the taxonomy terms - if you don't do that, then the link on taxonomy term such as Media & Movies doesn't work
-Action to take if argument doesn't validate: display empty text (just in case..)

add a new ATTACHMENT display

-Fields, filter and sort: no change
-Attachment settings:
-inherit argument:YES (inherit its arguments from the parent display ie the PAGE view)
-Inherit exposed filter:NO (we don't have exposed filter)
-position:after
-Attach to:page
-ARGUMENTS:OVERRIDE taxonomy:term settings
and here is the trick:
-Under action to take if argument is not present,choose: summary, sort ascending
-under validator option, choose PHP with the following code: return FALSE;
-Action to take if argument doesn't validate: summary, sort ascending
-under style, choose LIST
==> when there is no argument, we still want to display all industries and count them (there is no argument when the page is first displayed)
==> also, even if there is an argument (the user clicked on an Industry) we still want the list of Industry to stay as is so we force the argument to not validate using return code FALSE) - the view will still refresh the left side of the screen (the PAGE view) thanks to the argument settings defined at the PAGE level

Wednesday, 18 May 2011

Simple date differene

<?php
$start
= new DateTime('08-06-1995'); // DD-MM-YYYY
$end = new DateTime('22-11-1968');

if (
$start < $end) {
    echo
"Correct order";
} else {
    echo
"Incorrect order, end date is before the starting date";
}
?>

Monday, 18 April 2011

Some Jquery Tips

jQuery substring

jQuery('#textArea').keypress(function() {
 var text = jQuery('#textArea').val();
 if(text.length > 400) {
  text = text.substring(0, 400);
  jQuery('#textArea').val(text);
 }
});
 

jQuery refresh page

jQuery('#refresh-link').click(function() {
        location.reload();
});

jQuery message box

Many times there is a need for showing message to a user. If you would like to show your user modal window message, try following – jQuery message box.
Before we start – you can take a look at the demo message – made just for you! Click here…
In order to show jQuery message box – we first need to setup a CSS for both message and background. Copy following CSS into your CSS file in order to set style.
#darkbg { display: none;
 position: absolute;
 top: 0;
 left: 0;
 width: 100%;
 height: 100%;
 background: #000; 
 opacity: .5;
 filter: alpha(opacity=50);
 -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
}
#message_box { width: 300px;
 height: 150px;
 background: #fff; 
 border: 4px solid #f0f0f0; border-radius: 10px;
 -moz-border-radius: 10px;
 -webkit-border-radius: 10px;
 
 position: absolute;
 top: 100px;
 left: 50%;
 margin-left: -150px;
 
 text-align: center;
 z-index: 1000;
 display: none;
}
#message_box input[type=button] { float: right;
 margin-right: 10px;
}
 Now that we have CSS setup, it is time to write some JavaScript code. This JavaScript code is heart and soul of this jQuery message box. So, copy next lines into your .js file.
var message_box = function() {
 var button = '<input type="button" onclick="message_box.close_message();" value="Okay!" />';
 return {
  show_message: function(title, body) {
   if(jQuery('#message_box').html() === null) {
    var message = '<div id="message_box"><h1>' + title + '</h1>' + body + '<br/>' + button + '</div>';
    jQuery(document.body).append( message );
    jQuery(document.body).append( '<div id="darkbg"></div>' );
    jQuery('#darkbg').show();
    jQuery('#darkbg').css('height', jQuery('html, body').height());
 
    jQuery('#message_box').css('top', jQuery('html, body').scrollTop() + 150);
    jQuery('#message_box').show('slow');
   } else {
    var message = '<h1>' + title + '</h1>' + body + '<br/>' + button;
    jQuery('#darkbg').show();
    jQuery('#darkbg').css('height', jQuery('html, body').height());
 
    jQuery('#message_box').css('top', jQuery('html, body').scrollTop() + 150);
    jQuery('#message_box').show('slow');
    jQuery('#message_box').html( message );
   }
  },
  close_message: function() {
   jQuery('#message_box').hide('fast');
   jQuery('#darkbg').hide();
  }
 }
}();
 Now, we are almost done, we just need to be able to init message showing
 from our jQuery message box. This can be done in simple JavaScript 
function call:
message_box.show_message('Hi!', 'Whatup?!');
 
You can bind it to onclick event as well:
jQuery('#some_link').onclick(function() {
    message_box.show_message('Hi!', 'Whatup?!');
});

 

jQuery visible

Use jQuery visible selector to check if element is visible, and make a menu. To use jQuery visible selector and check if element is visible, just use following snippet.
1
2
3
4
5
if(jQuery('#your-jquery-visible-id').is(':visible')) {
 alert('jQuery says: "It is visible!"');
} else {
 alert('jQuery says: "It is not visible."');
}
Now that we know how to use jQuery to check if element is visible – we can build simple menu. The first part would be HTML.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<ul id="nav-jquery-visible">
 <li>
  <a href="javascript:void(0);" onclick="toggleSubmenu(this)">Music</a>
  <ul>
   <li><a href="http://shufflable.com/en/play/music/rock">Rock</a></li>
   <li><a href="http://shufflable.com/en/play/music/pop">Pop</a></li>
   <li><a href="http://shufflable.com/en/play/music/hard+rock">Hard rock</a></li>
   <li><a href="http://shufflable.com/en/play/music/blues">Blues</a></li>
   <li><a href="http://shufflable.com/en/play/music/metal">Heavy metal</a></li>
  </ul>
 </li>
 <li>
  <a href="javascript:void(0);" onclick="toggleSubmenu(this)">Programming</a>
  <ul>
   <li>PHP</li>
   <li>JavaScript</li>
   <li>Ruby</li>
   <li>C</li>
   <li>Java</li>
  </ul>
 </li>
</ul>
Than we make sure in CSS that submenu is not visible.
#nav-jquery-visible ul {
 display: none;
}
Finaly, we make JavaScript to put jQuery visible in use.
1
2
3
4
5
6
7
8
9
function toggleSubmenu(element) {
 var child = jQuery(element).parent().filter(':first').children('ul');
 
 if(jQuery(child[0]).is(':visible')) {
  jQuery(child[0]).slideUp();
 } else {
  jQuery(child[0]).slideDown();
 }
}
 

Get current page URL and title with jQuery

<p>Current page URL: <span id="this_url">www.example.com</span>.</p>
<p>Current page title: <span id="this_title">mytitle</span>.</p>
 
<script type="text/javascript">
jQuery(document).ready(function () {
 var href = jQuery(location).attr('href');
 var url = jQuery(this).attr('title');
 jQuery('#this_title').html('<strong>' + href + '</strong>');
 jQuery('#this_url').html('<strong>' + url + '</strong>');
});
</script>

Toggle div using jQuery

<p>Click on the link to see how to use <a href="javascript:void(0);" id="how-to">toggle in jQuery</a>?</p>
 
<div style="display: none;" id="toggle-div">
You should not write inline style, but I used it to make example of using slide toggle with jQuery shorter.
</div>
 
<script>
jQuery("#how-to").click(function () {
 jQuery("#toggle-div").slideToggle("slow");
});
</script>

JavaScript translate

var javaScriptTranslate = function() {
    var translations = {};
 
    return {
        translate: function(text) {
            if(typeof translations[text] === 'undefined') {
                return text;
            } else {
                return translations[text];
            }
        },
        init: function(translationArray) {
            translations = translationArray;
        }
    };
}();

javaScriptTranslate.init(<?php echo json_encode($translation); ?>);
alert(javaScriptTranslate.translate('Hello dear friend - I am JavaScript translate class'));




 


 

 

Source base installation of php, mysql and apache in ubuntu/ linux

Compile and Install a LAMP(Linux/Apache/MySQL/PHP) Server from Source In the last post, I described the method to install a LAMP ser...