Tag Archives: Javascript

Drupal 7 – Styling checkbox and radio button in Webform

Yesterday we talked about styling the checkbox and radio button as suggested by Ryan Fait.
Styling checkbox and radio button with CSS and Javascript

Here is a simple solution for applying the checkbox and radio button in Drupal 7 webform.

1. Upload the radio.png, checkbox.png and select.png to your subtheme. (Omega subtheme is used in this example.)

checkbox
radio
select

 
Continue reading Drupal 7 – Styling checkbox and radio button in Webform

Styling checkbox and radio button with CSS and Javascript

I want to style the form elements such as radio button, checkbox or selection list. Google shows me a very good tutorial written by Ryan Fait.
Las Vegas Web Design – Checkboxes, Radio Buttons, Select Lists, Custom HTML Form Elements

In the above tutorial, those form elements will be replaced by a span element. It works great. Only 1 minor problem which is those span elements could not align well. So i made some change on the CSS. Here is my example.
Continue reading Styling checkbox and radio button with CSS and Javascript

Drupal 7 – Add Javascript files on specific paths by template.php

In my previous post, Drupal 7 – Add Javascript files on specific paths by custom module, we try to add .js files for specific paths by creating a custom module. Actually we could implement the same feature by using the theme template.php. Here is an example.
Continue reading Drupal 7 – Add Javascript files on specific paths by template.php

Drupal 7 – Add Javascript files on specific paths by custom module

In the past, i always added js files on theme level. This is not a good approach because the aggregated theme js will be quite large and it is loaded on every pages even js code is not used.

So this time i try to add the js on specific path only when it is needed. This is done by creating a custom module. Let’s name the custom module eureka_js.

1. Inside the eureka_js module folder, we have the following files.

  • js/eureka.js
  • eureka_js.info
  • eureka_js.module

Continue reading Drupal 7 – Add Javascript files on specific paths by custom module

Facebook Javascript SDK – Logout with OAuth 2.0

Now we have OAuth 2.0 working with the Facebook Javascript SDK as mentioned in the last article.
Facebook Javascript SDK – A Simple Login Page with OAuth 2.0

The above example is incomplete as there is no logout link. Replace the fb-login-oauth2.php as follow. Continue reading Facebook Javascript SDK – Logout with OAuth 2.0

Facebook Javascript SDK – A Simple Login Page with OAuth 2.0

A few months ago, i published several posts about Facebook Javascript SDK but they no longer work since Facebook updates to OAuth 2.0. So this post is the updated version of
Facebook Javascript SDK – A Simple Login Page
and it should work works with OAuth2. Continue reading Facebook Javascript SDK – A Simple Login Page with OAuth 2.0

Drupal – Load External Javascript using drupal_add_js() @ 2

Here is another way to add the external .js file.

$external_js = 'http://www.example.com/a.js';
drupal_add_js('document.write(unescape("%3Cscript src=\''. $external_js . '\' type=\'text/javascript\'%3E%3C/script%3E"));', 'inline');

 

Done =)

Previous Post: Drupal – Load External Javascript using drupal_add_js() @ 1

Reference: Web Design by Tim Wooten – Load external js file in Drupal 6

Drupal – Load External Javascript using drupal_add_js() @ 1

If you want to include external .js file in your custom module, create the following file.
external.js

(function ($) {
  Drupal.behaviors.myModule = function(context) {
    var externalScript = $('<script></script>').attr('type','text/javascript').attr('src', 'http://example.org/example.js');
    $('body').append(externalScript);
  }
}(jQuery));

Continue reading Drupal – Load External Javascript using drupal_add_js() @ 1