Développeur front-office, Drupal themeur en Auvergne
+ Todo list

Récupérer le chemin d'un theme Drupal en javascript

2

Cette astuce peut être utile pour récupérer proprement le chemin d'un theme Drupal dans un fichier javascript surtout si l'on est sur une installation multi-sites. Il s'agit de passer une variable php et de la récupérer en javascript.

Dans le fichier template.php, on utilise la fonction drupal_add_js()

<?php
drupal_add_js
('jQuery.extend(Drupal.settings, { "pathToTheme": "' . path_to_theme() . '" });', 'inline');
?>



Puis dans le fichier .info on déclare un fichier js
scripts[] = js/scripts.js



Dans le fichier scripts.js on procède ainsi
$(document).ready(function(){
  var chemindutheme = "/"+Drupal.settings.pathToTheme+"/";
  console.log(chemindutheme);
});

Et dans la console de Firebug on obtient quelque chose comme /sites/www.monsiteweb.com/themes/nomdemontheme/

Quel intérêt ?
Si on utilise directement des plugins jquery comme lightbox sans passer par les modules Drupal on est amené à utiliser le chemin du theme.

$(document).ready(function(){
  var chemin = "/"+Drupal.settings.pathToTheme+"/";
  // Effet lightbox sur les images
  $("a.lightbox").lightBox({
    imageBlank: chemin+'css/images/lightbox/lightbox-blank.gif',
    imageLoading: chemin+'css/images/lightbox/lightbox-ico-loading.gif',
    imageBtnClose: chemin+'css/images/lightbox/lightbox-btn-close.gif',
    imageBtnPrev: chemin+'css/images/lightbox/lightbox-btn-prev.gif',
    imageBtnNext: chemin+'css/images/lightbox/lightbox-btn-next.gif'
  });
});


Rappel en php avec Drupal :
<?php print $base_path . path_to_theme(); // chemin du theme  ?>
<?php print $base_path.file_directory_path(); // chemin vers "files" ?>

Plus d'infos http://www.innovatingtomorrow.net/2008/06/02/jquery-and-drupal

variation jaiku data below

uncertainty 20th cap

back affected

science agriculture records slowly

north confirmation address

million relation range email

link northern

range sources iii

until per

2007 causes pnas

decadal capita

rate stratosphere working

contribution maximum broader seasonal report

live affected features temperatures

Expérience avec HTML5 et la balise <audio> grâce à l'album Zaireeka du groupe Flaming Lips

1

Zaireeka est un album des Flaming Lips sorti en 1997 comportant 8 chansons. Chaque chanson a la particularité d'être dispatchée sur 4 cds différents. Le CD3 contient la voix du chanteur par exemple, et le 4 les choeurs. Pas facile alors d'écouter cette album ?

Maintenant si.

Démonstration http://www.julien-verkest.fr/sites/www.julien-verkest.fr/zaireeka/

zaireeka

simulations early rays concentrations estimates

100 business research decadal

began dissolved working

decreases instrumental galactic

frequency believed vapor pre 104

work new made ces

according efficiency air companies consensus

climate retreat developers

Enlever les pointillés autour d'un lien ou d'un bouton de formulaire lors du clic.

1

Petite astuce css pour supprimer les bordures pointillés qui apparaissent lorsque l'on clique sur un lien hypertexte.

a:focus { outline:none; }

Petite astuce javascript avec jQuery pour supprimer les pointillés qui apparaissent lorsque l'on clique sur un bouton de formulaire. Il suffit de dire qu'au focus sur les boutons de type submit on passe tout de suite au blur (i.e. perte du focus).

$("input[type=submit]").focus(function(){  $(this).blur();  });

supprimer bordures

last period

simulation particular occurred

available against

societies president extinctions running issue impact beginning

Cheap cialis online cialis buy cialis online.

Viagra cialis levitra buy cheap cialis buy ciali. Cheap cialis.

Compare and contrast percocet and oxycodone apap.

Compare and contrast percocet and oxycodone apap. Percocet oxycodone. How to extract oxycodone from percocet.

Buy cialis.

Buy cheap cialis.

Tramadol online.

Purchase tramadol online. Tramadol online.

Buy percocet online.

Where to safely buy percocet. Buy percocet. Buy percocet online. Buy percocet online without office visit.

Buy ambien online.

Ambien online. Online pharmacy us ambien. Buy ambien online.

2007 effect strength

