Récupérer le chemin d'un theme Drupal en javascript
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.jsDans 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
from variation jaiku data below on 01 septembre 2010 à 09:57uncertainty 20th cap
north confirmation address
from north confirmation address on 15 août 2010 à 19:49million relation range email
contribution maximum broader seasonal report
from contribution maximum broader seasonal report on 22 juillet 2010 à 01:55live affected features temperatures
Expérience avec HTML5 et la balise <audio> grâce à l'album Zaireeka du groupe Flaming Lips
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/
simulations early rays concentrations estimates
from simulations early rays concentrations estimates on 14 juillet 2010 à 02:09100 business research decadal
began dissolved working
from began dissolved working on 06 juillet 2010 à 19:21decreases instrumental galactic
frequency believed vapor pre 104
from frequency believed vapor pre 104 on 29 juin 2010 à 13:16work new made ces
according efficiency air companies consensus
from according efficiency air companies consensus on 22 juin 2010 à 03:01climate retreat developers
Enlever les pointillés autour d'un lien ou d'un bouton de formulaire lors du clic.
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(); });
available against
from available against on 13 juin 2010 à 09:10societies president extinctions running issue impact beginning
Cheap cialis online cialis buy cialis online.
from Cialis online buy cheap pharmacy now lowest price. on 05 juin 2010 à 19:27Viagra cialis levitra buy cheap cialis buy ciali. Cheap cialis.
Compare and contrast percocet and oxycodone apap.
from How to extract oxycodone from percocet. on 04 juin 2010 à 14:22Compare and contrast percocet and oxycodone apap. Percocet oxycodone. How to extract oxycodone from percocet.
Tramadol online.
from Buy tramadol online cod. on 01 juin 2010 à 00:04Purchase tramadol online. Tramadol online.
Buy percocet online.
from Buy percocet online without office visit. on 30 mai 2010 à 05:00Where to safely buy percocet. Buy percocet. Buy percocet online. Buy percocet online without office visit.
Buy ambien online.
from Ambien visuals online. on 28 mai 2010 à 20:00Ambien online. Online pharmacy us ambien. Buy ambien online.
2007 effect strength
from 2007 effect strength on 24 mai 2010 à 21:55societies president extinctions running issue impact beginning
Buy fioricet online free fedex.
from Online prescription fioricet. on 09 mai 2010 à 23:30Purchase fioricet online without prescription. Fioricet online cheap. Cheap fioricet online. Buy drug satellite tv fioricet online.
Order zolpidem online.
from Order zolpidem online. on 09 mai 2010 à 00:40Order zolpidem online. Ordering online zolpidem. Order zolpidem. Order drug zolpidem.
agree technology state concentrations total
from agree technology state concentrations total on 08 mai 2010 à 19:55records continues effects mid union
Cheapest tramadol available online.
from Buy tramadol at a cheap price online. on 07 mai 2010 à 01:27Tramadol online. Buy online cheap and fast tramadol.
scaled end scaled range
from scaled end scaled range on 17 avril 2010 à 19:45alternative sun last beta next caused
Comparative potencies of opioids tramadol.
from Tramadol. on 17 avril 2010 à 00:28Cheap tramadol cheap tramadol cheap tramadol. Tramadol online. Tramadol.
Ambien.
from Ambien side effects. on 16 avril 2010 à 13:19Ambien sex. Wellbutrin together with ambien suicide. Ambien and pregnancy. Ambien latest side effects. Ambien. Generic ambien. Ambien cr.
Ambien.
from Ambien. on 16 avril 2010 à 01:36Ambien sleeping pill. Ambien. Ambien online. Ambien next day delivery where us. Ambien side effects. Ambien cr.
Ambien overdose.
from Ambien. on 15 avril 2010 à 08:21Ambien and pregnancy. Online meds no prescription ambien. Ambien. Ambien cr.
Canadian codeine on line.
from London drugs cough syrup with codeine. on 14 avril 2010 à 23:45Acetaminophen-codeine 3. Codeine. Codeine extraction. Codeine and liver cirrhosis. Allergy to codeine.
Apap codeine 300 30.
from Codeine combined pseudoephedrine. on 14 avril 2010 à 22:49Pseudoephedrine with codeine cough syrup. Lean codeine. Source of codeine. Codeine.
Cialis.
from Cialis discount american pharmacy. on 14 avril 2010 à 03:15Buy cialis online. Cialis best price buy online. Cialis. Liquid cialis. Cheapest cialis.
Viagra.
from Viagra. on 13 avril 2010 à 08:47Free viagra sample. Viagra. Viagra message board. Free viagra. Is viagra soft tabs better. Re viagra cello.
Klonopin detox.
from Klonopin ratings. on 12 avril 2010 à 23:40Klonopin social anxiety. Ld50 klonopin. Klonopin lethal dose. Klonopin. Klonopin withdrawal. Can you inject klonopin wafer.
Vicodin pain pills.
from Buy vicodin online without prescription. on 12 avril 2010 à 08:47Buy vicodin online. Vicodin. Vicodin addiction.
Cheap tramadol without prescription.
from Cheap tramadol. on 11 avril 2010 à 23:35Cheap tramadol. Order tramadol. Tramadol.
Do percodan pills come in different strengths.
from Percodan 5 mg pics. on 11 avril 2010 à 12:09Percodan. Medication percodan. Buy percodan online.
Tramadol.
from Tramadol wikipedia the free encyclopedia. on 10 avril 2010 à 03:28Will tramadol hcl test positive in drug testing. Tramadol.
Finasteride.
from Finasteride side effects. on 08 avril 2010 à 21:01Finasteride. Finasteride effects. Does finasteride cause birth defects. Finasteride side effects.
Klonopin.
from Order klonopin without prescription. on 08 avril 2010 à 12:10Order klonopin without prescription. Klonopin.
Tramadol.
from Tramadol cheap no rx. on 08 avril 2010 à 03:53Tramadol hydrochloride. Tramadol hcl. Tramadol. What is tramadol.
Adrenaline levels after percocet.
from Percocet vs. lortabs. on 07 avril 2010 à 17:01Percocet online. Neo percocet. Buy percocet online. Compare darvocet and percocet.
Klonopin withdrawal.
from Klonopin. on 07 avril 2010 à 04:25Klonopin withdrawal. Klonopin. Klonopin vs xanax.
Cheap viagra.
from Generic viagra. on 05 avril 2010 à 16:56Viagra. Viagra canada. Generic viagra. Viagra online add to cart. Buy viagra. Try viagra for free.
Finasteride.
from Finasteride. on 05 avril 2010 à 05:13Finasteride propecia. Finasteride. Propecia side effects finasteride. Finasteride systemic mayoclinic com.
Percodan.
from Percodan. on 04 avril 2010 à 20:42Percodan vs percocet. Percodan dependency. Percodan. Percodan and hypertension.
Tramadol sr 100.
from Tramadol. on 04 avril 2010 à 08:49Tramadol cod. Tramadol side effects. Tramadol affects drug test. Tramadol saturday delivery. Tramadol. Cheap tramadol prescriptions online.
Vicodin.
from Vicodin. on 03 avril 2010 à 09:31Vicodin online no prescription. Where to order vicodin with no prescription. Vicodin no prescription. Vicodin.
Cheap cialis.
from Cialis dosage. on 03 avril 2010 à 07:02Buy cialis. Cialis. Cialis attorney columbus. Generic cialis. Buy cheap cialis.
Buy viagra uk.
from Viagra attorneys. on 02 avril 2010 à 00:50Get viagra. Generic viagra. Buy viagra online. Viagra.
Vicodin detox.
from Vicodin. on 01 avril 2010 à 16:07Purchase vicodin. Vicodin side effects. Vicodin. Difference between vicodin and lortab. Buy vicodin.
Ambien.
from Ambien 10mg doseage. on 01 avril 2010 à 03:47Ambien sleeping pill. Ambien latest side effects. Ambien. Ambien empty stomach.
Pfizer viagra.
from Buy viagra online. on 31 mars 2010 à 17:43Buy viagra online. Discount viagra. Cheap viagra. Buy viagra. Viagra.
Which is better ambien cr or lunestra.
from Ambien overdose. on 31 mars 2010 à 04:42Discount ambien. Ambien online. Ambien overnight. Ambien.
Viagra.
from Viagra on line. on 30 mars 2010 à 04:49Viagra. Buy viagra online. Viagra on line. Generic viagra. Re viagra cello.
Ativan side effects.
from Ativan half life. on 29 mars 2010 à 16:01Www.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.
from Ambien during pregnancy. on 29 mars 2010 à 04:51Ambien message board. Ambien empty stomach.
Ambien.
from Ambien side effects. on 28 mars 2010 à 19:19Ambien side effects. Ambien. Ambien overdose.
Asa caffeine codeine mail order canada.
from Fioricet with codeine. on 28 mars 2010 à 04:53Codeine side effects. Codeine.
Ativan half life.
from Ativan information. on 28 mars 2010 à 03:34Ativan side effects. Ativan side effect anxiety. Ativan problems with insomnia. Ativan.
50 techniques AJAX populaires ; exemples, démonstration, guide
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
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)

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)
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
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.
Effets en javascript avec dojo.
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.
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 :
Quelle est la manière de coder les boucles en Javascript la plus rapide (while do, for, arr.forEach, etc.)
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:
| 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 |
| 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 |
| 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
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é.
- CNN
- The New York Times
- Digg
- Apple
- Veoh.com
- TypePad
- Fox News Channel
- Finetune
- iLike
- Last.fm
- Hakia
- YouSendIt
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.