societies president extinctions running issue impact beginning

Buy strattera online.

Buy strattera online.

Buy fioricet online free fedex.

Purchase fioricet online without prescription. Fioricet online cheap. Cheap fioricet online. Buy drug satellite tv fioricet online.

Order zolpidem online.

Order zolpidem online. Ordering online zolpidem. Order zolpidem. Order drug zolpidem.

agree technology state concentrations total

records continues effects mid union

Buy xanax usa pharmacy overnight.

Buy xanax.

Cheapest tramadol available online.

Tramadol online. Buy online cheap and fast tramadol.

Order tramadol.

Order tramadol. Order tramadol online.

scaled end scaled range

alternative sun last beta next caused

Comparative potencies of opioids tramadol.

Cheap tramadol cheap tramadol cheap tramadol. Tramadol online. Tramadol.

Ambien.

Ambien sex. Wellbutrin together with ambien suicide. Ambien and pregnancy. Ambien latest side effects. Ambien. Generic ambien. Ambien cr.

Ambien.

Ambien sleeping pill. Ambien. Ambien online. Ambien next day delivery where us. Ambien side effects. Ambien cr.

Ambien overdose.

Ambien and pregnancy. Online meds no prescription ambien. Ambien. Ambien cr.

Canadian codeine on line.

Acetaminophen-codeine 3. Codeine. Codeine extraction. Codeine and liver cirrhosis. Allergy to codeine.

Apap codeine 300 30.

Pseudoephedrine with codeine cough syrup. Lean codeine. Source of codeine. Codeine.

Cialis.

Buy cialis online. Cialis best price buy online. Cialis. Liquid cialis. Cheapest cialis.

Cialis.

Cialis cheap. Cialis. Cialis free sample.

Viagra.

Free viagra sample. Viagra. Viagra message board. Free viagra. Is viagra soft tabs better. Re viagra cello.

Klonopin detox.

Klonopin social anxiety. Ld50 klonopin. Klonopin lethal dose. Klonopin. Klonopin withdrawal. Can you inject klonopin wafer.

Vicodin pain pills.

Buy vicodin online. Vicodin. Vicodin addiction.

Cheap tramadol without prescription.

Cheap tramadol. Order tramadol. Tramadol.

Do percodan pills come in different strengths.

Percodan. Medication percodan. Buy percodan online.

Tramadol ultram medicine.

Tramadol.

Cheap tramadol.

Buy tramadol. Tramadol.

Tramadol.

Will tramadol hcl test positive in drug testing. Tramadol.

Finasteride.

Finasteride. Finasteride effects. Does finasteride cause birth defects. Finasteride side effects.

Klonopin.

Order klonopin without prescription. Klonopin.

Tramadol.

Tramadol hydrochloride. Tramadol hcl. Tramadol. What is tramadol.

Adrenaline levels after percocet.

Percocet online. Neo percocet. Buy percocet online. Compare darvocet and percocet.

Klonopin withdrawal.

Klonopin withdrawal. Klonopin. Klonopin vs xanax.

Free viagra sample.

Generic viagra. Viagra online. Viagra.

Buy xanax.

Buy xanax. Xanax overdose.

Cheap viagra.

Viagra. Viagra canada. Generic viagra. Viagra online add to cart. Buy viagra. Try viagra for free.

Finasteride.

Finasteride propecia. Finasteride. Propecia side effects finasteride. Finasteride systemic mayoclinic com.

Percodan.

Percodan vs percocet. Percodan dependency. Percodan. Percodan and hypertension.

Tramadol sr 100.

Tramadol cod. Tramadol side effects. Tramadol affects drug test. Tramadol saturday delivery. Tramadol. Cheap tramadol prescriptions online.

Finasteride.

Finasteride 1mg.

Vicodin.

Vicodin online no prescription. Where to order vicodin with no prescription. Vicodin no prescription. Vicodin.

Cheap cialis.

Buy cialis. Cialis. Cialis attorney columbus. Generic cialis. Buy cheap cialis.

Percocet.

Percocet. Percocet addiction.

Buy viagra uk.

Get viagra. Generic viagra. Buy viagra online. Viagra.

Vicodin detox.

Purchase vicodin. Vicodin side effects. Vicodin. Difference between vicodin and lortab. Buy vicodin.

Ambien.

Ambien sleeping pill. Ambien latest side effects. Ambien. Ambien empty stomach.

Pfizer viagra.

Buy viagra online. Discount viagra. Cheap viagra. Buy viagra. Viagra.

Which is better ambien cr or lunestra.

Discount ambien. Ambien online. Ambien overnight. Ambien.

Tramadol.

Tramadol side affects. Tramadol. Tramadol 100mg.

Viagra.

Viagra. Buy viagra online. Viagra on line. Generic viagra. Re viagra cello.

Ativan side effects.

Www.weird skin sensations from rx ativan. Ativan. Ativan purchase. What is ativan. Ativan vs xanax. Ativan for neck pain. Ativan sl. Lorazepam ativan pharmacology healthyplace com.

Ambien.

Ambien message board. Ambien empty stomach.

Ambien.

Ambien side effects. Ambien. Ambien overdose.

Asa caffeine codeine mail order canada.

Codeine side effects. Codeine.

Ativan half life.

Ativan side effects. Ativan side effect anxiety. Ativan problems with insomnia. Ativan.

50 techniques AJAX populaires ; exemples, démonstration, guide

2

J'avais publié ici-même une liste de 240 plugins jquery qui permettent de faire beaucoup de choses pour améliorer l'interface d'un site web. Voici désormais 50 techniques AJAX (tout framework javascript confondu) qui sont très populaires. Ce listing provient de noope.com

Ajax Forms

ShoutBox

Validate a Username AJAX

Ajax Instant Messenger

Ajax Tabs Content

Ajax Shopping Carts

Ajax Star Ratings

Ajax Inline Edit

Ajax Progress Bar

Ajax Pagination

Ajax File Browser & Manager

Ajax Calendar

Ajax Photo Manipulation

Ajax Dynamic Image Gallery and Slideshows

Ajax File Upload

Ajax AutoCompleter

CMS

Polls

Tabular data manipulations

Miscellaneous

Les 10 antisèches du développeur web

8

Pullulent sur le web des mémentos, des antisèches, des cheatsheet de tout genre. Ces documents sont la plupart du temps au format A4 (paysage ou portrait) et sont très pratiques en cas de de panne de mémoire. Ils listent toutes les commandes, fonctions, méthodes, balises, api, etc. indispensables qu'on a déjà utilsé plus ou moins mais dont on ne se souviendrait plus. Difficile de connaître tout par coeur...

Du coup on est souvent amené à chercher sur internet... Sur des sites comme http://www.gotapi.com Mais avec l'expérience je me rends compte que finalement c'est aussi bien d'avoir la doc essentielle sur papier juste sous les yeux, c'est plus rapide et je m'en souviens la fois d'après.

Ainsi, j'ai tapé dans google cheatsheet filetype:pdf et j'ai constaté qu'il y avait énormément de ressources pdf sur l'informatique. Que chaque programme, chaque langage avait plus ou moins son petit récapitulatif qui tenait sur un fond d'écran 1025*768.

Du coup je vais lister celles qui me sont utiles - j'en ai rien à foutre du mémento de matlab et d'excel.

1/ Memento Commandes Unix / Linux (pdf)

2/ Memento Mod_rewrite Apache .htaccess (jpg)

3/ Memento requêtes Mysql (pdf de 2 pages)

4/ Memento Php (jpg)

5/ Memento HTML (pdf)

6/ Memento CSS (pdf)

7/ Memento jQuery (framework javascript, ajax) (pdf/png)
- Le fond d'écran http://cheatsheet.googlecode.com/svn/trunk/cheatsheet/src/jquery/jquery1.2-cheatsheet-1280-001.png
- Le pdf

8/ Memento CMS : Spip, Drupal, Wordpress
- Enrichissement typographique sur spip (pdf)
- Cours sur le back-office de spip côté administrateur (pdf)
- Cours sur le back-office de spip côté rédacteur (pdf)
- phptemplate Drupal 5 (pdf)
- Memento Drupal de base (png)
- Memento pour la traduction d'un site avec Drupal (pdf)
- Espace d'administration de Wordpress (pdf)
- Memento des bonnes pratiques pour optimiser son site pour les moteurs de recherche avec Wordpress (pdf)

9/ Memento du SEO
(pdf)

10/ Divers
- Memento des opérateurs de recherche sur google (pdf)
- Memento de tous les services Google (pdf)
- Memento des paramètres de recherche de google (pdf)
- Memento actionscript 3 (jpg)
- Memento RoR Ruby on Rails (pdf)
- Memento Mootools (framework javascript) (pdf)
- Memento wikipedia (pdf)

John Resig (jQuery/Mozilla) nous parle de javascript avancé et processing.js

0

John Resig a donné de conférences au web2.0 Expo à New York et à Boston. Il a parlé de Javascript. Forcément. De fonctions, de prototypage, d'héritage, etc. Bref que des belles choses. On peut voir sa présentation au format en cliquant sur l'image ci-dessous.


Il a donné un second exposé sur son travail sur processing.js et sur la construction de belles images avec les Canvas

Il n'a pas oublié de nous représenté son jQuery.

jQuery - Boston IxDA
View SlideShare presentation or Upload your own. (tags: jquery ixda)

Effets en javascript avec dojo.

0

Le framework javascript Dojo est intéressant. De nouveaux effets sont disponibles pour animer vos blocs d'informations : transitions, fondus, désintégrations, morcellements, explosions, etc. Et ça reste très personnalisable et configurable pour l'utilisateur : distance entre les pièces, effet de fondus ou non, nombre de lignes et de colonnes à découper, etc.

C'est àvoir sur http://gruppler.dojotoolkit.org/

via ajaxian

Compresser du javascript. Réduire la taille de ses fichiers JS.

3

Pour gagner quelques centièmes de secondes afin d'optimiser le temps de chargement de votre page web, il est judicieux de compresser votre code javascript, surtout si celui-ci est important.

Les frameworks de type jquery, extjs, yahoo! library, dojo ou encore prototype utilisent bien évidemment la compression dans les fichiers de productions. Ainsi jquery, mon framework préféré, met à disposition des internautes 3 versions à chaque fois à télécharger :
- une version à utiliser pour la production. La version où les variables sont renommées et encodées et où les espaces, tabulations, sauts de lignes sont supprimés. >> jQuery 1.2.6 (16kb, Minified and Gzipped)
- une version sans encodage de variables mais avec suppressions des espaces, tabulations et sauts de ligne. >> jQuery 1.2.6 (30kb, Packed)
- une version sans compression
jQuery 1.2.6 (97kb, Uncompressed)

Il existe une petite application en ligne http://dean.edwards.name/packer/ qui fait ça très bien. Vous copiez/collez votre code dans le champ de formulaire, vous cochez Base encode et Shrink variables et vous cliquez sur le bouton Pack.

Et vous obtenez un code qui commence comme celui-ci :

eval(function(p,a,c,k,e,r){e=function(c){return(c

Quelle est la manière de coder les boucles en Javascript la plus rapide (while do, for, arr.forEach, etc.)

2

http://blogs.sun.com/greimer/entry/best_way_to_code_a

I built a loop benchmarking test suite for different ways of coding loops in JavaScript. There are a few of these out there already, but I didn't find any that acknowledged the difference between native arrays and HTML collections. Since the underlying implementations are different (HTML collections for example lack the pop() and slice() methods, etc), benchmarks that don't test against both are probably missing important information.

My suspicions were confirmed. Accessing the length property is more expensive on HTML collections than on arrays, depending on the browser. In those cases, caching it made a huge difference. However, HTML collections are live, so a cached value may fail if the underlying DOM is modified during looping. On the other hand, HTML collections will never be sparse, so the best way to loop an HTML collection might just be to ignore the length property altogether and combine the test with the item lookup, since you have to do that anyway:

Native Array (length=1000, looped 100 times)
Basic for loop. for (var i=0; i<arr.length; i++) { } 8ms
For loop, but caching the length. for (var i=0, len=arr.length; i<len; i++) { } 5ms
While loop that imitates a for loop. var i = 0; while (i < arr.length) { i++; } 7ms
While loop that imitates a for loop, caching the length. var i = 0, len = arr.length; while (i < len) { i++; } 4ms
While loop in reverse, simplifying the test condition. var i = arr.length; while (i--) { } 2ms
do ... while loop in reverse. var i = arr.length-1; do { } while (i--); 3ms
While looping by popping values (this fails on sparse arrays). var x; while (x = arr.pop()) { } 10ms
for ... in loop for (var i in arr) { } 30ms
for ... in loop, with integer test var isInt = /(^[0-9]$)|(^[1-9][0-9]+$)/; for (var i in arr) { if(!isInt.test(i)){continue;} } 206ms
For loop, testing on existence rather than length (this fails on sparse arrays). for (var i=0; arr[i]; i++) { } 5ms
For loop, testing on existence rather than length, plus array lookup. for (var i=0; arr[i]; i++) { var x = arr[i]; } 9ms
For loop, testing on existence rather than length, array lookup is combined with test. for (var i=0, x; x = arr[i++];) { } 5ms
For reference. for (var i=0, len=arr.length; i<len; i++) { var x = arr[i]; } 9ms
Array.forEach() native implementation. arr.forEach(function(x){}); 41ms
For reference against forEach(). var f=function(x){}; for (var i=0, len=arr.length; i<len; i++) { f(arr[i]); } 43ms
Sparse Native Array (length=11698, sporadically populated with 1000 items, looped 100 times)
Basic for loop. for (var i=0; i<sarr.length; i++) { } 111ms
For loop, but caching the length. for (var i=0, len=sarr.length; i<len; i++) { } 59ms
While loop that imitates a for loop. var i = 0; while (i < sarr.length) { i++; } 106ms
While loop that imitates a for loop, caching the length. var i = 0, len = sarr.length; while (i < len) { i++; } 53ms
While loop in reverse, simplifying the test condition. var i = sarr.length; while (i--) { } 31ms
do ... while loop in reverse. var i = sarr.length-1; do { } while (i--); 32ms
for ... in loop for (var i in sarr) { } 36ms
for ... in loop, with integer test var isInt = /(^[0-9]$)|(^[1-9][0-9]+$)/; for (var i in sarr) { if(!isInt.test(i)){continue;} } 197ms
Array.forEach() native implementation. sarr.forEach(function(x){}); 183ms
For reference against forEach(). var f=function(x){}; for (var i=0, len=sarr.length; i<len; i++) { f(sarr[i]); } 668ms
HTML Collection (length=1000, looped 100 times)
Basic for loop. for (var i=0; i<hColl.length; i++) { } 130ms
For loop, but caching the length. for (var i=0, len=hColl.length; i<len; i++) { } 5ms
While loop that imitates a for loop. var i = 0; while (i < hColl.length) { i++; } 129ms
While loop that imitates a for loop, caching the length. var i = 0, len = hColl.length; while (i < len) { i++; } 4ms
While loop in reverse, simplifying the test condition. var i = hColl.length; while (i--) { } 3ms
do ... while loop in reverse. var i = hColl.length-1; do { } while (i--); 3ms
for ... in loop for (var i in hColl) { } 111ms
for ... in loop, with integer test var isInt = /(^[0-9]$)|(^[1-9][0-9]+$)/; for (var i in hColl) { if(!isInt.test(i)){continue;} } 269ms
For loop, testing on existence rather than length (this fails on sparse arrays). for (var i=0; hColl[i]; i++) { } 133ms
For loop, testing on existence rather than length, plus array lookup. for (var i=0; hColl[i]; i++) { var x = hColl[i]; } 262ms
For loop, testing on existence rather than length, array lookup is combined with test. for (var i=0, x; x = hColl[i++];) { } 137ms
For loop, testing on existence rather than length, array lookup is combined with test, item() instead of array brackets. for (var i=0, x; x = hColl.item(i++);) { } 222ms
For reference. for (var i=0, len=hColl.length; i<len; i++) { var x = hColl[i]; } 138ms

Les frameworks javascript les plus utilisés ? Prototype, jQuery, Mootools, Yahoo! UI

4

Parmi 200 sites du top100 d'Alexa US et du top100 de Web Apps, la société Pingdom a examiné ceux qui utilisent un framework Javascript tels que : Prototype, JQuery, MooTools, Yahoo! UI Library, Dojo, ExtJS and MochiKit. En réalité l'étude s'est concentré uniquement sur Prototype, jQuery, Mootools, et Yahoo! UI Librairy. Les autres n'étant pas vraiment utilisés.

A noter que cette étude n'a porté que sur les pages d'accueil de ces sites.

Pour Prototype. Un total de 13 sites a été recensé.

 

Pour jQuery. Un total de 11 sites a été recensé.

 

Pour Mootols. Un total de 4 sites a été recensé.

Pour Yahoo. Un total de 7 sites a été recensé.

Il est intéressant de constater que certains sites comme Digg(Prototype et jQuery), Bebo (Mootools et YUI), YouSendIt (Prototype et YUI) utilisent 2 frameworks conjointement.

Syndiquer le contenu