commit 0a34996378b160106a15f30b4a4ad13f99aaf1ff parent 863d0d81582313903008bf31dbada92f4cf4251b Author: Georges Dupéron <jahvascriptmaniac+github@free.fr> Date: Tue, 14 Sep 2010 02:17:05 +0200 Modifications pour MCHB Diffstat:
83 files changed, 3586 insertions(+), 105 deletions(-)
diff --git a/__cms__/code/modules/admin/admin-connexion.php b/__cms__/code/modules/admin/admin-connexion.php @@ -3,7 +3,7 @@ class AdminConnexion { public static function action($chemin, $action, $paramètres) { if ($action == "connexion") { - if (Authentification::connexion($paramètres["utilisateur"], $paramètres["mdp"])) { + if (Authentification::connexion(strtolower($paramètres["utilisateurnom"] . "___" . $paramètres["utilisateurprenom"]), $paramètres["mdp"])) { return self::vue($chemin, "connexion réussie"); } else { return self::vue($chemin, "connexion échouée"); @@ -54,7 +54,8 @@ class AdminConnexion { $ret = "<h2>" . $titre . "</h2>"; $ret .= $message; $ret .= '<form method="post" action="' . $chemin->get_url() . '">'; - $ret .= '<p><label for="utilisateur">Nom : </label><input type="text" id="utilisateur" name="utilisateur" value="" /></p>'; + $ret .= '<p><label for="utilisateurnom">Nom : </label><input type="text" id="utilisateurnom" name="utilisateurnom" value="" /></p>'; + $ret .= '<p><label for="utilisateurprenom">Prénom : </label><input type="text" id="utilisateurprenom" name="utilisateurprenom" value="" /></p>'; $ret .= '<p><label for="mdp">Mot de passe : </label><input type="password" id="mdp" name="mdp" value="" /></p>'; $ret .= '<p>'; $ret .= '<input type="hidden" name="action" value="connexion" />'; @@ -65,6 +66,6 @@ class AdminConnexion { } } -Modules::enregister_module("AdminConnexion", "admin-connexion", "vue", "utilisateur mdp"); +Modules::enregister_module("AdminConnexion", "admin-connexion", "vue", "utilisateurnom utilisateurprenom mdp"); ?> \ No newline at end of file diff --git a/__cms__/code/modules/contact/contact-contact.php b/__cms__/code/modules/contact/contact-contact.php @@ -0,0 +1,60 @@ +<?php + +class ContactContact { + public static function action($chemin, $action, $paramètres) { + if ($action == "anuler") { + return new Page($chemin, '', "redirect"); + } else if ($action == "supprimer") { + Stockage::supprimer($chemin, true); // TODO ! gérer correctement le récursif + return new Page($chemin->parent(), '', "redirect"); + } else { + if (isset($paramètres["contenu"])) { + Stockage::set_prop($chemin, "contenu", $paramètres["contenu"]); + } + + // titre après les autres paramètres car il peut générer un redirect. + if (isset($paramètres["titre"]) && Stockage::prop_diff($chemin, "titre", $paramètres["titre"])) { + Stockage::set_prop($chemin, "titre", $paramètres["titre"]); + Stockage::renomer($chemin, $paramètres["titre"]); + $chemin = $chemin->renomer($paramètres["titre"]); + // TODO : transmettre le paramètre "vue" + return new Page($chemin, '', "redirect"); + } + + if (isset($paramètres["vue"])) { + return self::vue($chemin, $paramètres["vue"]); + } else { + return self::vue($chemin); + } + } + } + + public static function vue($chemin, $vue = "normal") { + if ($vue == "normal") { + $ret = ''; + + if (Permissions::vérifier_permission($chemin, "set_prop", Authentification::get_utilisateur())) { + $ret .= '<form class="articles article edition" enctype="multipart/form-data" method="post" action="' . $chemin->get_url() . '">'; + $ret .= '<h2><input type="text" name="titre" value="' . Stockage::get_prop($chemin, "titre") . '" /></h2>'; + $ret .= formulaire_édition_texte_enrichi(Stockage::get_prop($chemin, "contenu"), "contenu"); + $ret .= '<p><input type="submit" value="appliquer" /></p>'; + $ret .= '</form>'; + } else { + $ret .= '<h2>' . Stockage::get_prop($chemin, "titre") . '</h2>'; + $ret .= affichage_texte_enrichi(Stockage::get_prop($chemin, "contenu")); + } + if (Permissions::vérifier_permission($chemin, "supprimer", Authentification::get_utilisateur())) { + // TODO : afficher le bouton "Supprimer". + } + + return new Page($ret, Stockage::get_prop($chemin, "titre")); + } elseif ($vue == "miniature") { + $ret = miniature_texte_enrichi(Stockage::get_prop($chemin, "contenu")); + return new Page($ret, Stockage::get_prop($chemin, "titre")); + } + } +} + +Modules::enregister_module("ContactContact", "contact-contact", "vue", "titre contenu"); + +?> +\ No newline at end of file diff --git a/__cms__/code/modules/contact/contact-index.php b/__cms__/code/modules/contact/contact-index.php @@ -0,0 +1,88 @@ +<?php + +class ContactIndex { + public static function action($chemin, $action, $paramètres) { + if ($action == "anuler") { + return new Page($chemin, '', "redirect"); + } else if ($action == "nouvelle_page") { + $np = Stockage::nouvelle_page($chemin, "Nouvel article", "articles-article"); + Stockage::set_prop($np, "proprietaire", Authentification::get_utilisateur()); + Stockage::set_prop($np, "titre", "Nouvel article"); + Stockage::set_prop($np, "contenu", "Bla bla bla."); + enregistrer_nouveaute($np); + return new Page($np, '', "redirect"); + } else { + if (isset($paramètres["description"])) { + Stockage::set_prop($chemin, "description", $paramètres["description"]); + } + + if (isset($paramètres["titre"])) { + Stockage::set_prop($chemin, "titre", $paramètres["titre"]); + } + + if (isset($paramètres["vue"])) { + return self::vue($chemin, $paramètres["vue"]); + } else { + return self::vue($chemin); + } + } + } + + public static function vue($chemin, $vue = "normal") { + if ($vue == "normal") { + $ret = ''; + + if (Permissions::vérifier_permission($chemin, "set_prop", Authentification::get_utilisateur())) { + $ret .= '<form class="articles infos" method="post" action="' . $chemin->get_url() . '">'; + $ret .= '<h2><input type="text" name="titre" value="' . Stockage::get_prop($chemin, "titre") . '" /></h2>'; + $ret .= formulaire_édition_texte_enrichi(Stockage::get_prop($chemin, "description"), "description"); + $ret .= '<p><input type="submit" value="appliquer" /></p>'; + $ret .= '</form>'; + } else { + $ret .= '<h2>' . Stockage::get_prop($chemin, "titre") . '</h2>'; + $ret .= '<p class="articles index description affichage">' . Stockage::get_prop($chemin, "description") . '</p>'; + } + + $ret .= '<div class="articles liste-articles index">'; + $ret .= '<ul>'; + + if (Permissions::vérifier_permission($chemin, "nouvelle_page", Authentification::get_utilisateur())) { + $ret .= '<li>'; + $ret .= '<div class="titre">'; + + $ret .= '<form class="articles nouvelle_page" method="post" action="' . $chemin->get_url() . '">'; + $ret .= '<p>'; + $ret .= '<input type="hidden" name="action" value="nouvelle_page"/>'; + $ret .= '<input type="submit" value="Nouvel article"/>'; + $ret .= '</p>'; + $ret .= '</form>'; + + $ret .= '</div>'; + $ret .= '</li>'; + } + + foreach (Stockage::liste_enfants($chemin) as $k) { // TODO : trier par numéro ! + $mini = Modules::vue($k, 'miniature'); + $ret .= '<li>'; + // TODO : mettre une ancre "#message<numéro>" + $ret .= '<a href="' . $k->get_url() . '">'; // TODO : escape l'url ! + $ret .= '<span class="titre">'; + $ret .= $mini->titre; + $ret .= '</span>'; + $ret .= '<p class="contenu">'; + $ret .= $mini->contenu; + $ret .= '</p>'; + $ret .= '</a>'; + $ret .= '</li>'; + } + + $ret .= '</ul>'; + + return new Page($ret, Stockage::get_prop($chemin, "titre")); + } + } +} + +Modules::enregister_module("ContactIndex", "contact-index", "vue", "titre description"); + +?> diff --git a/__cms__/code/modules/contact/include.php b/__cms__/code/modules/contact/include.php @@ -0,0 +1,4 @@ +<?php + require_once(dirname(__FILE__) . "/contact-index.php"); + require_once(dirname(__FILE__) . "/contact-contact.php"); +?> +\ No newline at end of file diff --git a/__cms__/code/modules/equipes/equipes-equipe.php b/__cms__/code/modules/equipes/equipes-equipe.php @@ -0,0 +1,86 @@ +<?php + +class ÉquipesÉquipe { + public static function action($chemin, $action, $paramètres) { + if ($action == "anuler") { + return new Page($chemin, '', "redirect"); + } else if ($action == "nouvelle_page") { + // SECURITE : On ne doit PAS pouvoir modifier dernier_numero arbitrairement + // CONCURENCE : Faire un lock quelque part... + $numéro_joueur = 1 + Stockage::get_prop($chemin, "dernier_numero"); + Stockage::set_prop($chemin, "dernier_numero", $numéro_joueur); + $np = Stockage::nouvelle_page($chemin, "Joueur" . $numéro_joueur, "equipes-joueur"); + Stockage::set_prop($np, "proprietaire", Authentification::get_utilisateur()); + Stockage::set_prop($np, "nom", "Dupondt"); + Stockage::set_prop($np, "prenom", "Jean"); + Stockage::set_prop($np, "description", ""); + enregistrer_nouveaute($np); + + return new Page($chemin, '', "redirect"); + } else if ($action == "supprimer") { + Stockage::supprimer($chemin, true); // TODO ! gérer correctement le récursif + return new Page($chemin->parent(), '', "redirect"); + } else { + if (isset($paramètres["titre"]) && Stockage::prop_diff($chemin, "titre", $paramètres["titre"])) { + Stockage::set_prop($chemin, "titre", $paramètres["titre"]); + Stockage::renomer($chemin, $paramètres["titre"]); + $chemin = $chemin->renomer($paramètres["titre"]); + // TODO : transmettre le paramètre "vue" + return new Page($chemin, '', "redirect"); + } + + if (isset($paramètres["vue"])) { + return self::vue($chemin, $paramètres["vue"]); + } else { + return self::vue($chemin); + } + } + } + + public static function vue($chemin, $vue = "normal") { + if ($vue == "normal") { + $ret = ''; + + if (Permissions::vérifier_permission($chemin, "set_prop", Authentification::get_utilisateur())) { + $ret .= '<form class="équipes équipe infos" method="post" action="' . $chemin->get_url() . '">'; + $ret .= '<h2><input type="text" name="titre" value="' . Stockage::get_prop($chemin, "titre") . '" /></h2>'; + $ret .= '<p><input type="submit" value="appliquer" /></p>'; + $ret .= '</form>'; + } else { + $ret .= '<h2 class="équipes équipe titre affichage">' . Stockage::get_prop($chemin, "titre") . '</h2>'; + } + if (Permissions::vérifier_permission($chemin, "supprimer", Authentification::get_utilisateur())) { + $ret .= '<form action="' . $chemin->get_url() . '">'; + $ret .= '<input type="hidden" name="action" value="supprimer"/>'; + $ret .= '<input type="submit" value="Supprimer l\'équipe"/>'; + $ret .= '</form>'; + } + $ret .= '<ul class="équipes équipe">'; + + foreach (stockage::liste_enfants($chemin) as $k) { + $ret .= '<li>' . Modules::vue($k)->contenu . '</li>'; + } + + if (Permissions::vérifier_permission($chemin, "nouvelle_page", Authentification::get_utilisateur())) { + $ret .= '<li>'; + $ret .= '<form class="équipes équipe nouvelle_page" method="post" action="' . $chemin->get_url() . '">'; + $ret .= '<p>'; + $ret .= '<input type="hidden" name="action" value="nouvelle_page"/>'; + $ret .= '<input type="submit" value="Nouveau joueur"/>'; + $ret .= '</p>'; + $ret .= '</form>'; + $ret .= '</li>'; + } + + $ret .= '</ul>'; + + return new Page($ret, Stockage::get_prop($chemin, "titre")); + } else if ($vue == "miniature") { + return new Page("Équipe.", Stockage::get_prop($chemin, "titre")); + } + } +} + +Modules::enregister_module("ÉquipesÉquipe", "equipes-equipe", "vue", "titre"); + +?> +\ No newline at end of file diff --git a/__cms__/code/modules/equipes/equipes-index.php b/__cms__/code/modules/equipes/equipes-index.php @@ -0,0 +1,84 @@ +<?php + +class ÉquipesIndex { + public static function action($chemin, $action, $paramètres) { + if ($action == "anuler") { + return new Page($chemin, '', "redirect"); + } else if ($action == "nouvelle_page") { + $np = Stockage::nouvelle_page($chemin, "Nouvelle équipe", "equipes-equipe"); + Stockage::set_prop($np, "proprietaire", Authentification::get_utilisateur()); + Stockage::set_prop($np, "titre", "Nouvelle équipe"); + Stockage::set_prop($np, "dernier_numero", 0); + enregistrer_nouveaute($np); + return new Page($np, '', "redirect"); + } else { + if (isset($paramètres["description"])) { + Stockage::set_prop($chemin, "description", $paramètres["description"]); + } + + if (isset($paramètres["titre"])) { + Stockage::set_prop($chemin, "titre", $paramètres["titre"]); + } + + if (isset($paramètres["vue"])) { + return self::vue($chemin, $paramètres["vue"]); + } else { + return self::vue($chemin); + } + } + } + + public static function vue($chemin, $vue = "normal") { + if ($vue == "normal") { + $ret = ''; + + if (Permissions::vérifier_permission($chemin, "set_prop", Authentification::get_utilisateur())) { + $ret .= '<form class="equipes infos" method="post" action="' . $chemin->get_url() . '">'; + $ret .= '<h2><input type="text" name="titre" value="' . Stockage::get_prop($chemin, "titre") . '" /></h2>'; + $ret .= formulaire_édition_texte_enrichi(Stockage::get_prop($chemin, "description"), "description"); + $ret .= '<p><input type="submit" value="appliquer" /></p>'; + $ret .= '</form>'; + } else { + $ret .= '<h2>' . Stockage::get_prop($chemin, "titre") . '</h2>'; + $ret .= '<p class="equipes index description affichage">' . Stockage::get_prop($chemin, "description") . '</p>'; + } + + $ret .= '<div class="equipes index liste-equipes">'; + $ret .= '<ul>'; + + if (Permissions::vérifier_permission($chemin, "nouvelle_page", Authentification::get_utilisateur())) { + $ret .= '<li>'; + $ret .= '<div class="titre">'; + + $ret .= '<form class="equipes nouvelle_page" method="post" action="' . $chemin->get_url() . '">'; + $ret .= '<p>'; + $ret .= '<input type="hidden" name="action" value="nouvelle_page"/>'; + $ret .= '<input type="submit" value="Nouvelle équipe"/>'; + $ret .= '</p>'; + $ret .= '</form>'; + + $ret .= '</div>'; + $ret .= '</li>'; + } + + foreach (Stockage::liste_enfants($chemin) as $k) { // TODO : trier par numéro ! + $mini = Modules::vue($k, 'miniature'); + $ret .= '<li>'; + $ret .= '<a href="' . $k->get_url() . '">'; // TODO : escape l'url ! + $ret .= '<span class="titre">'; + $ret .= $mini->titre; + $ret .= '</span>'; + $ret .= '</a>'; + $ret .= '</li>'; + } + + $ret .= '</ul>'; + + return new Page($ret, Stockage::get_prop($chemin, "titre")); + } + } +} + +Modules::enregister_module("ÉquipesIndex", "equipes-index", "vue", "titre description"); + +?> +\ No newline at end of file diff --git a/__cms__/code/modules/equipes/equipes-joueur.php b/__cms__/code/modules/equipes/equipes-joueur.php @@ -0,0 +1,58 @@ +<?php + +class ÉquipesJoueur { + public static function action($chemin, $action, $paramètres) { + if ($action == "anuler") { + return new Page($chemin, '', "redirect"); + } else if ($action == "supprimer") { + Stockage::supprimer($chemin, true); // TODO ! gérer correctement le récursif + return new Page($chemin->parent(), '', "redirect"); + } else { + if (isset($paramètres["nom"])) { + Stockage::set_prop($chemin, "nom", $paramètres["nom"]); + } + if (isset($paramètres["prenom"])) { + Stockage::set_prop($chemin, "prenom", $paramètres["prenom"]); + } + if (isset($paramètres["description"])) { + Stockage::set_prop($chemin, "description", $paramètres["description"]); + } + + return new Page($chemin->parent(), '', "redirect"); + } + } + + public static function vue($chemin, $vue = "normal") { + if ($vue == "normal") { + $ret = ''; + + if (Permissions::vérifier_permission($chemin, "set_prop", Authentification::get_utilisateur())) { + $ret .= '<form class="équipes joueur edition" enctype="multipart/form-data" method="post" action="' . $chemin->get_url() . '">'; + $ret .= '<input type="text" name="prenom" value="' . Stockage::get_prop($chemin, "prenom") . '" />'; + $ret .= '<input type="text" name="nom" value="' . Stockage::get_prop($chemin, "nom") . '" />'; + $ret .= formulaire_édition_texte_enrichi(Stockage::get_prop($chemin, "description"), "description"); + $ret .= '<p><input type="submit" value="appliquer" /></p>'; + $ret .= '</form>'; + } else { + $ret .= Stockage::get_prop($chemin, "prenom"); + $ret .= " "; + $ret .= Stockage::get_prop($chemin, "nom"); + $ret .= affichage_texte_enrichi(Stockage::get_prop($chemin, "description")); + } + if (Permissions::vérifier_permission($chemin, "supprimer", Authentification::get_utilisateur())) { + $ret .= '<form action="' . $chemin->get_url() . '">'; + $ret .= '<input type="hidden" name="action" value="supprimer"/>'; + $ret .= '<input type="submit" value="Supprimer le joueur ' . htmlspecialchars(Stockage::get_prop($chemin, "prenom") . " " . Stockage::get_prop($chemin, "nom")) . '"/>'; + $ret .= '</form>'; + } + + // Peut-être afficher le bouton "citer" ? ou est-ce trop d'options ? + + return new Page($ret, Stockage::get_prop($chemin, "prenom") . " " . Stockage::get_prop($chemin, "nom")); + } + } +} + +Modules::enregister_module("ÉquipesJoueur", "equipes-joueur", "vue", "nom prenom description"); + +?> +\ No newline at end of file diff --git a/__cms__/code/modules/equipes/include.php b/__cms__/code/modules/equipes/include.php @@ -0,0 +1,5 @@ +<?php + require_once(dirname(__FILE__) . "/equipes-index.php"); + require_once(dirname(__FILE__) . "/equipes-equipe.php"); + require_once(dirname(__FILE__) . "/equipes-joueur.php"); +?> +\ No newline at end of file diff --git a/__cms__/code/modules/include.php b/__cms__/code/modules/include.php @@ -6,7 +6,9 @@ require_once(dirname(__FILE__) . "/site/include.php"); require_once(dirname(__FILE__) . "/admin/include.php"); require_once(dirname(__FILE__) . "/forum/include.php"); require_once(dirname(__FILE__) . "/galerie/include.php"); -require_once(dirname(__FILE__) . "/articles/include.php"); require_once(dirname(__FILE__) . "/nouveautes/include.php"); +require_once(dirname(__FILE__) . "/equipes/include.php"); +require_once(dirname(__FILE__) . "/liens/include.php"); +require_once(dirname(__FILE__) . "/contact/include.php"); ?> \ No newline at end of file diff --git a/__cms__/code/modules/liens/include.php b/__cms__/code/modules/liens/include.php @@ -0,0 +1,4 @@ +<?php + require_once(dirname(__FILE__) . "/liens-index.php"); + require_once(dirname(__FILE__) . "/liens-lien.php"); +?> +\ No newline at end of file diff --git a/__cms__/code/modules/liens/liens-index.php b/__cms__/code/modules/liens/liens-index.php @@ -0,0 +1,88 @@ +<?php + +class LiensIndex { + public static function action($chemin, $action, $paramètres) { + if ($action == "anuler") { + return new Page($chemin, '', "redirect"); + } else if ($action == "nouvelle_page") { + $np = Stockage::nouvelle_page($chemin, "Nouvel article", "articles-article"); + Stockage::set_prop($np, "proprietaire", Authentification::get_utilisateur()); + Stockage::set_prop($np, "titre", "Nouvel article"); + Stockage::set_prop($np, "contenu", "Bla bla bla."); + enregistrer_nouveaute($np); + return new Page($np, '', "redirect"); + } else { + if (isset($paramètres["description"])) { + Stockage::set_prop($chemin, "description", $paramètres["description"]); + } + + if (isset($paramètres["titre"])) { + Stockage::set_prop($chemin, "titre", $paramètres["titre"]); + } + + if (isset($paramètres["vue"])) { + return self::vue($chemin, $paramètres["vue"]); + } else { + return self::vue($chemin); + } + } + } + + public static function vue($chemin, $vue = "normal") { + if ($vue == "normal") { + $ret = ''; + + if (Permissions::vérifier_permission($chemin, "set_prop", Authentification::get_utilisateur())) { + $ret .= '<form class="articles infos" method="post" action="' . $chemin->get_url() . '">'; + $ret .= '<h2><input type="text" name="titre" value="' . Stockage::get_prop($chemin, "titre") . '" /></h2>'; + $ret .= formulaire_édition_texte_enrichi(Stockage::get_prop($chemin, "description"), "description"); + $ret .= '<p><input type="submit" value="appliquer" /></p>'; + $ret .= '</form>'; + } else { + $ret .= '<h2>' . Stockage::get_prop($chemin, "titre") . '</h2>'; + $ret .= '<p class="articles index description affichage">' . Stockage::get_prop($chemin, "description") . '</p>'; + } + + $ret .= '<div class="articles liste-articles index">'; + $ret .= '<ul>'; + + if (Permissions::vérifier_permission($chemin, "nouvelle_page", Authentification::get_utilisateur())) { + $ret .= '<li>'; + $ret .= '<div class="titre">'; + + $ret .= '<form class="articles nouvelle_page" method="post" action="' . $chemin->get_url() . '">'; + $ret .= '<p>'; + $ret .= '<input type="hidden" name="action" value="nouvelle_page"/>'; + $ret .= '<input type="submit" value="Nouvel article"/>'; + $ret .= '</p>'; + $ret .= '</form>'; + + $ret .= '</div>'; + $ret .= '</li>'; + } + + foreach (Stockage::liste_enfants($chemin) as $k) { // TODO : trier par numéro ! + $mini = Modules::vue($k, 'miniature'); + $ret .= '<li>'; + // TODO : mettre une ancre "#message<numéro>" + $ret .= '<a href="' . $k->get_url() . '">'; // TODO : escape l'url ! + $ret .= '<span class="titre">'; + $ret .= $mini->titre; + $ret .= '</span>'; + $ret .= '<p class="contenu">'; + $ret .= $mini->contenu; + $ret .= '</p>'; + $ret .= '</a>'; + $ret .= '</li>'; + } + + $ret .= '</ul>'; + + return new Page($ret, Stockage::get_prop($chemin, "titre")); + } + } +} + +Modules::enregister_module("LiensIndex", "liens-index", "vue", "titre description"); + +?> diff --git a/__cms__/code/modules/liens/liens-lien.php b/__cms__/code/modules/liens/liens-lien.php @@ -0,0 +1,60 @@ +<?php + +class LiensLien { + public static function action($chemin, $action, $paramètres) { + if ($action == "anuler") { + return new Page($chemin, '', "redirect"); + } else if ($action == "supprimer") { + Stockage::supprimer($chemin, true); // TODO ! gérer correctement le récursif + return new Page($chemin->parent(), '', "redirect"); + } else { + if (isset($paramètres["contenu"])) { + Stockage::set_prop($chemin, "contenu", $paramètres["contenu"]); + } + + // titre après les autres paramètres car il peut générer un redirect. + if (isset($paramètres["titre"]) && Stockage::prop_diff($chemin, "titre", $paramètres["titre"])) { + Stockage::set_prop($chemin, "titre", $paramètres["titre"]); + Stockage::renomer($chemin, $paramètres["titre"]); + $chemin = $chemin->renomer($paramètres["titre"]); + // TODO : transmettre le paramètre "vue" + return new Page($chemin, '', "redirect"); + } + + if (isset($paramètres["vue"])) { + return self::vue($chemin, $paramètres["vue"]); + } else { + return self::vue($chemin); + } + } + } + + public static function vue($chemin, $vue = "normal") { + if ($vue == "normal") { + $ret = ''; + + if (Permissions::vérifier_permission($chemin, "set_prop", Authentification::get_utilisateur())) { + $ret .= '<form class="articles article edition" enctype="multipart/form-data" method="post" action="' . $chemin->get_url() . '">'; + $ret .= '<h2><input type="text" name="titre" value="' . Stockage::get_prop($chemin, "titre") . '" /></h2>'; + $ret .= formulaire_édition_texte_enrichi(Stockage::get_prop($chemin, "contenu"), "contenu"); + $ret .= '<p><input type="submit" value="appliquer" /></p>'; + $ret .= '</form>'; + } else { + $ret .= '<h2>' . Stockage::get_prop($chemin, "titre") . '</h2>'; + $ret .= affichage_texte_enrichi(Stockage::get_prop($chemin, "contenu")); + } + if (Permissions::vérifier_permission($chemin, "supprimer", Authentification::get_utilisateur())) { + // TODO : afficher le bouton "Supprimer". + } + + return new Page($ret, Stockage::get_prop($chemin, "titre")); + } elseif ($vue == "miniature") { + $ret = miniature_texte_enrichi(Stockage::get_prop($chemin, "contenu")); + return new Page($ret, Stockage::get_prop($chemin, "titre")); + } + } +} + +Modules::enregister_module("LiensLien", "liens-lien", "vue", "texte cible description"); + +?> +\ No newline at end of file diff --git a/__cms__/code/modules/nouveautes/nouveautes-index.php~ b/__cms__/code/modules/nouveautes/nouveautes-index.php~ @@ -1,62 +0,0 @@ -<?php - -class NouveautesIndex { - public static function action($chemin, $action, $paramètres) { - if ($action == "anuler") { - return new Page($chemin, '', "redirect"); - } else { - if (isset($paramètres["titre"])) { - Stockage::set_prop($chemin, "titre", $paramètres["titre"]); - } - - if (isset($paramètres["vue"])) { - return self::vue($chemin, $paramètres["vue"]); - } else { - return self::vue($chemin); - } - } - } - - public static function vue($chemin, $vue = "normal") { - if ($vue == "normal") { - $ret = ''; - - if (Permissions::vérifier_permission($chemin, "set_prop", Authentification::get_utilisateur())) { - $ret .= '<form class="articles infos" method="post" action="' . $chemin->get_url() . '">'; - $ret .= '<h2><input type="text" name="titre" value="' . Stockage::get_prop($chemin, "titre") . '" /></h2>'; - $ret .= '<p><input type="submit" value="appliquer" /></p>'; - $ret .= '</form>'; - } else { - $ret .= '<h2>' . Stockage::get_prop($chemin, "titre") . '</h2>'; - } - - $ret .= '<div class="nouveautes list index">'; - $ret .= '<ul>'; - - var_dump(Stockage::liste_enfants(new Chemin("/forum"))); - - foreach (Stockage::liste_enfants($chemin) as $k) { - $mini = Modules::vue($k, 'miniature'); - $ret .= '<li>'; - // TODO : mettre une ancre "#message<numéro>" - $ret .= '<a href="' . $k->get_url() . '">'; // TODO : escape l'url ! - $ret .= '<span class="titre">'; - $ret .= $mini->titre; - $ret .= '</span>'; - $ret .= '</a>'; - $ret .= '<p class="contenu">'; - $ret .= $mini->contenu; - $ret .= '</p>'; - $ret .= '</li>'; - } - - $ret .= '</ul>'; - - return new Page($ret, Stockage::get_prop($chemin, "titre")); - } - } -} - -Modules::enregister_module("NouveautesIndex", "nouveautes-index", "vue", "titre"); - -?> diff --git a/__cms__/code/modules/site/site-index.php b/__cms__/code/modules/site/site-index.php @@ -6,6 +6,14 @@ class SiteIndex { Stockage::set_prop($chemin, "nom_site", $paramètres["nom_site"]); } + if (isset($paramètres["prochain_evenement"])) { + Stockage::set_prop($chemin, "prochain_evenement", $paramètres["prochain_evenement"]); + } + + if (isset($paramètres["description"])) { + Stockage::set_prop($chemin, "description", $paramètres["description"]); + } + if (isset($paramètres["vue"])) { return self::vue($chemin, $paramètres["vue"]); } else { @@ -16,8 +24,37 @@ class SiteIndex { public static function vue($chemin, $vue = "normal") { if ($vue == "normal") { $ret = ''; - $ret .= "<h2>" . Stockage::get_prop($chemin, "nom_site") . "</h2>"; - $ret .= "<p>Bienvenue sur le site d'exemple.</p>"; + + $ret .= '<div class="prochain-evenement">'; + $ret .= '<h2>Prochain évènement</h2>'; + if (Permissions::vérifier_permission($chemin, "set_prop", Authentification::get_utilisateur())) { + $ret .= '<form method="post" action="' . $chemin->get_url() . '">'; + $ret .= formulaire_édition_texte_enrichi(Stockage::get_prop($chemin, "prochain_evenement"), "prochain_evenement"); + $ret .= '<p><input type="submit" value="appliquer" /></p>'; + $ret .= '</form>'; + } else { + $ret .= Stockage::get_prop($chemin, "prochain_evenement"); + } + $ret .= '</div>'; + + $ret .= '<div class="description-site">'; + if (Permissions::vérifier_permission($chemin, "set_prop", Authentification::get_utilisateur())) { + $ret .= '<form class="nom_site infos" method="post" action="' . $chemin->get_url() . '">'; + $ret .= '<h2><input type="text" name="nom_site" value="' . Stockage::get_prop($chemin, "nom_site") . '" /></h2>'; + $ret .= '<p><input type="submit" value="appliquer" /></p>'; + $ret .= '</form>'; + } else { + $ret .= "<h2>" . Stockage::get_prop($chemin, "nom_site") . "</h2>"; + } + if (Permissions::vérifier_permission($chemin, "set_prop", Authentification::get_utilisateur())) { + $ret .= '<form method="post" action="' . $chemin->get_url() . '">'; + $ret .= formulaire_édition_texte_enrichi(Stockage::get_prop($chemin, "description"), "description"); + $ret .= '<p><input type="submit" value="appliquer" /></p>'; + $ret .= '</form>'; + } else { + $ret .= Stockage::get_prop($chemin, "description"); + } + $ret .= '</div>'; return new Page($ret, Stockage::get_prop($chemin, "nom_site")); } else if ($vue == "css") { return new Page(get_css(), "text/css", "raw"); @@ -26,6 +63,6 @@ class SiteIndex { } } -Modules::enregister_module("SiteIndex", "site-index", "vue", "titre"); +Modules::enregister_module("SiteIndex", "site-index", "vue", "nom_site prochain_evenement description"); ?> \ No newline at end of file diff --git a/__cms__/code/site/css.php b/__cms__/code/site/css.php @@ -1,5 +1,8 @@ <?php +// #ba7500 +// #c0a700 + function get_css() { return "h1 a { color: #7f7f33; diff --git a/__cms__/code/site/squelette.php b/__cms__/code/site/squelette.php @@ -22,7 +22,9 @@ class Squelette { $ret .= ' <meta http-equiv="Content-Language" content="fr" />' . $nl; $ret .= ' <meta name="keywords" lang="fr" content="motcle1,mocle2" />' . $nl; $ret .= ' <meta name="description" content="Description de ma page web." />' . $nl; - $ret .= ' <link href="' . $chemin_css . '" rel="stylesheet" type="text/css" />' . $nl; + /*$ret .= ' <link href="' . $chemin_css . '" rel="stylesheet" type="text/css" />' . $nl;*/ + $ret .= ' <link href="' . $racine->get_url("test.less") . '" rel="stylesheet/less" type="text/css" />' . $nl; + $ret .= ' <script src="' . $racine->get_url("less/less.js") . '" type="text/javascript"></script>' . $nl; $ret .= ' </head>' . $nl; $ret .= ' <body>' . $nl; $ret .= ' <h1><a href="' . $racine->get_url() . '">' . Stockage::get_prop($racine, "nom_site") . '</a></h1>' . $nl; @@ -39,9 +41,11 @@ class Squelette { $ret .= ' <ul>' . $nl; $ret .= ' <li><a href="' . $racine->get_url() . '">Accueil</a></li>' . $nl; $ret .= ' <li><a href="' . $racine->enfant("galerie")->get_url() . '">Galerie</a></li>' . $nl; - $ret .= ' <li><a href="' . $racine->enfant("forum")->get_url() . '">Forum</a></li>' . $nl; - $ret .= ' <li><a href="' . $racine->enfant("articles")->get_url() . '">Articles</a></li>' . $nl; $ret .= ' <li><a href="' . $racine->enfant("nouveautes")->get_url() . '">Nouveautés</a></li>' . $nl; + $ret .= ' <li><a href="' . $racine->enfant("equipes")->get_url() . '">Équipes</a></li>' . $nl; + $ret .= ' <li><a href="' . $racine->enfant("forum")->get_url() . '">Forum</a></li>' . $nl; + $ret .= ' <li><a href="' . $racine->enfant("liens")->get_url() . '">Liens utiles</a></li>' . $nl; + $ret .= ' <li><a href="' . $racine->enfant("contact")->get_url() . '">Contact</a></li>' . $nl; if (Permissions::vérifier_permission($racine->enfant("admin"), "set_prop", Authentification::get_utilisateur())) { $ret .= '<li><a href="' . $racine->enfant("admin")->get_url() . '">Administration</a></li>' . $nl; } diff --git a/__cms__/donnees/__prop__description b/__cms__/donnees/__prop__description @@ -0,0 +1 @@ +Du bla bla sur le handball, l\'association, etc. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. +\ No newline at end of file diff --git a/__cms__/donnees/__prop__nom_site b/__cms__/donnees/__prop__nom_site @@ -1 +1 @@ -Site d'exemple -\ No newline at end of file +Montpellier Chamberte Handball +\ No newline at end of file diff --git a/__cms__/donnees/__prop__prochain_evenement b/__cms__/donnees/__prop__prochain_evenement @@ -0,0 +1 @@ +Match au stade de france ! +\ No newline at end of file diff --git a/__cms__/donnees/admin/utilisateurs/admin/__prop__groupe b/__cms__/donnees/admin/utilisateurs/grand___chef/__prop__groupe diff --git a/__cms__/donnees/admin/utilisateurs/admin/__prop__mot_de_passe b/__cms__/donnees/admin/utilisateurs/grand___chef/__prop__mot_de_passe diff --git a/__cms__/donnees/admin/utilisateurs/admin/__prop__peut_se_connecter b/__cms__/donnees/admin/utilisateurs/grand___chef/__prop__peut_se_connecter diff --git a/__cms__/donnees/articles/__prop__description b/__cms__/donnees/articles/__prop__description @@ -1,2 +0,0 @@ -Description des articles. -FooBar -\ No newline at end of file diff --git a/__cms__/donnees/articles/__prop__titre b/__cms__/donnees/articles/__prop__titre @@ -1 +0,0 @@ -Articles test -\ No newline at end of file diff --git a/__cms__/donnees/articles/__prop__type b/__cms__/donnees/articles/__prop__type @@ -1 +0,0 @@ -articles-index -\ No newline at end of file diff --git a/__cms__/donnees/contact/__prop__dernier_numero b/__cms__/donnees/contact/__prop__dernier_numero @@ -0,0 +1 @@ +0 +\ No newline at end of file diff --git a/__cms__/donnees/contact/__prop__description b/__cms__/donnees/contact/__prop__description @@ -0,0 +1 @@ +Personnes à contacter : +\ No newline at end of file diff --git a/__cms__/donnees/contact/__prop__titre b/__cms__/donnees/contact/__prop__titre @@ -0,0 +1 @@ +Contact +\ No newline at end of file diff --git a/__cms__/donnees/contact/__prop__type b/__cms__/donnees/contact/__prop__type @@ -0,0 +1 @@ +contact-index +\ No newline at end of file diff --git a/__cms__/donnees/equipes/__prop__description b/__cms__/donnees/equipes/__prop__description @@ -0,0 +1 @@ +Et nous présentons fièrement devant vos yeux ébahis nos équipes de super-handballeurs !!! +\ No newline at end of file diff --git a/__cms__/donnees/equipes/__prop__titre b/__cms__/donnees/equipes/__prop__titre @@ -0,0 +1 @@ +Équipes +\ No newline at end of file diff --git a/__cms__/donnees/equipes/__prop__type b/__cms__/donnees/equipes/__prop__type @@ -0,0 +1 @@ +equipes-index +\ No newline at end of file diff --git a/__cms__/donnees/equipes/Équipe n°1/Joueur3/__prop__date_modif b/__cms__/donnees/equipes/Équipe n°1/Joueur3/__prop__date_modif @@ -0,0 +1 @@ +1284419751 +\ No newline at end of file diff --git a/__cms__/donnees/equipes/Équipe n°1/Joueur3/__prop__description b/__cms__/donnees/equipes/Équipe n°1/Joueur3/__prop__description @@ -0,0 +1 @@ +Un vaillant gardien de but. Que la force soit avec lui ! +\ No newline at end of file diff --git a/__cms__/donnees/equipes/Équipe n°1/Joueur3/__prop__nom b/__cms__/donnees/equipes/Équipe n°1/Joueur3/__prop__nom @@ -0,0 +1 @@ +Skywalker +\ No newline at end of file diff --git a/__cms__/donnees/equipes/Équipe n°1/Joueur3/__prop__prenom b/__cms__/donnees/equipes/Équipe n°1/Joueur3/__prop__prenom @@ -0,0 +1 @@ +Luc +\ No newline at end of file diff --git a/__cms__/donnees/articles/Nouvel article/__prop__proprietaire b/__cms__/donnees/equipes/Équipe n°1/Joueur3/__prop__proprietaire diff --git a/__cms__/donnees/equipes/Équipe n°1/Joueur3/__prop__type b/__cms__/donnees/equipes/Équipe n°1/Joueur3/__prop__type @@ -0,0 +1 @@ +equipes-joueur +\ No newline at end of file diff --git a/__cms__/donnees/equipes/Équipe n°1/__prop__date_modif b/__cms__/donnees/equipes/Équipe n°1/__prop__date_modif @@ -0,0 +1 @@ +1284418704 +\ No newline at end of file diff --git a/__cms__/donnees/nouveautes/__prop__dernier_numero b/__cms__/donnees/equipes/Équipe n°1/__prop__dernier_numero diff --git a/__cms__/donnees/admin/utilisateurs/admin/__prop__mot_de_passe b/__cms__/donnees/equipes/Équipe n°1/__prop__proprietaire diff --git a/__cms__/donnees/equipes/Équipe n°1/__prop__titre b/__cms__/donnees/equipes/Équipe n°1/__prop__titre @@ -0,0 +1 @@ +Équipe n°1 +\ No newline at end of file diff --git a/__cms__/donnees/equipes/Équipe n°1/__prop__type b/__cms__/donnees/equipes/Équipe n°1/__prop__type @@ -0,0 +1 @@ +equipes-equipe +\ No newline at end of file diff --git a/__cms__/donnees/liens/__prop__dernier_numero b/__cms__/donnees/liens/__prop__dernier_numero @@ -0,0 +1 @@ +0 +\ No newline at end of file diff --git a/__cms__/donnees/liens/__prop__description b/__cms__/donnees/liens/__prop__description @@ -0,0 +1 @@ +Quelques liens utiles vers des terrains de handball virtuels ! +\ No newline at end of file diff --git a/__cms__/donnees/liens/__prop__titre b/__cms__/donnees/liens/__prop__titre @@ -0,0 +1 @@ +Liens utiles +\ No newline at end of file diff --git a/__cms__/donnees/liens/__prop__type b/__cms__/donnees/liens/__prop__type @@ -0,0 +1 @@ +liens-index +\ No newline at end of file diff --git a/__cms__/donnees/nouveautes/2/__prop__chemin b/__cms__/donnees/nouveautes/2/__prop__chemin @@ -1 +1 @@ -/forum/Nouveau sujet -\ No newline at end of file +/equipes/Nouvelle équipe +\ No newline at end of file diff --git a/__cms__/donnees/nouveautes/3/__prop__chemin b/__cms__/donnees/nouveautes/3/__prop__chemin @@ -1 +1 @@ -/forum/Nouveau sujet -\ No newline at end of file +/equipes/Équipe n°1/Nouveau joueur +\ No newline at end of file diff --git a/__cms__/donnees/nouveautes/4/__prop__chemin b/__cms__/donnees/nouveautes/4/__prop__chemin @@ -0,0 +1 @@ +/equipes/Équipe n°1/Joueur1 +\ No newline at end of file diff --git a/__cms__/donnees/nouveautes/4/__prop__type b/__cms__/donnees/nouveautes/4/__prop__type @@ -0,0 +1 @@ +nouveaute-element-liste +\ No newline at end of file diff --git a/__cms__/donnees/nouveautes/5/__prop__chemin b/__cms__/donnees/nouveautes/5/__prop__chemin @@ -0,0 +1 @@ +/equipes/Équipe n°1/Joueur2 +\ No newline at end of file diff --git a/__cms__/donnees/nouveautes/5/__prop__type b/__cms__/donnees/nouveautes/5/__prop__type @@ -0,0 +1 @@ +nouveaute-element-liste +\ No newline at end of file diff --git a/__cms__/donnees/nouveautes/6/__prop__chemin b/__cms__/donnees/nouveautes/6/__prop__chemin @@ -0,0 +1 @@ +/equipes/Équipe n°1/Joueur3 +\ No newline at end of file diff --git a/__cms__/donnees/nouveautes/6/__prop__type b/__cms__/donnees/nouveautes/6/__prop__type @@ -0,0 +1 @@ +nouveaute-element-liste +\ No newline at end of file diff --git a/__cms__/donnees/articles/Nouvel article/__prop__contenu b/__cms__/donnees/nouveautes/Nouvel article/__prop__contenu diff --git a/__cms__/donnees/admin/utilisateurs/admin/__prop__mot_de_passe b/__cms__/donnees/nouveautes/Nouvel article/__prop__proprietaire diff --git a/__cms__/donnees/articles/Nouvel article/__prop__titre b/__cms__/donnees/nouveautes/Nouvel article/__prop__titre diff --git a/__cms__/donnees/articles/Nouvel article/__prop__type b/__cms__/donnees/nouveautes/Nouvel article/__prop__type diff --git a/__cms__/donnees/nouveautes/__prop__dernier_numero b/__cms__/donnees/nouveautes/__prop__dernier_numero @@ -1 +1 @@ -3 -\ No newline at end of file +6 +\ No newline at end of file diff --git a/__cms__/donnees/nouveautes/__prop__description b/__cms__/donnees/nouveautes/__prop__description @@ -0,0 +1 @@ +Les dernières informations sur les matches et autres évènements sont affichées ici. +\ No newline at end of file diff --git a/__cms__/donnees/nouveautes/__prop__type b/__cms__/donnees/nouveautes/__prop__type @@ -1 +1 @@ -nouveautes-index -\ No newline at end of file +articles-index +\ No newline at end of file diff --git a/articles/Nouvel article/index.php b/articles/Nouvel article/index.php @@ -1,7 +0,0 @@ -<?php - -require_once(dirname(__FILE__) . "/./../../__cms__/cms.php"); - -CMS::page("/articles/Nouvel article"); - -?> -\ No newline at end of file diff --git a/articles/index.php b/articles/index.php @@ -1,7 +0,0 @@ -<?php - -require_once(dirname(__FILE) . "/./../__cms__/cms.php"); - -CMS::page("/articles"); - -?> diff --git a/contact/index.php b/contact/index.php @@ -0,0 +1,7 @@ +<?php + +require_once(dirname(__FILE) . "/./../__cms__/cms.php"); + +CMS::page("/contact"); + +?> diff --git a/equipes/Nouvelle équipe/index.php b/equipes/Nouvelle équipe/index.php @@ -0,0 +1,7 @@ +<?php + +require_once(dirname(__FILE__) . "/./../../__cms__/cms.php"); + +CMS::page("/equipes/Nouvelle équipe"); + +?> +\ No newline at end of file diff --git a/equipes/index.php b/equipes/index.php @@ -0,0 +1,7 @@ +<?php + +require_once(dirname(__FILE) . "/./../__cms__/cms.php"); + +CMS::page("/equipes"); + +?> diff --git a/equipes/Équipe n°1/Joueur1/index.php b/equipes/Équipe n°1/Joueur1/index.php @@ -0,0 +1,7 @@ +<?php + +require_once(dirname(__FILE__) . "/./../../../__cms__/cms.php"); + +CMS::page("/equipes/Équipe n°1/Joueur1"); + +?> +\ No newline at end of file diff --git a/equipes/Équipe n°1/Joueur2/index.php b/equipes/Équipe n°1/Joueur2/index.php @@ -0,0 +1,7 @@ +<?php + +require_once(dirname(__FILE__) . "/./../../../__cms__/cms.php"); + +CMS::page("/equipes/Équipe n°1/Joueur2"); + +?> +\ No newline at end of file diff --git a/equipes/Équipe n°1/Joueur3/index.php b/equipes/Équipe n°1/Joueur3/index.php @@ -0,0 +1,7 @@ +<?php + +require_once(dirname(__FILE__) . "/./../../../__cms__/cms.php"); + +CMS::page("/equipes/Équipe n°1/Joueur3"); + +?> +\ No newline at end of file diff --git a/equipes/Équipe n°1/Nouveau joueur/index.php b/equipes/Équipe n°1/Nouveau joueur/index.php @@ -0,0 +1,7 @@ +<?php + +require_once(dirname(__FILE__) . "/./../../../__cms__/cms.php"); + +CMS::page("/equipes/Équipe n°1/Nouveau joueur"); + +?> +\ No newline at end of file diff --git a/equipes/Équipe n°1/index.php b/equipes/Équipe n°1/index.php @@ -0,0 +1,7 @@ +<?php + +require_once(dirname(__FILE__) . "/./../../__cms__/cms.php"); + +CMS::page("/equipes/Équipe n°1"); + +?> +\ No newline at end of file diff --git a/less/less-1.0.35.js b/less/less-1.0.35.js @@ -0,0 +1,2565 @@ +// +// LESS - Leaner CSS v1.0.35 +// http://lesscss.org +// +// Copyright (c) 2010, Alexis Sellier +// Licensed under the Apache 2.0 License. +// +(function (window, undefined) { +// +// Stub out `require` in the browser +// +function require(arg) { + return window.less[arg.split('/')[1]]; +}; + + +// ecma-5.js +// +// -- kriskowal Kris Kowal Copyright (C) 2009-2010 MIT License +// -- tlrobinson Tom Robinson +// dantman Daniel Friesen + +// +// Array +// +if (!Array.isArray) { + Array.isArray = function(obj) { + return Object.prototype.toString.call(obj) === "[object Array]" || + (obj instanceof Array); + }; +} +if (!Array.prototype.forEach) { + Array.prototype.forEach = function(block, thisObject) { + var len = this.length >>> 0; + for (var i = 0; i < len; i++) { + if (i in this) { + block.call(thisObject, this[i], i, this); + } + } + }; +} +if (!Array.prototype.map) { + Array.prototype.map = function(fun /*, thisp*/) { + var len = this.length >>> 0; + var res = new Array(len); + var thisp = arguments[1]; + + for (var i = 0; i < len; i++) { + if (i in this) { + res[i] = fun.call(thisp, this[i], i, this); + } + } + return res; + }; +} +if (!Array.prototype.filter) { + Array.prototype.filter = function (block /*, thisp */) { + var values = []; + var thisp = arguments[1]; + for (var i = 0; i < this.length; i++) { + if (block.call(thisp, this[i])) { + values.push(this[i]); + } + } + return values; + }; +} +if (!Array.prototype.reduce) { + Array.prototype.reduce = function(fun /*, initial*/) { + var len = this.length >>> 0; + var i = 0; + + // no value to return if no initial value and an empty array + if (len === 0 && arguments.length === 1) throw new TypeError(); + + if (arguments.length >= 2) { + var rv = arguments[1]; + } else { + do { + if (i in this) { + rv = this[i++]; + break; + } + // if array contains no values, no initial value to return + if (++i >= len) throw new TypeError(); + } while (true); + } + for (; i < len; i++) { + if (i in this) { + rv = fun.call(null, rv, this[i], i, this); + } + } + return rv; + }; +} +if (!Array.prototype.indexOf) { + Array.prototype.indexOf = function (value /*, fromIndex */ ) { + var length = this.length; + var i = arguments[1] || 0; + + if (!length) return -1; + if (i >= length) return -1; + if (i < 0) i += length; + + for (; i < length; i++) { + if (!Object.prototype.hasOwnProperty.call(this, i)) { continue } + if (value === this[i]) return i; + } + return -1; + }; +} + +// +// Object +// +if (!Object.keys) { + Object.keys = function (object) { + var keys = []; + for (var name in object) { + if (Object.prototype.hasOwnProperty.call(object, name)) { + keys.push(name); + } + } + return keys; + }; +} + +// +// String +// +if (!String.prototype.trim) { + String.prototype.trim = function () { + return String(this).replace(/^\s\s*/, '').replace(/\s\s*$/, ''); + }; +} +var less, tree; + +if (typeof(window) === 'undefined') { + less = exports, + tree = require('less/tree'); +} else { + if (typeof(window.less) === 'undefined') { window.less = {} } + less = window.less, + tree = window.less.tree = {}; +} +// +// less.js - parser +// +// A relatively straight-forward predictive parser. +// There is no tokenization/lexing stage, the input is parsed +// in one sweep. +// +// To make the parser fast enough to run in the browser, several +// optimization had to be made: +// +// - Matching and slicing on a huge input is often cause of slowdowns. +// The solution is to chunkify the input into smaller strings. +// The chunks are stored in the `chunks` var, +// `j` holds the current chunk index, and `current` holds +// the index of the current chunk in relation to `input`. +// This gives us an almost 4x speed-up. +// +// - In many cases, we don't need to match individual tokens; +// for example, if a value doesn't hold any variables, operations +// or dynamic references, the parser can effectively 'skip' it, +// treating it as a literal. +// An example would be '1px solid #000' - which evaluates to itself, +// we don't need to know what the individual components are. +// The drawback, of course is that you don't get the benefits of +// syntax-checking on the CSS. This gives us a 50% speed-up in the parser, +// and a smaller speed-up in the code-gen. +// +// +// Token matching is done with the `$` function, which either takes +// a terminal string or regexp, or a non-terminal function to call. +// It also takes care of moving all the indices forwards. +// +// +less.Parser = function Parser(env) { + var input, // LeSS input string + i, // current index in `input` + j, // current chunk + temp, // temporarily holds a chunk's state, for backtracking + memo, // temporarily holds `i`, when backtracking + furthest, // furthest index the parser has gone to + chunks, // chunkified input + current, // index of current chunk, in `input` + parser; + + var that = this; + + // This function is called after all files + // have been imported through `@import`. + var finish = function () {}; + + var imports = this.imports = { + paths: env && env.paths || [], // Search paths, when importing + queue: [], // Files which haven't been imported yet + files: {}, // Holds the imported parse trees + push: function (path, callback) { + var that = this; + this.queue.push(path); + + // + // Import a file asynchronously + // + less.Parser.importer(path, this.paths, function (root) { + that.queue.splice(that.queue.indexOf(path), 1); // Remove the path from the queue + that.files[path] = root; // Store the root + + callback(root); + + if (that.queue.length === 0) { finish() } // Call `finish` if we're done importing + }); + } + }; + + function save() { temp = chunks[j], memo = i, current = i } + function restore() { chunks[j] = temp, i = memo, current = i } + + function sync() { + if (i > current) { + chunks[j] = chunks[j].slice(i - current); + current = i; + } + } + // + // Parse from a token, regexp or string, and move forward if match + // + function $(tok) { + var match, args, length, c, index, endIndex, k; + + // + // Non-terminal + // + if (tok instanceof Function) { + return tok.call(parser.parsers); + // + // Terminal + // + // Either match a single character in the input, + // or match a regexp in the current chunk (chunk[j]). + // + } else if (typeof(tok) === 'string') { + match = input.charAt(i) === tok ? tok : null; + length = 1; + sync (); + + // 1. We move to the next chunk, if necessary. + // 2. Set the `lastIndex` to be relative + // to the current chunk, and try to match in it. + // 3. Make sure we matched at `index`. Because we use + // the /g flag, the match could be anywhere in the + // chunk. We have to make sure it's at our previous + // index, which we stored in [2]. + // + } else { + sync (); + + if (match = tok.exec(chunks[j])) { // 3. + length = match[0].length; + } else { + return null; + } + } + + // The match is confirmed, add the match length to `i`, + // and consume any extra white-space characters (' ' || '\n') + // which come after that. The reason for this is that LeSS's + // grammar is mostly white-space insensitive. + // + if (match) { + mem = i += length; + endIndex = i + chunks[j].length - length; + + while (i < endIndex) { + c = input.charCodeAt(i); + if (! (c === 32 || c === 10 || c === 9)) { break } + i++; + } + chunks[j] = chunks[j].slice(length + (i - mem)); + current = i; + + if (chunks[j].length === 0 && j < chunks.length - 1) { j++ } + + if(typeof(match) === 'string') { + return match; + } else { + return match.length === 1 ? match[0] : match; + } + } + } + + // Same as $(), but don't change the state of the parser, + // just return the match. + function peek(tok) { + if (typeof(tok) === 'string') { + return input.charAt(i) === tok; + } else { + if (tok.test(chunks[j])) { + return true; + } else { + return false; + } + } + } + + this.env = env = env || {}; + + // The optimization level dictates the thoroughness of the parser, + // the lower the number, the less nodes it will create in the tree. + // This could matter for debugging, or if you want to access + // the individual nodes in the tree. + this.optimization = ('optimization' in this.env) ? this.env.optimization : 1; + + this.env.filename = this.env.filename || null; + + // + // The Parser + // + return parser = { + + imports: imports, + // + // Parse an input string into an abstract syntax tree, + // call `callback` when done. + // + parse: function (str, callback) { + var root, start, end, zone, line, lines, buff = [], c, error = null; + + i = j = current = furthest = 0; + chunks = []; + input = str.replace(/\r\n/g, '\n'); + + // Split the input into chunks. + chunks = (function (chunks) { + var j = 0, + skip = /[^"'`\{\}\/]+/g, + comment = /\/\*(?:[^*]|\*+[^\/*])*\*+\/|\/\/.*/g, + level = 0, + match, + chunk = chunks[0], + inString; + + for (var i = 0, c, cc; i < input.length; i++) { + skip.lastIndex = i; + if (match = skip.exec(input)) { + if (match.index === i) { + i += match[0].length; + chunk.push(match[0]); + } + } + c = input.charAt(i); + comment.lastIndex = i; + + if (!inString && c === '/') { + cc = input.charAt(i + 1); + if (cc === '/' || cc === '*') { + if (match = comment.exec(input)) { + if (match.index === i) { + i += match[0].length; + chunk.push(match[0]); + c = input.charAt(i); + } + } + } + } + + if (c === '{' && !inString) { level ++; + chunk.push(c); + } else if (c === '}' && !inString) { level --; + chunk.push(c); + chunks[++j] = chunk = []; + } else { + if (c === '"' || c === "'" || c === '`') { + if (! inString) { + inString = c; + } else { + inString = inString === c ? false : inString; + } + } + chunk.push(c); + } + } + if (level > 0) { + throw { + type: 'Syntax', + message: "Missing closing `}`", + filename: env.filename + }; + } + + return chunks.map(function (c) { return c.join('') });; + })([[]]); + + // Start with the primary rule. + // The whole syntax tree is held under a Ruleset node, + // with the `root` property set to true, so no `{}` are + // output. The callback is called when the input is parsed. + root = new(tree.Ruleset)([], $(this.parsers.primary)); + root.root = true; + + root.toCSS = (function (evaluate) { + var line, lines, column; + + return function (options, variables) { + var frames = []; + + options = options || {}; + // + // Allows setting variables with a hash, so: + // + // `{ color: new(tree.Color)('#f01') }` will become: + // + // new(tree.Rule)('@color', + // new(tree.Value)([ + // new(tree.Expression)([ + // new(tree.Color)('#f01') + // ]) + // ]) + // ) + // + if (typeof(variables) === 'object' && !Array.isArray(variables)) { + variables = Object.keys(variables).map(function (k) { + var value = variables[k]; + + if (! (value instanceof tree.Value)) { + if (! (value instanceof tree.Expression)) { + value = new(tree.Expression)([value]); + } + value = new(tree.Value)([value]); + } + return new(tree.Rule)('@' + k, value, false, 0); + }); + frames = [new(tree.Ruleset)(null, variables)]; + } + + try { + var css = evaluate.call(this, { frames: frames }) + .toCSS([], { compress: options.compress || false }); + } catch (e) { + lines = input.split('\n'); + line = getLine(e.index); + + for (var n = e.index, column = -1; + n >= 0 && input.charAt(n) !== '\n'; + n--) { column++ } + + throw { + type: e.type, + message: e.message, + filename: env.filename, + index: e.index, + line: typeof(line) === 'number' ? line + 1 : null, + callLine: e.call && (getLine(e.call) + 1), + callExtract: lines[getLine(e.call)], + stack: e.stack, + column: column, + extract: [ + lines[line - 1], + lines[line], + lines[line + 1] + ] + }; + } + if (options.compress) { + return css.replace(/(\s)+/g, "$1"); + } else { + return css; + } + + function getLine(index) { + return index ? (input.slice(0, index).match(/\n/g) || "").length : null; + } + }; + })(root.eval); + + // If `i` is smaller than the `input.length - 1`, + // it means the parser wasn't able to parse the whole + // string, so we've got a parsing error. + // + // We try to extract a \n delimited string, + // showing the line where the parse error occured. + // We split it up into two parts (the part which parsed, + // and the part which didn't), so we can color them differently. + if (i < input.length - 1) { + i = furthest; + lines = input.split('\n'); + line = (input.slice(0, i).match(/\n/g) || "").length + 1; + + for (var n = i, column = -1; n >= 0 && input.charAt(n) !== '\n'; n--) { column++ } + + error = { + name: "ParseError", + message: "Syntax Error on line " + line, + filename: env.filename, + line: line, + column: column, + extract: [ + lines[line - 2], + lines[line - 1], + lines[line] + ] + }; + } + + if (this.imports.queue.length > 0) { + finish = function () { callback(error, root) }; + } else { + callback(error, root); + } + }, + + // + // Here in, the parsing rules/functions + // + // The basic structure of the syntax tree generated is as follows: + // + // Ruleset -> Rule -> Value -> Expression -> Entity + // + // Here's some LESS code: + // + // .class { + // color: #fff; + // border: 1px solid #000; + // width: @w + 4px; + // > .child {...} + // } + // + // And here's what the parse tree might look like: + // + // Ruleset (Selector '.class', [ + // Rule ("color", Value ([Expression [Color #fff]])) + // Rule ("border", Value ([Expression [Dimension 1px][Keyword "solid"][Color #000]])) + // Rule ("width", Value ([Expression [Operation "+" [Variable "@w"][Dimension 4px]]])) + // Ruleset (Selector [Element '>', '.child'], [...]) + // ]) + // + // In general, most rules will try to parse a token with the `$()` function, and if the return + // value is truly, will return a new node, of the relevant type. Sometimes, we need to check + // first, before parsing, that's when we use `peek()`. + // + parsers: { + // + // The `primary` rule is the *entry* and *exit* point of the parser. + // The rules here can appear at any level of the parse tree. + // + // The recursive nature of the grammar is an interplay between the `block` + // rule, which represents `{ ... }`, the `ruleset` rule, and this `primary` rule, + // as represented by this simplified grammar: + // + // primary → (ruleset | rule)+ + // ruleset → selector+ block + // block → '{' primary '}' + // + // Only at one point is the primary rule not called from the + // block rule: at the root level. + // + primary: function () { + var node, root = []; + + while ((node = $(this.mixin.definition) || $(this.rule) || $(this.ruleset) || + $(this.mixin.call) || $(this.comment) || $(this.directive)) + || $(/^[\s\n]+/)) { + node && root.push(node); + } + return root; + }, + + // We create a Comment node for CSS comments `/* */`, + // but keep the LeSS comments `//` silent, by just skipping + // over them. + comment: function () { + var comment; + + if (input.charAt(i) !== '/') return; + + if (input.charAt(i + 1) === '/') { + return new(tree.Comment)($(/^\/\/.*/), true); + } else if (comment = $(/^\/\*(?:[^*]|\*+[^\/*])*\*+\/\n?/)) { + return new(tree.Comment)(comment); + } + }, + + // + // Entities are tokens which can be found inside an Expression + // + entities: { + // + // A string, which supports escaping " and ' + // + // "milky way" 'he\'s the one!' + // + quoted: function () { + var str; + if (input.charAt(i) !== '"' && input.charAt(i) !== "'") return; + + if (str = $(/^"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'/)) { + return new(tree.Quoted)(str[0], str[1] || str[2]); + } + }, + + // + // A catch-all word, such as: + // + // black border-collapse + // + keyword: function () { + var k; + if (k = $(/^[A-Za-z-]+/)) { return new(tree.Keyword)(k) } + }, + + // + // A function call + // + // rgb(255, 0, 255) + // + // We also try to catch IE's `alpha()`, but let the `alpha` parser + // deal with the details. + // + // The arguments are parsed with the `entities.arguments` parser. + // + call: function () { + var name, args; + + if (! (name = /^([\w-]+|%)\(/.exec(chunks[j]))) return; + + name = name[1].toLowerCase(); + + if (name === 'url') { return null } + else { i += name.length + 1 } + + if (name === 'alpha') { return $(this.alpha) } + + args = $(this.entities.arguments); + + if (! $(')')) return; + + if (name) { return new(tree.Call)(name, args) } + }, + arguments: function () { + var args = [], arg; + + while (arg = $(this.expression)) { + args.push(arg); + if (! $(',')) { break } + } + return args; + }, + literal: function () { + return $(this.entities.dimension) || + $(this.entities.color) || + $(this.entities.quoted); + }, + + // + // Parse url() tokens + // + // We use a specific rule for urls, because they don't really behave like + // standard function calls. The difference is that the argument doesn't have + // to be enclosed within a string, so it can't be parsed as an Expression. + // + url: function () { + var value; + + if (input.charAt(i) !== 'u' || !$(/^url\(/)) return; + value = $(this.entities.quoted) || $(this.entities.variable) || $(/^[-\w%@$\/.&=:;#+?]+/) || ""; + if (! $(')')) throw new(Error)("missing closing ) for url()"); + + return new(tree.URL)((value.value || value instanceof tree.Variable) + ? value : new(tree.Anonymous)(value), imports.paths); + }, + + // + // A Variable entity, such as `@fink`, in + // + // width: @fink + 2px + // + // We use a different parser for variable definitions, + // see `parsers.variable`. + // + variable: function () { + var name, index = i; + + if (input.charAt(i) === '@' && (name = $(/^@[\w-]+/))) { + return new(tree.Variable)(name, index); + } + }, + + // + // A Hexadecimal color + // + // #4F3C2F + // + // `rgb` and `hsl` colors are parsed through the `entities.call` parser. + // + color: function () { + var rgb; + + if (input.charAt(i) === '#' && (rgb = $(/^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})/))) { + return new(tree.Color)(rgb[1]); + } + }, + + // + // A Dimension, that is, a number and a unit + // + // 0.5em 95% + // + dimension: function () { + var value, c = input.charCodeAt(i); + if ((c > 57 || c < 45) || c === 47) return; + + if (value = $(/^(-?\d*\.?\d+)(px|%|em|pc|ex|in|deg|s|ms|pt|cm|mm|rad|grad|turn)?/)) { + return new(tree.Dimension)(value[1], value[2]); + } + }, + + // + // JavaScript code to be evaluated + // + // `window.location.href` + // + javascript: function () { + var str; + + if (input.charAt(i) !== '`') { return } + + if (str = $(/^`([^`]*)`/)) { + return new(tree.JavaScript)(str[1], i); + } + } + }, + + // + // The variable part of a variable definition. Used in the `rule` parser + // + // @fink: + // + variable: function () { + var name; + + if (input.charAt(i) === '@' && (name = $(/^(@[\w-]+)\s*:/))) { return name[1] } + }, + + // + // A font size/line-height shorthand + // + // small/12px + // + // We need to peek first, or we'll match on keywords and dimensions + // + shorthand: function () { + var a, b; + + if (! peek(/^[@\w.%-]+\/[@\w.-]+/)) return; + + if ((a = $(this.entity)) && $('/') && (b = $(this.entity))) { + return new(tree.Shorthand)(a, b); + } + }, + + // + // Mixins + // + mixin: { + // + // A Mixin call, with an optional argument list + // + // #mixins > .square(#fff); + // .rounded(4px, black); + // .button; + // + // The `while` loop is there because mixins can be + // namespaced, but we only support the child and descendant + // selector for now. + // + call: function () { + var elements = [], e, c, args, index = i, s = input.charAt(i); + + if (s !== '.' && s !== '#') { return } + + while (e = $(/^[#.][\w-]+/)) { + elements.push(new(tree.Element)(c, e)); + c = $('>'); + } + $('(') && (args = $(this.entities.arguments)) && $(')'); + + if (elements.length > 0 && ($(';') || peek('}'))) { + return new(tree.mixin.Call)(elements, args, index); + } + }, + + // + // A Mixin definition, with a list of parameters + // + // .rounded (@radius: 2px, @color) { + // ... + // } + // + // Until we have a finer grained state-machine, we have to + // do a look-ahead, to make sure we don't have a mixin call. + // See the `rule` function for more information. + // + // We start by matching `.rounded (`, and then proceed on to + // the argument list, which has optional default values. + // We store the parameters in `params`, with a `value` key, + // if there is a value, such as in the case of `@radius`. + // + // Once we've got our params list, and a closing `)`, we parse + // the `{...}` block. + // + definition: function () { + var name, params = [], match, ruleset, param, value; + + if ((input.charAt(i) !== '.' && input.charAt(i) !== '#') || + peek(/^[^{]*(;|})/)) return; + + if (match = $(/^([#.][\w-]+)\s*\(/)) { + name = match[1]; + + while (param = $(this.entities.variable) || $(this.entities.literal) + || $(this.entities.keyword)) { + // Variable + if (param instanceof tree.Variable) { + if ($(':')) { + if (value = $(this.expression)) { + params.push({ name: param.name, value: value }); + } else { + throw new(Error)("Expected value"); + } + } else { + params.push({ name: param.name }); + } + } else { + params.push({ value: param }); + } + if (! $(',')) { break } + } + if (! $(')')) throw new(Error)("Expected )"); + + ruleset = $(this.block); + + if (ruleset) { + return new(tree.mixin.Definition)(name, params, ruleset); + } + } + } + }, + + // + // Entities are the smallest recognized token, + // and can be found inside a rule's value. + // + entity: function () { + return $(this.entities.literal) || $(this.entities.variable) || $(this.entities.url) || + $(this.entities.call) || $(this.entities.keyword) || $(this.entities.javascript); + }, + + // + // A Rule terminator. Note that we use `peek()` to check for '}', + // because the `block` rule will be expecting it, but we still need to make sure + // it's there, if ';' was ommitted. + // + end: function () { + return $(';') || peek('}'); + }, + + // + // IE's alpha function + // + // alpha(opacity=88) + // + alpha: function () { + var value; + + if (! $(/^opacity=/i)) return; + if (value = $(/^\d+/) || $(this.entities.variable)) { + if (! $(')')) throw new(Error)("missing closing ) for alpha()"); + return new(tree.Alpha)(value); + } + }, + + // + // A Selector Element + // + // div + // + h1 + // #socks + // input[type="text"] + // + // Elements are the building blocks for Selectors, + // they are made out of a `Combinator` (see combinator rule), + // and an element name, such as a tag a class, or `*`. + // + element: function () { + var e, t; + + c = $(this.combinator); + e = $(/^[.#:]?[\w-]+/) || $('*') || $(this.attribute) || $(/^\([^)@]+\)/); + + if (e) { return new(tree.Element)(c, e) } + }, + + // + // Combinators combine elements together, in a Selector. + // + // Because our parser isn't white-space sensitive, special care + // has to be taken, when parsing the descendant combinator, ` `, + // as it's an empty space. We have to check the previous character + // in the input, to see if it's a ` ` character. More info on how + // we deal with this in *combinator.js*. + // + combinator: function () { + var match, c = input.charAt(i); + + if (c === '>' || c === '&' || c === '+' || c === '~') { + i++; + while (input.charAt(i) === ' ') { i++ } + return new(tree.Combinator)(c); + } else if (c === ':' && input.charAt(i + 1) === ':') { + i += 2; + while (input.charAt(i) === ' ') { i++ } + return new(tree.Combinator)('::'); + } else if (input.charAt(i - 1) === ' ') { + return new(tree.Combinator)(" "); + } else { + return new(tree.Combinator)(null); + } + }, + + // + // A CSS Selector + // + // .class > div + h1 + // li a:hover + // + // Selectors are made out of one or more Elements, see above. + // + selector: function () { + var sel, e, elements = [], c, match; + + while (e = $(this.element)) { + c = input.charAt(i); + elements.push(e) + if (c === '{' || c === '}' || c === ';' || c === ',') { break } + } + + if (elements.length > 0) { return new(tree.Selector)(elements) } + }, + tag: function () { + return $(/^[a-zA-Z][a-zA-Z-]*[0-9]?/) || $('*'); + }, + attribute: function () { + var attr = '', key, val, op; + + if (! $('[')) return; + + if (key = $(/^[a-zA-Z-]+/) || $(this.entities.quoted)) { + if ((op = $(/^[|~*$^]?=/)) && + (val = $(this.entities.quoted) || $(/^[\w-]+/))) { + attr = [key, op, val.toCSS ? val.toCSS() : val].join(''); + } else { attr = key } + } + + if (! $(']')) return; + + if (attr) { return "[" + attr + "]" } + }, + + // + // The `block` rule is used by `ruleset` and `mixin.definition`. + // It's a wrapper around the `primary` rule, with added `{}`. + // + block: function () { + var content; + + if ($('{') && (content = $(this.primary)) && $('}')) { + return content; + } + }, + + // + // div, .class, body > p {...} + // + ruleset: function () { + var selectors = [], s, rules, match; + save(); + + if (match = /^([.#: \w-]+)[\s\n]*\{/.exec(chunks[j])) { + i += match[0].length - 1; + selectors = [new(tree.Selector)([new(tree.Element)(null, match[1])])]; + } else { + while (s = $(this.selector)) { + selectors.push(s); + if (! $(',')) { break } + } + if (s) $(this.comment); + } + + if (selectors.length > 0 && (rules = $(this.block))) { + return new(tree.Ruleset)(selectors, rules); + } else { + // Backtrack + furthest = i; + restore(); + } + }, + rule: function () { + var value, c = input.charAt(i), important; + save(); + + if (c === '.' || c === '#' || c === '&') { return } + + if (name = $(this.variable) || $(this.property)) { + if ((name.charAt(0) != '@') && (match = /^([^@+\/'"*`(;{}-]*);/.exec(chunks[j]))) { + i += match[0].length - 1; + value = new(tree.Anonymous)(match[1]); + } else if (name === "font") { + value = $(this.font); + } else { + value = $(this.value); + } + important = $(this.important); + + if (value && $(this.end)) { + return new(tree.Rule)(name, value, important, memo); + } else { + furthest = i; + restore(); + } + } + }, + + // + // An @import directive + // + // @import "lib"; + // + // Depending on our environemnt, importing is done differently: + // In the browser, it's an XHR request, in Node, it would be a + // file-system operation. The function used for importing is + // stored in `import`, which we pass to the Import constructor. + // + "import": function () { + var path; + if ($(/^@import\s+/) && + (path = $(this.entities.quoted) || $(this.entities.url)) && + $(';')) { + return new(tree.Import)(path, imports); + } + }, + + // + // A CSS Directive + // + // @charset "utf-8"; + // + directive: function () { + var name, value, rules, types; + + if (input.charAt(i) !== '@') return; + + if (value = $(this['import'])) { + return value; + } else if (name = $(/^@media|@page/)) { + types = $(/^[^{]+/).trim(); + if (rules = $(this.block)) { + return new(tree.Directive)(name + " " + types, rules); + } + } else if (name = $(/^@[-a-z]+/)) { + if (name === '@font-face') { + if (rules = $(this.block)) { + return new(tree.Directive)(name, rules); + } + } else if ((value = $(this.entity)) && $(';')) { + return new(tree.Directive)(name, value); + } + } + }, + font: function () { + var value = [], expression = [], weight, shorthand, font, e; + + while (e = $(this.shorthand) || $(this.entity)) { + expression.push(e); + } + value.push(new(tree.Expression)(expression)); + + if ($(',')) { + while (e = $(this.expression)) { + value.push(e); + if (! $(',')) { break } + } + } + return new(tree.Value)(value); + }, + + // + // A Value is a comma-delimited list of Expressions + // + // font-family: Baskerville, Georgia, serif; + // + // In a Rule, a Value represents everything after the `:`, + // and before the `;`. + // + value: function () { + var e, expressions = [], important; + + while (e = $(this.expression)) { + expressions.push(e); + if (! $(',')) { break } + } + + if (expressions.length > 0) { + return new(tree.Value)(expressions); + } + }, + important: function () { + if (input.charAt(i) === '!') { + return $(/^! *important/); + } + }, + sub: function () { + var e; + + if ($('(') && (e = $(this.expression)) && $(')')) { + return e; + } + }, + multiplication: function () { + var m, a, op, operation; + if (m = $(this.operand)) { + while ((op = ($('/') || $('*'))) && (a = $(this.operand))) { + operation = new(tree.Operation)(op, [operation || m, a]); + } + return operation || m; + } + }, + addition: function () { + var m, a, op, operation; + if (m = $(this.multiplication)) { + while ((op = $(/^[-+]\s+/) || (input.charAt(i - 1) != ' ' && ($('+') || $('-')))) && + (a = $(this.multiplication))) { + operation = new(tree.Operation)(op, [operation || m, a]); + } + return operation || m; + } + }, + + // + // An operand is anything that can be part of an operation, + // such as a Color, or a Variable + // + operand: function () { + return $(this.sub) || $(this.entities.dimension) || + $(this.entities.color) || $(this.entities.variable) || + $(this.entities.call); + }, + + // + // Expressions either represent mathematical operations, + // or white-space delimited Entities. + // + // 1px solid black + // @var * 2 + // + expression: function () { + var e, delim, entities = [], d; + + while (e = $(this.addition) || $(this.entity)) { + entities.push(e); + } + if (entities.length > 0) { + return new(tree.Expression)(entities); + } + }, + property: function () { + var name; + + if (name = $(/^(\*?-?[-a-z_0-9]+)\s*:/)) { + return name[1]; + } + } + } + }; +}; + +if (typeof(window) !== 'undefined') { + // + // Used by `@import` directives + // + less.Parser.importer = function (path, paths, callback) { + if (path.charAt(0) !== '/' && paths.length > 0) { + path = paths[0] + path; + } + // We pass `true` as 3rd argument, to force the reload of the import. + // This is so we can get the syntax tree as opposed to just the CSS output, + // as we need this to evaluate the current stylesheet. + loadStyleSheet({ href: path, title: path }, callback, true); + }; +} + +(function (tree) { + +tree.functions = { + rgb: function (r, g, b) { + return this.rgba(r, g, b, 1.0); + }, + rgba: function (r, g, b, a) { + var rgb = [r, g, b].map(function (c) { return number(c) }), + a = number(a); + return new(tree.Color)(rgb, a); + }, + hsl: function (h, s, l) { + return this.hsla(h, s, l, 1.0); + }, + hsla: function (h, s, l, a) { + h = (number(h) % 360) / 360; + s = number(s); l = number(l); a = number(a); + + var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s; + var m1 = l * 2 - m2; + + return this.rgba(hue(h + 1/3) * 255, + hue(h) * 255, + hue(h - 1/3) * 255, + a); + + function hue(h) { + h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h); + if (h * 6 < 1) return m1 + (m2 - m1) * h * 6; + else if (h * 2 < 1) return m2; + else if (h * 3 < 2) return m1 + (m2 - m1) * (2/3 - h) * 6; + else return m1; + } + }, + hue: function (color) { + return new(tree.Dimension)(Math.round(color.toHSL().h)); + }, + saturation: function (color) { + return new(tree.Dimension)(Math.round(color.toHSL().s * 100), '%'); + }, + lightness: function (color) { + return new(tree.Dimension)(Math.round(color.toHSL().l * 100), '%'); + }, + alpha: function (color) { + return new(tree.Dimension)(color.toHSL().a); + }, + saturate: function (color, amount) { + var hsl = color.toHSL(); + + hsl.s += amount.value / 100; + hsl.s = clamp(hsl.s); + return hsla(hsl); + }, + desaturate: function (color, amount) { + var hsl = color.toHSL(); + + hsl.s -= amount.value / 100; + hsl.s = clamp(hsl.s); + return hsla(hsl); + }, + lighten: function (color, amount) { + var hsl = color.toHSL(); + + hsl.l += amount.value / 100; + hsl.l = clamp(hsl.l); + return hsla(hsl); + }, + darken: function (color, amount) { + var hsl = color.toHSL(); + + hsl.l -= amount.value / 100; + hsl.l = clamp(hsl.l); + return hsla(hsl); + }, + spin: function (color, amount) { + var hsl = color.toHSL(); + var hue = (hsl.h + amount.value) % 360; + + hsl.h = hue < 0 ? 360 + hue : hue; + + return hsla(hsl); + }, + greyscale: function (color) { + return this.desaturate(color, new(tree.Dimension)(100)); + }, + e: function (str) { + return new(tree.Anonymous)(str instanceof tree.JavaScript ? str.evaluated : str); + }, + '%': function (quoted /* arg, arg, ...*/) { + var args = Array.prototype.slice.call(arguments, 1), + str = quoted.value; + + for (var i = 0; i < args.length; i++) { + str = str.replace(/%s/, args[i].value) + .replace(/%[da]/, args[i].toCSS()); + } + str = str.replace(/%%/g, '%'); + return new(tree.Quoted)('"' + str + '"', str); + } +}; + +function hsla(hsla) { + return tree.functions.hsla(hsla.h, hsla.s, hsla.l, hsla.a); +} + +function number(n) { + if (n instanceof tree.Dimension) { + return parseFloat(n.unit == '%' ? n.value / 100 : n.value); + } else if (typeof(n) === 'number') { + return n; + } else { + throw { + error: "RuntimeError", + message: "color functions take numbers as parameters" + }; + } +} + +function clamp(val) { + return Math.min(1, Math.max(0, val)); +} + +})(require('less/tree')); +(function (tree) { + +tree.Alpha = function (val) { + this.value = val; +}; +tree.Alpha.prototype = { + toCSS: function () { + return "alpha(opacity=" + + (this.value.toCSS ? this.value.toCSS() : this.value) + ")"; + }, + eval: function () { return this } +}; + +})(require('less/tree')); +(function (tree) { + +tree.Anonymous = function (string) { + this.value = string.value || string; +}; +tree.Anonymous.prototype = { + toCSS: function () { + return this.value; + }, + eval: function () { return this } +}; + +})(require('less/tree')); +(function (tree) { + +// +// A function call node. +// +tree.Call = function (name, args) { + this.name = name; + this.args = args; +}; +tree.Call.prototype = { + // + // When evaluating a function call, + // we either find the function in `tree.functions` [1], + // in which case we call it, passing the evaluated arguments, + // or we simply print it out as it appeared originally [2]. + // + // The *functions.js* file contains the built-in functions. + // + // The reason why we evaluate the arguments, is in the case where + // we try to pass a variable to a function, like: `saturate(@color)`. + // The function should receive the value, not the variable. + // + eval: function (env) { + var args = this.args.map(function (a) { return a.eval(env) }); + + if (this.name in tree.functions) { // 1. + return tree.functions[this.name].apply(tree.functions, args); + } else { // 2. + return new(tree.Anonymous)(this.name + + "(" + args.map(function (a) { return a.toCSS() }).join(', ') + ")"); + } + }, + + toCSS: function (env) { + return this.eval(env).toCSS(); + } +}; + +})(require('less/tree')); +(function (tree) { +// +// RGB Colors - #ff0014, #eee +// +tree.Color = function (rgb, a) { + // + // The end goal here, is to parse the arguments + // into an integer triplet, such as `128, 255, 0` + // + // This facilitates operations and conversions. + // + if (Array.isArray(rgb)) { + this.rgb = rgb; + } else if (rgb.length == 6) { + this.rgb = rgb.match(/.{2}/g).map(function (c) { + return parseInt(c, 16); + }); + } else { + this.rgb = rgb.split('').map(function (c) { + return parseInt(c + c, 16); + }); + } + this.alpha = typeof(a) === 'number' ? a : 1; +}; +tree.Color.prototype = { + eval: function () { return this }, + + // + // If we have some transparency, the only way to represent it + // is via `rgba`. Otherwise, we use the hex representation, + // which has better compatibility with older browsers. + // Values are capped between `0` and `255`, rounded and zero-padded. + // + toCSS: function () { + if (this.alpha < 1.0) { + return "rgba(" + this.rgb.map(function (c) { + return Math.round(c); + }).concat(this.alpha).join(', ') + ")"; + } else { + return '#' + this.rgb.map(function (i) { + i = Math.round(i); + i = (i > 255 ? 255 : (i < 0 ? 0 : i)).toString(16); + return i.length === 1 ? '0' + i : i; + }).join(''); + } + }, + + // + // Operations have to be done per-channel, if not, + // channels will spill onto each other. Once we have + // our result, in the form of an integer triplet, + // we create a new Color node to hold the result. + // + operate: function (op, other) { + var result = []; + + if (! (other instanceof tree.Color)) { + other = other.toColor(); + } + + for (var c = 0; c < 3; c++) { + result[c] = tree.operate(op, this.rgb[c], other.rgb[c]); + } + return new(tree.Color)(result); + }, + + toHSL: function () { + var r = this.rgb[0] / 255, + g = this.rgb[1] / 255, + b = this.rgb[2] / 255, + a = this.alpha; + + var max = Math.max(r, g, b), min = Math.min(r, g, b); + var h, s, l = (max + min) / 2, d = max - min; + + if (max === min) { + h = s = 0; + } else { + s = l > 0.5 ? d / (2 - max - min) : d / (max + min); + + switch (max) { + case r: h = (g - b) / d + (g < b ? 6 : 0); break; + case g: h = (b - r) / d + 2; break; + case b: h = (r - g) / d + 4; break; + } + h /= 6; + } + return { h: h * 360, s: s, l: l, a: a }; + } +}; + + +})(require('less/tree')); +(function (tree) { + +tree.Comment = function (value, silent) { + this.value = value; + this.silent = !!silent; +}; +tree.Comment.prototype = { + toCSS: function (env) { + return env.compress ? '' : this.value; + }, + eval: function () { return this } +}; + +})(require('less/tree')); +(function (tree) { + +// +// A number with a unit +// +tree.Dimension = function (value, unit) { + this.value = parseFloat(value); + this.unit = unit || null; +}; + +tree.Dimension.prototype = { + eval: function () { return this }, + toColor: function () { + return new(tree.Color)([this.value, this.value, this.value]); + }, + toCSS: function () { + var css = this.value + this.unit; + return css; + }, + + // In an operation between two Dimensions, + // we default to the first Dimension's unit, + // so `1px + 2em` will yield `3px`. + // In the future, we could implement some unit + // conversions such that `100cm + 10mm` would yield + // `101cm`. + operate: function (op, other) { + return new(tree.Dimension) + (tree.operate(op, this.value, other.value), + this.unit || other.unit); + } +}; + +})(require('less/tree')); +(function (tree) { + +tree.Directive = function (name, value) { + this.name = name; + if (Array.isArray(value)) { + this.ruleset = new(tree.Ruleset)([], value); + } else { + this.value = value; + } +}; +tree.Directive.prototype = { + toCSS: function (ctx, env) { + if (this.ruleset) { + this.ruleset.root = true; + return this.name + (env.compress ? '{' : ' {\n ') + + this.ruleset.toCSS(ctx, env).trim().replace(/\n/g, '\n ') + + (env.compress ? '}': '\n}\n'); + } else { + return this.name + ' ' + this.value.toCSS() + ';\n'; + } + }, + eval: function (env) { + env.frames.unshift(this); + this.ruleset = this.ruleset && this.ruleset.eval(env); + env.frames.shift(); + return this; + }, + variable: function (name) { return tree.Ruleset.prototype.variable.call(this.ruleset, name) }, + find: function () { return tree.Ruleset.prototype.find.apply(this.ruleset, arguments) }, + rulesets: function () { return tree.Ruleset.prototype.rulesets.apply(this.ruleset) } +}; + +})(require('less/tree')); +(function (tree) { + +tree.Element = function (combinator, value) { + this.combinator = combinator instanceof tree.Combinator ? + combinator : new(tree.Combinator)(combinator); + this.value = value.trim(); +}; +tree.Element.prototype.toCSS = function (env) { + return this.combinator.toCSS(env || {}) + this.value; +}; + +tree.Combinator = function (value) { + if (value === ' ') { + this.value = ' '; + } else { + this.value = value ? value.trim() : ""; + } +}; +tree.Combinator.prototype.toCSS = function (env) { + return { + '' : '', + ' ' : ' ', + '&' : '', + ':' : ' :', + '::': '::', + '+' : env.compress ? '+' : ' + ', + '~' : env.compress ? '~' : ' ~ ', + '>' : env.compress ? '>' : ' > ' + }[this.value]; +}; + +})(require('less/tree')); +(function (tree) { + +tree.Expression = function (value) { this.value = value }; +tree.Expression.prototype = { + eval: function (env) { + if (this.value.length > 1) { + return new(tree.Expression)(this.value.map(function (e) { + return e.eval(env); + })); + } else { + return this.value[0].eval(env); + } + }, + toCSS: function (env) { + return this.value.map(function (e) { + return e.toCSS(env); + }).join(' '); + } +}; + +})(require('less/tree')); +(function (tree) { +// +// CSS @import node +// +// The general strategy here is that we don't want to wait +// for the parsing to be completed, before we start importing +// the file. That's because in the context of a browser, +// most of the time will be spent waiting for the server to respond. +// +// On creation, we push the import path to our import queue, though +// `import,push`, we also pass it a callback, which it'll call once +// the file has been fetched, and parsed. +// +tree.Import = function (path, imports) { + var that = this; + + this._path = path; + + // The '.less' extension is optional + if (path instanceof tree.Quoted) { + this.path = /\.(le?|c)ss$/.test(path.value) ? path.value : path.value + '.less'; + } else { + this.path = path.value.value || path.value; + } + + this.css = /css$/.test(this.path); + + // Only pre-compile .less files + if (! this.css) { + imports.push(this.path, function (root) { + if (! root) { + throw new(Error)("Error parsing " + that.path); + } + that.root = root; + }); + } +}; + +// +// The actual import node doesn't return anything, when converted to CSS. +// The reason is that it's used at the evaluation stage, so that the rules +// it imports can be treated like any other rules. +// +// In `eval`, we make sure all Import nodes get evaluated, recursively, so +// we end up with a flat structure, which can easily be imported in the parent +// ruleset. +// +tree.Import.prototype = { + toCSS: function () { + if (this.css) { + return "@import " + this._path.toCSS() + ';\n'; + } else { + return ""; + } + }, + eval: function (env) { + var ruleset; + + if (this.css) { + return this; + } else { + ruleset = new(tree.Ruleset)(null, this.root.rules.slice(0)); + + for (var i = 0; i < ruleset.rules.length; i++) { + if (ruleset.rules[i] instanceof tree.Import) { + Array.prototype + .splice + .apply(ruleset.rules, + [i, 1].concat(ruleset.rules[i].eval(env))); + } + } + return ruleset.rules; + } + } +}; + +})(require('less/tree')); +(function (tree) { + +tree.JavaScript = function (string, index) { + this.expression = string; + this.index = index; +}; +tree.JavaScript.prototype = { + toCSS: function () { + return JSON.stringify(this.evaluated); + }, + eval: function (env) { + var result, + expression = new(Function)('return (' + this.expression + ')'), + context = {}; + + for (var k in env.frames[0].variables()) { + context[k.slice(1)] = { + value: env.frames[0].variables()[k].value, + toJS: function () { + return this.value.eval(env).toCSS(); + } + }; + } + + try { + this.evaluated = expression.call(context); + } catch (e) { + throw { message: "JavaScript evaluation error: '" + e.name + ': ' + e.message + "'" , + index: this.index }; + } + return this; + } +}; + +})(require('less/tree')); + +(function (tree) { + +tree.Keyword = function (value) { this.value = value }; +tree.Keyword.prototype = { + eval: function () { return this }, + toCSS: function () { return this.value } +}; + +})(require('less/tree')); +(function (tree) { + +tree.mixin = {}; +tree.mixin.Call = function (elements, args, index) { + this.selector = new(tree.Selector)(elements); + this.arguments = args; + this.index = index; +}; +tree.mixin.Call.prototype = { + eval: function (env) { + var mixins, rules = [], match = false; + + for (var i = 0; i < env.frames.length; i++) { + if ((mixins = env.frames[i].find(this.selector)).length > 0) { + for (var m = 0; m < mixins.length; m++) { + if (mixins[m].match(this.arguments, env)) { + try { + Array.prototype.push.apply( + rules, mixins[m].eval(env, this.arguments).rules); + match = true; + } catch (e) { + throw { message: e.message, index: e.index, stack: e.stack, call: this.index }; + } + } + } + if (match) { + return rules; + } else { + throw { message: 'No matching definition was found for `' + + this.selector.toCSS().trim() + '(' + + this.arguments.map(function (a) { + return a.toCSS(); + }).join(', ') + ")`", + index: this.index }; + } + } + } + throw { message: this.selector.toCSS().trim() + " is undefined", + index: this.index }; + } +}; + +tree.mixin.Definition = function (name, params, rules) { + this.name = name; + this.selectors = [new(tree.Selector)([new(tree.Element)(null, name)])]; + this.params = params; + this.arity = params.length; + this.rules = rules; + this._lookups = {}; + this.required = params.reduce(function (count, p) { + if (p.name && !p.value) { return count + 1 } + else { return count } + }, 0); + this.parent = tree.Ruleset.prototype; + this.frames = []; +}; +tree.mixin.Definition.prototype = { + toCSS: function () { return "" }, + variable: function (name) { return this.parent.variable.call(this, name) }, + variables: function () { return this.parent.variables.call(this) }, + find: function () { return this.parent.find.apply(this, arguments) }, + rulesets: function () { return this.parent.rulesets.apply(this) }, + + eval: function (env, args) { + var frame = new(tree.Ruleset)(null, []), context; + + for (var i = 0, val; i < this.params.length; i++) { + if (this.params[i].name) { + if (val = (args && args[i]) || this.params[i].value) { + frame.rules.unshift(new(tree.Rule)(this.params[i].name, val.eval(env))); + } else { + throw { message: "wrong number of arguments for " + this.name + + ' (' + args.length + ' for ' + this.arity + ')' }; + } + } + } + return new(tree.Ruleset)(null, this.rules.slice(0)).eval({ + frames: [this, frame].concat(this.frames, env.frames) + }); + }, + match: function (args, env) { + var argsLength = (args && args.length) || 0, len; + + if (argsLength < this.required) { return false } + + len = Math.min(argsLength, this.arity); + + for (var i = 0; i < len; i++) { + if (!this.params[i].name) { + if (args[i].eval(env).toCSS() != this.params[i].value.eval(env).toCSS()) { + return false; + } + } + } + return true; + } +}; + +})(require('less/tree')); +(function (tree) { + +tree.Operation = function (op, operands) { + this.op = op.trim(); + this.operands = operands; +}; +tree.Operation.prototype.eval = function (env) { + var a = this.operands[0].eval(env), + b = this.operands[1].eval(env), + temp; + + if (a instanceof tree.Dimension && b instanceof tree.Color) { + if (this.op === '*' || this.op === '+') { + temp = b, b = a, a = temp; + } else { + throw { name: "OperationError", + message: "Can't substract or divide a color from a number" }; + } + } + return a.operate(this.op, b); +}; + +tree.operate = function (op, a, b) { + switch (op) { + case '+': return a + b; + case '-': return a - b; + case '*': return a * b; + case '/': return a / b; + } +}; + +})(require('less/tree')); +(function (tree) { + +tree.Quoted = function (str, content) { + this.value = content || ''; + this.quote = str.charAt(0); +}; +tree.Quoted.prototype = { + toCSS: function () { + return this.quote + this.value + this.quote; + }, + eval: function () { + return this; + } +}; + +})(require('less/tree')); +(function (tree) { + +tree.Rule = function (name, value, important, index) { + this.name = name; + this.value = (value instanceof tree.Value) ? value : new(tree.Value)([value]); + this.important = important ? ' ' + important.trim() : ''; + this.index = index; + + if (name.charAt(0) === '@') { + this.variable = true; + } else { this.variable = false } +}; +tree.Rule.prototype.toCSS = function (env) { + if (this.variable) { return "" } + else { + return this.name + (env.compress ? ':' : ': ') + + this.value.toCSS(env) + + this.important + ";"; + } +}; + +tree.Rule.prototype.eval = function (context) { + return new(tree.Rule)(this.name, this.value.eval(context), this.important, this.index); +}; + +tree.Shorthand = function (a, b) { + this.a = a; + this.b = b; +}; + +tree.Shorthand.prototype = { + toCSS: function (env) { + return this.a.toCSS(env) + "/" + this.b.toCSS(env); + }, + eval: function () { return this } +}; + +})(require('less/tree')); +(function (tree) { + +tree.Ruleset = function (selectors, rules) { + this.selectors = selectors; + this.rules = rules; + this._lookups = {}; +}; +tree.Ruleset.prototype = { + eval: function (env) { + var ruleset = new(tree.Ruleset)(this.selectors, this.rules.slice(0)); + + ruleset.root = this.root; + + // push the current ruleset to the frames stack + env.frames.unshift(ruleset); + + // Evaluate imports + if (ruleset.root) { + for (var i = 0; i < ruleset.rules.length; i++) { + if (ruleset.rules[i] instanceof tree.Import) { + Array.prototype.splice + .apply(ruleset.rules, [i, 1].concat(ruleset.rules[i].eval(env))); + } + } + } + + // Store the frames around mixin definitions, + // so they can be evaluated like closures when the time comes. + for (var i = 0; i < ruleset.rules.length; i++) { + if (ruleset.rules[i] instanceof tree.mixin.Definition) { + ruleset.rules[i].frames = env.frames.slice(0); + } + } + + // Evaluate mixin calls. + for (var i = 0; i < ruleset.rules.length; i++) { + if (ruleset.rules[i] instanceof tree.mixin.Call) { + Array.prototype.splice + .apply(ruleset.rules, [i, 1].concat(ruleset.rules[i].eval(env))); + } + } + + // Evaluate everything else + for (var i = 0, rule; i < ruleset.rules.length; i++) { + rule = ruleset.rules[i]; + + if (! (rule instanceof tree.mixin.Definition)) { + ruleset.rules[i] = rule.eval ? rule.eval(env) : rule; + } + } + + // Pop the stack + env.frames.shift(); + + return ruleset; + }, + match: function (args) { + return !args || args.length === 0; + }, + variables: function () { + if (this._variables) { return this._variables } + else { + return this._variables = this.rules.reduce(function (hash, r) { + if (r instanceof tree.Rule && r.variable === true) { + hash[r.name] = r; + } + return hash; + }, {}); + } + }, + variable: function (name) { + return this.variables()[name]; + }, + rulesets: function () { + if (this._rulesets) { return this._rulesets } + else { + return this._rulesets = this.rules.filter(function (r) { + return (r instanceof tree.Ruleset) || (r instanceof tree.mixin.Definition); + }); + } + }, + find: function (selector, self) { + self = self || this; + var rules = [], rule, match, + key = selector.toCSS(); + + if (key in this._lookups) { return this._lookups[key] } + + this.rulesets().forEach(function (rule) { + if (rule !== self) { + for (var j = 0; j < rule.selectors.length; j++) { + if (match = selector.match(rule.selectors[j])) { + if (selector.elements.length > 1) { + Array.prototype.push.apply(rules, rule.find( + new(tree.Selector)(selector.elements.slice(1)), self)); + } else { + rules.push(rule); + } + break; + } + } + } + }); + return this._lookups[key] = rules; + }, + // + // Entry point for code generation + // + // `context` holds an array of arrays. + // + toCSS: function (context, env) { + var css = [], // The CSS output + rules = [], // node.Rule instances + rulesets = [], // node.Ruleset instances + paths = [], // Current selectors + selector, // The fully rendered selector + rule; + + if (! this.root) { + if (context.length === 0) { + paths = this.selectors.map(function (s) { return [s] }); + } else { + for (var s = 0; s < this.selectors.length; s++) { + for (var c = 0; c < context.length; c++) { + paths.push(context[c].concat([this.selectors[s]])); + } + } + } + } + + // Compile rules and rulesets + for (var i = 0; i < this.rules.length; i++) { + rule = this.rules[i]; + + if (rule.rules || (rule instanceof tree.Directive)) { + rulesets.push(rule.toCSS(paths, env)); + } else if (rule instanceof tree.Comment) { + if (!rule.silent) { + if (this.root) { + rulesets.push(rule.toCSS(env)); + } else { + rules.push(rule.toCSS(env)); + } + } + } else { + if (rule.toCSS && !rule.variable) { + rules.push(rule.toCSS(env)); + } else if (rule.value && !rule.variable) { + rules.push(rule.value.toString()); + } + } + } + + rulesets = rulesets.join(''); + + // If this is the root node, we don't render + // a selector, or {}. + // Otherwise, only output if this ruleset has rules. + if (this.root) { + css.push(rules.join(env.compress ? '' : '\n')); + } else { + if (rules.length > 0) { + selector = paths.map(function (p) { + return p.map(function (s) { + return s.toCSS(env); + }).join('').trim(); + }).join(env.compress ? ',' : (paths.length > 3 ? ',\n' : ', ')); + css.push(selector, + (env.compress ? '{' : ' {\n ') + + rules.join(env.compress ? '' : '\n ') + + (env.compress ? '}' : '\n}\n')); + } + } + css.push(rulesets); + + return css.join('') + (env.compress ? '\n' : ''); + } +}; +})(require('less/tree')); +(function (tree) { + +tree.Selector = function (elements) { + this.elements = elements; + if (this.elements[0].combinator.value === "") { + this.elements[0].combinator.value = ' '; + } +}; +tree.Selector.prototype.match = function (other) { + if (this.elements[0].value === other.elements[0].value) { + return true; + } else { + return false; + } +}; +tree.Selector.prototype.toCSS = function (env) { + if (this._css) { return this._css } + + return this._css = this.elements.map(function (e) { + if (typeof(e) === 'string') { + return ' ' + e.trim(); + } else { + return e.toCSS(env); + } + }).join(''); +}; + +})(require('less/tree')); +(function (tree) { + +tree.URL = function (val, paths) { + // Add the base path if the URL is relative and we are in the browser + if (!/^(?:https?:\/|file:\/)?\//.test(val.value) && paths.length > 0 && typeof(window) !== 'undefined') { + val.value = paths[0] + (val.value.charAt(0) === '/' ? val.value.slice(1) : val.value); + } + this.value = val; + this.paths = paths; +}; +tree.URL.prototype = { + toCSS: function () { + return "url(" + this.value.toCSS() + ")"; + }, + eval: function (ctx) { + return new(tree.URL)(this.value.eval(ctx), this.paths); + } +}; + +})(require('less/tree')); +(function (tree) { + +tree.Value = function (value) { + this.value = value; + this.is = 'value'; +}; +tree.Value.prototype = { + eval: function (env) { + if (this.value.length === 1) { + return this.value[0].eval(env); + } else { + return new(tree.Value)(this.value.map(function (v) { + return v.eval(env); + })); + } + }, + toCSS: function (env) { + return this.value.map(function (e) { + return e.toCSS(env); + }).join(env.compress ? ',' : ', '); + } +}; + +})(require('less/tree')); +(function (tree) { + +tree.Variable = function (name, index) { this.name = name, this.index = index }; +tree.Variable.prototype = { + eval: function (env) { + var variable, v, name = this.name; + + if (variable = tree.find(env.frames, function (frame) { + if (v = frame.variable(name)) { + return v.value.eval(env); + } + })) { return variable } + else { + throw { message: "variable " + this.name + " is undefined", + index: this.index }; + } + } +}; + +})(require('less/tree')); +require('less/tree').find = function (obj, fun) { + for (var i = 0, r; i < obj.length; i++) { + if (r = fun.call(obj, obj[i])) { return r } + } + return null; +}; +// +// browser.js - client-side engine +// + +var isFileProtocol = (location.protocol === 'file:' || + location.protocol === 'chrome:' || + location.protocol === 'resource:'); + +less.env = less.env || + location.hostname == '127.0.0.1' || + location.hostname == '0.0.0.0' || + location.hostname == 'localhost' || + location.port.length > 0 || + isFileProtocol ? 'development' + : 'production'; + +// Load styles asynchronously (default: false) +// +// This is set to `false` by default, so that the body +// doesn't start loading before the stylesheets are parsed. +// Setting this to `true` can result in flickering. +// +less.async = false; + +// Interval between watch polls +less.poll = less.poll || (isFileProtocol ? 1000 : 1500); + +// +// Watch mode +// +less.watch = function () { return this.watchMode = true }; +less.unwatch = function () { return this.watchMode = false }; + +if (less.env === 'development') { + less.optimization = 0; + + if (/!watch/.test(location.hash)) { + less.watch(); + } + less.watchTimer = setInterval(function () { + if (less.watchMode) { + loadStyleSheets(function (root, sheet, env) { + if (root) { + createCSS(root.toCSS(), sheet, env.lastModified); + } + }); + } + }, less.poll); +} else { + less.optimization = 3; +} + +var cache; + +try { + cache = (typeof(window.localStorage) === 'undefined') ? null : window.localStorage; +} catch (_) { + cache = null; +} + +// +// Get all <link> tags with the 'rel' attribute set to "stylesheet/less" +// +var links = document.getElementsByTagName('link'); +var typePattern = /^text\/(x-)?less$/; + +less.sheets = []; + +for (var i = 0; i < links.length; i++) { + if (links[i].rel === 'stylesheet/less' || (links[i].rel.match(/stylesheet/) && + (links[i].type.match(typePattern)))) { + less.sheets.push(links[i]); + } +} + + +less.refresh = function (reload) { + var startTime = endTime = new(Date); + + loadStyleSheets(function (root, sheet, env) { + if (env.local) { + log("loading " + sheet.href + " from cache."); + } else { + log("parsed " + sheet.href + " successfully."); + createCSS(root.toCSS(), sheet, env.lastModified); + } + log("css for " + sheet.href + " generated in " + (new(Date) - endTime) + 'ms'); + (env.remaining === 0) && log("css generated in " + (new(Date) - startTime) + 'ms'); + endTime = new(Date); + }, reload); + + loadStyles(); +}; +less.refreshStyles = loadStyles; + +less.refresh(less.env === 'development'); + +function loadStyles() { + var styles = document.getElementsByTagName('style'); + for (var i = 0; i < styles.length; i++) { + if (styles[i].type.match(typePattern)) { + new(less.Parser)().parse(styles[i].innerHTML || '', function (e, tree) { + styles[i].type = 'text/css'; + styles[i].innerHTML = tree.toCSS(); + }); + } + } +} + +function loadStyleSheets(callback, reload) { + for (var i = 0; i < less.sheets.length; i++) { + loadStyleSheet(less.sheets[i], callback, reload, less.sheets.length - (i + 1)); + } +} + +function loadStyleSheet(sheet, callback, reload, remaining) { + var url = window.location.href; + var href = sheet.href.replace(/\?.*$/, ''); + var css = cache && cache.getItem(href); + var timestamp = cache && cache.getItem(href + ':timestamp'); + var styles = { css: css, timestamp: timestamp }; + + // Stylesheets in IE don't always return the full path + if (! /^(https?|file):/.test(href)) { + href = url.slice(0, url.lastIndexOf('/') + 1) + href; + } + + xhr(sheet.href, function (data, lastModified) { + if (!reload && styles && + (new(Date)(lastModified).valueOf() === + new(Date)(styles.timestamp).valueOf())) { + // Use local copy + createCSS(styles.css, sheet); + callback(null, sheet, { local: true, remaining: remaining }); + } else { + // Use remote copy (re-parse) + try { + new(less.Parser)({ + optimization: less.optimization, + paths: [href.replace(/[\w\.-]+$/, '')] + }).parse(data, function (e, root) { + if (e) { return error(e, href) } + try { + callback(root, sheet, { local: false, lastModified: lastModified, remaining: remaining }); + removeNode(document.getElementById('less-error-message:' + extractId(href))); + } catch (e) { + error(e, href); + } + }); + } catch (e) { + error(e, href); + } + } + }, function (status, url) { + throw new(Error)("Couldn't load " + url+ " (" + status + ")"); + }); +} + +function extractId(href) { + return href.replace(/^[a-z]+:\/\/?[^\/]+/, '' ) // Remove protocol & domain + .replace(/^\//, '' ) // Remove root / + .replace(/\?.*$/, '' ) // Remove query + .replace(/\.[^\.\/]+$/, '' ) // Remove file extension + .replace(/[^\.\w-]+/g, '-') // Replace illegal characters + .replace(/\./g, ':'); // Replace dots with colons(for valid id) +} + +function createCSS(styles, sheet, lastModified) { + var css; + + // Strip the query-string + var href = sheet.href ? sheet.href.replace(/\?.*$/, '') : ''; + + // If there is no title set, use the filename, minus the extension + var id = 'less:' + (sheet.title || extractId(href)); + + // If the stylesheet doesn't exist, create a new node + if ((css = document.getElementById(id)) === null) { + css = document.createElement('style'); + css.type = 'text/css'; + css.media = sheet.media || 'screen'; + css.id = id; + document.getElementsByTagName('head')[0].appendChild(css); + } + + if (css.styleSheet) { // IE + try { + css.styleSheet.cssText = styles; + } catch (e) { + throw new(Error)("Couldn't reassign styleSheet.cssText."); + } + } else { + (function (node) { + if (css.childNodes.length > 0) { + if (css.firstChild.nodeValue !== node.nodeValue) { + css.replaceChild(node, css.firstChild); + } + } else { + css.appendChild(node); + } + })(document.createTextNode(styles)); + } + + // Don't update the local store if the file wasn't modified + if (lastModified && cache) { + log('saving ' + href + ' to cache.'); + cache.setItem(href, styles); + cache.setItem(href + ':timestamp', lastModified); + } +} + +function xhr(url, callback, errback) { + var xhr = getXMLHttpRequest(); + var async = isFileProtocol ? false : less.async; + + if (typeof(xhr.overrideMimeType) === 'function') { + xhr.overrideMimeType('text/css'); + } + xhr.open('GET', url, async); + xhr.send(null); + + if (isFileProtocol) { + if (xhr.status === 0) { + callback(xhr.responseText); + } else { + errback(xhr.status); + } + } else if (async) { + xhr.onreadystatechange = function () { + if (xhr.readyState == 4) { + handleResponse(xhr, callback, errback); + } + }; + } else { + handleResponse(xhr, callback, errback); + } + + function handleResponse(xhr, callback, errback) { + if (xhr.status >= 200 && xhr.status < 300) { + callback(xhr.responseText, + xhr.getResponseHeader("Last-Modified")); + } else if (typeof(errback) === 'function') { + errback(xhr.status, url); + } + } +} + +function getXMLHttpRequest() { + if (window.XMLHttpRequest) { + return new(XMLHttpRequest); + } else { + try { + return new(ActiveXObject)("MSXML2.XMLHTTP.3.0"); + } catch (e) { + log("browser doesn't support AJAX."); + return null; + } + } +} + +function removeNode(node) { + return node && node.parentNode.removeChild(node); +} + +function log(str) { + if (less.env == 'development' && typeof(console) !== "undefined") { console.log('less: ' + str) } +} + +function error(e, href) { + var id = 'less-error-message:' + extractId(href); + + var template = ['<ul>', + '<li><label>[-1]</label><pre class="ctx">{0}</pre></li>', + '<li><label>[0]</label><pre>{current}</pre></li>', + '<li><label>[1]</label><pre class="ctx">{2}</pre></li>', + '</ul>'].join('\n'); + + var elem = document.createElement('div'), timer, content; + + elem.id = id; + elem.className = "less-error-message"; + + content = '<h3>' + (e.message || 'There is an error in your .less file') + + '</h3>' + '<p><a href="' + href + '">' + href + "</a> "; + + if (e.extract) { + content += 'on line ' + e.line + ', column ' + (e.column + 1) + ':</p>' + + template.replace(/\[(-?\d)\]/g, function (_, i) { + return (parseInt(e.line) + parseInt(i)) || ''; + }).replace(/\{(\d)\}/g, function (_, i) { + return e.extract[parseInt(i)] || ''; + }).replace(/\{current\}/, e.extract[1].slice(0, e.column) + '<span class="error">' + + e.extract[1].slice(e.column) + '</span>'); + } + elem.innerHTML = content; + + // CSS for error messages + createCSS([ + '.less-error-message ul, .less-error-message li {', + 'list-style-type: none;', + 'margin-right: 15px;', + 'padding: 4px 0;', + 'margin: 0;', + '}', + '.less-error-message label {', + 'font-size: 12px;', + 'margin-right: 15px;', + 'padding: 4px 0;', + 'color: #cc7777;', + '}', + '.less-error-message pre {', + 'color: #ee4444;', + 'padding: 4px 0;', + 'margin: 0;', + 'display: inline-block;', + '}', + '.less-error-message pre.ctx {', + 'color: #dd4444;', + '}', + '.less-error-message h3 {', + 'font-size: 20px;', + 'font-weight: bold;', + 'padding: 15px 0 5px 0;', + 'margin: 0;', + '}', + '.less-error-message a {', + 'color: #10a', + '}', + '.less-error-message .error {', + 'color: red;', + 'font-weight: bold;', + 'padding-bottom: 2px;', + 'border-bottom: 1px dashed red;', + '}' + ].join('\n'), { title: 'error-message' }); + + elem.style.cssText = [ + "font-family: Arial, sans-serif", + "border: 1px solid #e00", + "background-color: #eee", + "border-radius: 5px", + "-webkit-border-radius: 5px", + "-moz-border-radius: 5px", + "color: #e00", + "padding: 15px", + "margin-bottom: 15px" + ].join(';'); + + if (less.env == 'development') { + timer = setInterval(function () { + if (document.body) { + if (document.getElementById(id)) { + document.body.replaceChild(elem, document.getElementById(id)); + } else { + document.body.insertBefore(elem, document.body.firstChild); + } + clearInterval(timer); + } + }, 10); + } +} + +})(window); diff --git a/less/less-1.0.35.min.js b/less/less-1.0.35.min.js @@ -0,0 +1,67 @@ +// +// LESS - Leaner CSS v1.0.35 +// http://lesscss.org +// +// Copyright (c) 2010, Alexis Sellier +// Licensed under the Apache 2.0 License. +// +(function(y){function q(e){return y.less[e.split("/")[1]]}function U(){for(var e=document.getElementsByTagName("style"),b=0;b<e.length;b++)if(e[b].type.match(V))(new o.Parser).parse(e[b].innerHTML||"",function(d,g){e[b].type="text/css";e[b].innerHTML=g.toCSS()})}function W(e,b){for(var d=0;d<o.sheets.length;d++)X(o.sheets[d],e,b,o.sheets.length-(d+1))}function X(e,b,d,g){var a=y.location.href,i=e.href.replace(/\?.*$/,""),h=D&&D.getItem(i),j=D&&D.getItem(i+":timestamp"),n={css:h,timestamp:j};/^(https?|file):/.test(i)|| +(i=a.slice(0,a.lastIndexOf("/")+1)+i);$(e.href,function(r,w){if(!d&&n&&(new Date(w)).valueOf()===(new Date(n.timestamp)).valueOf()){N(n.css,e);b(null,e,{local:true,remaining:g})}else try{(new o.Parser({optimization:o.optimization,paths:[i.replace(/[\w\.-]+$/,"")]})).parse(r,function(t,E){if(t)return Q(t,i);try{b(E,e,{local:false,lastModified:w,remaining:g});aa(document.getElementById("less-error-message:"+R(i)))}catch(O){Q(O,i)}})}catch(v){Q(v,i)}},function(r,w){throw new Error("Couldn't load "+w+ +" ("+r+")");})}function R(e){return e.replace(/^[a-z]+:\/\/?[^\/]+/,"").replace(/^\//,"").replace(/\?.*$/,"").replace(/\.[^\.\/]+$/,"").replace(/[^\.\w-]+/g,"-").replace(/\./g,":")}function N(e,b,d){var g,a=b.href?b.href.replace(/\?.*$/,""):"",i="less:"+(b.title||R(a));if((g=document.getElementById(i))===null){g=document.createElement("style");g.type="text/css";g.media=b.media||"screen";g.id=i;document.getElementsByTagName("head")[0].appendChild(g)}if(g.styleSheet)try{g.styleSheet.cssText=e}catch(h){throw new Error("Couldn't reassign styleSheet.cssText."); +}else(function(j){if(g.childNodes.length>0)g.firstChild.nodeValue!==j.nodeValue&&g.replaceChild(j,g.firstChild);else g.appendChild(j)})(document.createTextNode(e));if(d&&D){I("saving "+a+" to cache.");D.setItem(a,e);D.setItem(a+":timestamp",d)}}function $(e,b,d){function g(h,j,n){if(h.status>=200&&h.status<300)j(h.responseText,h.getResponseHeader("Last-Modified"));else typeof n==="function"&&n(h.status,e)}var a=ba(),i=P?false:o.async;typeof a.overrideMimeType==="function"&&a.overrideMimeType("text/css"); +a.open("GET",e,i);a.send(null);if(P)a.status===0?b(a.responseText):d(a.status);else if(i)a.onreadystatechange=function(){a.readyState==4&&g(a,b,d)};else g(a,b,d)}function ba(){if(y.XMLHttpRequest)return new XMLHttpRequest;else try{return new ActiveXObject("MSXML2.XMLHTTP.3.0")}catch(e){I("browser doesn't support AJAX.");return null}}function aa(e){return e&&e.parentNode.removeChild(e)}function I(e){o.env=="development"&&typeof console!=="undefined"&&console.log("less: "+e)}function Q(e,b){var d="less-error-message:"+ +R(b),g=document.createElement("div"),a;g.id=d;g.className="less-error-message";b="<h3>"+(e.message||"There is an error in your .less file")+'</h3><p><a href="'+b+'">'+b+"</a> ";if(e.extract)b+="on line "+e.line+", column "+(e.column+1)+":</p>"+'<ul>\n<li><label>[-1]</label><pre class="ctx">{0}</pre></li>\n<li><label>[0]</label><pre>{current}</pre></li>\n<li><label>[1]</label><pre class="ctx">{2}</pre></li>\n</ul>'.replace(/\[(-?\d)\]/g,function(i,h){return parseInt(e.line)+parseInt(h)||""}).replace(/\{(\d)\}/g, +function(i,h){return e.extract[parseInt(h)]||""}).replace(/\{current\}/,e.extract[1].slice(0,e.column)+'<span class="error">'+e.extract[1].slice(e.column)+"</span>");g.innerHTML=b;N(".less-error-message ul, .less-error-message li {\nlist-style-type: none;\nmargin-right: 15px;\npadding: 4px 0;\nmargin: 0;\n}\n.less-error-message label {\nfont-size: 12px;\nmargin-right: 15px;\npadding: 4px 0;\ncolor: #cc7777;\n}\n.less-error-message pre {\ncolor: #ee4444;\npadding: 4px 0;\nmargin: 0;\ndisplay: inline-block;\n}\n.less-error-message pre.ctx {\ncolor: #dd4444;\n}\n.less-error-message h3 {\nfont-size: 20px;\nfont-weight: bold;\npadding: 15px 0 5px 0;\nmargin: 0;\n}\n.less-error-message a {\ncolor: #10a\n}\n.less-error-message .error {\ncolor: red;\nfont-weight: bold;\npadding-bottom: 2px;\nborder-bottom: 1px dashed red;\n}", +{title:"error-message"});g.style.cssText="font-family: Arial, sans-serif;border: 1px solid #e00;background-color: #eee;border-radius: 5px;-webkit-border-radius: 5px;-moz-border-radius: 5px;color: #e00;padding: 15px;margin-bottom: 15px";if(o.env=="development")a=setInterval(function(){if(document.body){document.getElementById(d)?document.body.replaceChild(g,document.getElementById(d)):document.body.insertBefore(g,document.body.firstChild);clearInterval(a)}},10)}if(!Array.isArray)Array.isArray=function(e){return Object.prototype.toString.call(e)=== +"[object Array]"||e instanceof Array};if(!Array.prototype.forEach)Array.prototype.forEach=function(e,b){for(var d=this.length>>>0,g=0;g<d;g++)g in this&&e.call(b,this[g],g,this)};if(!Array.prototype.map)Array.prototype.map=function(e,b){for(var d=this.length>>>0,g=new Array(d),a=0;a<d;a++)if(a in this)g[a]=e.call(b,this[a],a,this);return g};if(!Array.prototype.filter)Array.prototype.filter=function(e,b){for(var d=[],g=0;g<this.length;g++)e.call(b,this[g])&&d.push(this[g]);return d};if(!Array.prototype.reduce)Array.prototype.reduce= +function(e){var b=this.length>>>0,d=0;if(b===0&&arguments.length===1)throw new TypeError;if(arguments.length>=2)var g=arguments[1];else{do{if(d in this){g=this[d++];break}if(++d>=b)throw new TypeError;}while(1)}for(;d<b;d++)if(d in this)g=e.call(null,g,this[d],d,this);return g};if(!Array.prototype.indexOf)Array.prototype.indexOf=function(e,b){var d=this.length;b=b||0;if(!d)return-1;if(b>=d)return-1;if(b<0)b+=d;for(;b<d;b++)if(Object.prototype.hasOwnProperty.call(this,b))if(e===this[b])return b;return-1}; +if(!Object.keys)Object.keys=function(e){var b=[];for(var d in e)Object.prototype.hasOwnProperty.call(e,d)&&b.push(d);return b};if(!String.prototype.trim)String.prototype.trim=function(){return String(this).replace(/^\s\s*/,"").replace(/\s\s*$/,"")};var o,m;if(typeof y==="undefined"){o=exports;m=q("less/tree")}else{if(typeof y.less==="undefined")y.less={};o=y.less;m=y.less.tree={}}o.Parser=function(e){function b(){r=t[n];E=w=j}function d(){t[n]=r;E=j=w}function g(){if(j>E){t[n]=t[n].slice(j-E);E=j}} +function a(f){var k,l,p;if(f instanceof Function)return f.call(O.parsers);else if(typeof f==="string"){f=h.charAt(j)===f?f:null;k=1;g()}else{g();if(f=f.exec(t[n]))k=f[0].length;else return null}if(f){mem=j+=k;for(p=j+t[n].length-k;j<p;){l=h.charCodeAt(j);if(!(l===32||l===10||l===9))break;j++}t[n]=t[n].slice(k+(j-mem));E=j;t[n].length===0&&n<t.length-1&&n++;return typeof f==="string"?f:f.length===1?f[0]:f}}function i(f){return typeof f==="string"?h.charAt(j)===f:f.test(t[n])?true:false}var h,j,n,r, +w,v,t,E,O,Y=function(){},S=this.imports={paths:e&&e.paths||[],queue:[],files:{},push:function(f,k){var l=this;this.queue.push(f);o.Parser.importer(f,this.paths,function(p){l.queue.splice(l.queue.indexOf(f),1);l.files[f]=p;k(p);l.queue.length===0&&Y()})}};this.env=e=e||{};this.optimization="optimization"in this.env?this.env.optimization:1;this.env.filename=this.env.filename||null;return O={imports:S,parse:function(f,k){var l,p,K=null;j=n=E=v=0;t=[];h=f.replace(/\r\n/g,"\n");t=function(L){for(var G= +0,H=/[^"'`\{\}\/]+/g,A=/\/\*(?:[^*]|\*+[^\/*])*\*+\/|\/\/.*/g,B=0,x,z=L[0],C,s=0,u;s<h.length;s++){H.lastIndex=s;if(x=H.exec(h))if(x.index===s){s+=x[0].length;z.push(x[0])}u=h.charAt(s);A.lastIndex=s;if(!C&&u==="/"){x=h.charAt(s+1);if(x==="/"||x==="*")if(x=A.exec(h))if(x.index===s){s+=x[0].length;z.push(x[0]);u=h.charAt(s)}}if(u==="{"&&!C){B++;z.push(u)}else if(u==="}"&&!C){B--;z.push(u);L[++G]=z=[]}else{if(u==='"'||u==="'"||u==="`")C=C?C===u?false:C:u;z.push(u)}}if(B>0)throw{type:"Syntax",message:"Missing closing `}`", +filename:e.filename};return L.map(function(F){return F.join("")})}([[]]);l=new m.Ruleset([],a(this.parsers.primary));l.root=true;l.toCSS=function(L){var G,H;return function(A,B){function x(u){return u?(h.slice(0,u).match(/\n/g)||"").length:null}var z=[];A=A||{};if(typeof B==="object"&&!Array.isArray(B)){B=Object.keys(B).map(function(u){var F=B[u];if(!(F instanceof m.Value)){F instanceof m.Expression||(F=new m.Expression([F]));F=new m.Value([F])}return new m.Rule("@"+u,F,false,0)});z=[new m.Ruleset(null, +B)]}try{var C=L.call(this,{frames:z}).toCSS([],{compress:A.compress||false})}catch(s){H=h.split("\n");G=x(s.index);A=s.index;for(z=-1;A>=0&&h.charAt(A)!=="\n";A--)z++;throw{type:s.type,message:s.message,filename:e.filename,index:s.index,line:typeof G==="number"?G+1:null,callLine:s.call&&x(s.call)+1,callExtract:H[x(s.call)],stack:s.stack,column:z,extract:[H[G-1],H[G],H[G+1]]};}return A.compress?C.replace(/(\s)+/g,"$1"):C}}(l.eval);if(j<h.length-1){j=v;p=h.split("\n");f=(h.slice(0,j).match(/\n/g)|| +"").length+1;for(var T=j,Z=-1;T>=0&&h.charAt(T)!=="\n";T--)Z++;K={name:"ParseError",message:"Syntax Error on line "+f,filename:e.filename,line:f,column:Z,extract:[p[f-2],p[f-1],p[f]]}}if(this.imports.queue.length>0)Y=function(){k(K,l)};else k(K,l)},parsers:{primary:function(){for(var f,k=[];(f=a(this.mixin.definition)||a(this.rule)||a(this.ruleset)||a(this.mixin.call)||a(this.comment)||a(this.directive))||a(/^[\s\n]+/);)f&&k.push(f);return k},comment:function(){var f;if(h.charAt(j)==="/")if(h.charAt(j+ +1)==="/")return new m.Comment(a(/^\/\/.*/),true);else if(f=a(/^\/\*(?:[^*]|\*+[^\/*])*\*+\/\n?/))return new m.Comment(f)},entities:{quoted:function(){var f;if(!(h.charAt(j)!=='"'&&h.charAt(j)!=="'"))if(f=a(/^"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'/))return new m.Quoted(f[0],f[1]||f[2])},keyword:function(){var f;if(f=a(/^[A-Za-z-]+/))return new m.Keyword(f)},call:function(){var f,k;if(f=/^([\w-]+|%)\(/.exec(t[n])){f=f[1].toLowerCase();if(f==="url")return null;else j+=f.length+1;if(f==="alpha")return a(this.alpha); +k=a(this.entities.arguments);if(a(")"))if(f)return new m.Call(f,k)}},arguments:function(){for(var f=[],k;k=a(this.expression);){f.push(k);if(!a(","))break}return f},literal:function(){return a(this.entities.dimension)||a(this.entities.color)||a(this.entities.quoted)},url:function(){var f;if(!(h.charAt(j)!=="u"||!a(/^url\(/))){f=a(this.entities.quoted)||a(this.entities.variable)||a(/^[-\w%@$\/.&=:;#+?]+/)||"";if(!a(")"))throw new Error("missing closing ) for url()");return new m.URL(f.value||f instanceof +m.Variable?f:new m.Anonymous(f),S.paths)}},variable:function(){var f,k=j;if(h.charAt(j)==="@"&&(f=a(/^@[\w-]+/)))return new m.Variable(f,k)},color:function(){var f;if(h.charAt(j)==="#"&&(f=a(/^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})/)))return new m.Color(f[1])},dimension:function(){var f;f=h.charCodeAt(j);if(!(f>57||f<45||f===47))if(f=a(/^(-?\d*\.?\d+)(px|%|em|pc|ex|in|deg|s|ms|pt|cm|mm|rad|grad|turn)?/))return new m.Dimension(f[1],f[2])},javascript:function(){var f;if(h.charAt(j)==="`")if(f=a(/^`([^`]*)`/))return new m.JavaScript(f[1], +j)}},variable:function(){var f;if(h.charAt(j)==="@"&&(f=a(/^(@[\w-]+)\s*:/)))return f[1]},shorthand:function(){var f,k;if(i(/^[@\w.%-]+\/[@\w.-]+/))if((f=a(this.entity))&&a("/")&&(k=a(this.entity)))return new m.Shorthand(f,k)},mixin:{call:function(){var f=[],k,l,p,K=j;k=h.charAt(j);if(!(k!=="."&&k!=="#")){for(;k=a(/^[#.][\w-]+/);){f.push(new m.Element(l,k));l=a(">")}a("(")&&(p=a(this.entities.arguments))&&a(")");if(f.length>0&&(a(";")||i("}")))return new m.mixin.Call(f,p,K)}},definition:function(){var f, +k=[],l,p;if(!(h.charAt(j)!=="."&&h.charAt(j)!=="#"||i(/^[^{]*(;|})/)))if(f=a(/^([#.][\w-]+)\s*\(/)){for(f=f[1];l=a(this.entities.variable)||a(this.entities.literal)||a(this.entities.keyword);){if(l instanceof m.Variable)if(a(":"))if(p=a(this.expression))k.push({name:l.name,value:p});else throw new Error("Expected value");else k.push({name:l.name});else k.push({value:l});if(!a(","))break}if(!a(")"))throw new Error("Expected )");if(l=a(this.block))return new m.mixin.Definition(f,k,l)}}},entity:function(){return a(this.entities.literal)|| +a(this.entities.variable)||a(this.entities.url)||a(this.entities.call)||a(this.entities.keyword)||a(this.entities.javascript)},end:function(){return a(";")||i("}")},alpha:function(){var f;if(a(/^opacity=/i))if(f=a(/^\d+/)||a(this.entities.variable)){if(!a(")"))throw new Error("missing closing ) for alpha()");return new m.Alpha(f)}},element:function(){var f;c=a(this.combinator);if(f=a(/^[.#:]?[\w-]+/)||a("*")||a(this.attribute)||a(/^\([^)@]+\)/))return new m.Element(c,f)},combinator:function(){var f= +h.charAt(j);if(f===">"||f==="&"||f==="+"||f==="~"){for(j++;h.charAt(j)===" ";)j++;return new m.Combinator(f)}else if(f===":"&&h.charAt(j+1)===":"){for(j+=2;h.charAt(j)===" ";)j++;return new m.Combinator("::")}else return h.charAt(j-1)===" "?new m.Combinator(" "):new m.Combinator(null)},selector:function(){for(var f,k=[],l;f=a(this.element);){l=h.charAt(j);k.push(f);if(l==="{"||l==="}"||l===";"||l===",")break}if(k.length>0)return new m.Selector(k)},tag:function(){return a(/^[a-zA-Z][a-zA-Z-]*[0-9]?/)|| +a("*")},attribute:function(){var f="",k,l,p;if(a("[")){if(k=a(/^[a-zA-Z-]+/)||a(this.entities.quoted))f=(p=a(/^[|~*$^]?=/))&&(l=a(this.entities.quoted)||a(/^[\w-]+/))?[k,p,l.toCSS?l.toCSS():l].join(""):k;if(a("]"))if(f)return"["+f+"]"}},block:function(){var f;if(a("{")&&(f=a(this.primary))&&a("}"))return f},ruleset:function(){var f=[],k,l;b();if(k=/^([.#: \w-]+)[\s\n]*\{/.exec(t[n])){j+=k[0].length-1;f=[new m.Selector([new m.Element(null,k[1])])]}else{for(;k=a(this.selector);){f.push(k);if(!a(","))break}k&& +a(this.comment)}if(f.length>0&&(l=a(this.block)))return new m.Ruleset(f,l);else{v=j;d()}},rule:function(){var f;f=h.charAt(j);var k;b();if(!(f==="."||f==="#"||f==="&"))if(name=a(this.variable)||a(this.property)){if(name.charAt(0)!="@"&&(match=/^([^@+\/'"*`(;{}-]*);/.exec(t[n]))){j+=match[0].length-1;f=new m.Anonymous(match[1])}else f=name==="font"?a(this.font):a(this.value);k=a(this.important);if(f&&a(this.end))return new m.Rule(name,f,k,w);else{v=j;d()}}},"import":function(){var f;if(a(/^@import\s+/)&& +(f=a(this.entities.quoted)||a(this.entities.url))&&a(";"))return new m.Import(f,S)},directive:function(){var f,k,l;if(h.charAt(j)==="@")if(k=a(this["import"]))return k;else if(f=a(/^@media|@page/)){l=a(/^[^{]+/).trim();if(k=a(this.block))return new m.Directive(f+" "+l,k)}else if(f=a(/^@[-a-z]+/))if(f==="@font-face"){if(k=a(this.block))return new m.Directive(f,k)}else if((k=a(this.entity))&&a(";"))return new m.Directive(f,k)},font:function(){for(var f=[],k=[],l;l=a(this.shorthand)||a(this.entity);)k.push(l); +f.push(new m.Expression(k));if(a(","))for(;l=a(this.expression);){f.push(l);if(!a(","))break}return new m.Value(f)},value:function(){for(var f,k=[];f=a(this.expression);){k.push(f);if(!a(","))break}if(k.length>0)return new m.Value(k)},important:function(){if(h.charAt(j)==="!")return a(/^! *important/)},sub:function(){var f;if(a("(")&&(f=a(this.expression))&&a(")"))return f},multiplication:function(){var f,k,l,p;if(f=a(this.operand)){for(;(l=a("/")||a("*"))&&(k=a(this.operand));)p=new m.Operation(l, +[p||f,k]);return p||f}},addition:function(){var f,k,l,p;if(f=a(this.multiplication)){for(;(l=a(/^[-+]\s+/)||h.charAt(j-1)!=" "&&(a("+")||a("-")))&&(k=a(this.multiplication));)p=new m.Operation(l,[p||f,k]);return p||f}},operand:function(){return a(this.sub)||a(this.entities.dimension)||a(this.entities.color)||a(this.entities.variable)||a(this.entities.call)},expression:function(){for(var f,k=[];f=a(this.addition)||a(this.entity);)k.push(f);if(k.length>0)return new m.Expression(k)},property:function(){var f; +if(f=a(/^(\*?-?[-a-z_0-9]+)\s*:/))return f[1]}}}};if(typeof y!=="undefined")o.Parser.importer=function(e,b,d){if(e.charAt(0)!=="/"&&b.length>0)e=b[0]+e;X({href:e,title:e},d,true)};(function(e){function b(a){return e.functions.hsla(a.h,a.s,a.l,a.a)}function d(a){if(a instanceof e.Dimension)return parseFloat(a.unit=="%"?a.value/100:a.value);else if(typeof a==="number")return a;else throw{error:"RuntimeError",message:"color functions take numbers as parameters"};}function g(a){return Math.min(1,Math.max(0, +a))}e.functions={rgb:function(a,i,h){return this.rgba(a,i,h,1)},rgba:function(a,i,h,j){a=[a,i,h].map(function(n){return d(n)});j=d(j);return new e.Color(a,j)},hsl:function(a,i,h){return this.hsla(a,i,h,1)},hsla:function(a,i,h,j){function n(v){v=v<0?v+1:v>1?v-1:v;return v*6<1?w+(r-w)*v*6:v*2<1?r:v*3<2?w+(r-w)*(2/3-v)*6:w}a=d(a)%360/360;i=d(i);h=d(h);j=d(j);var r=h<=0.5?h*(i+1):h+i-h*i,w=h*2-r;return this.rgba(n(a+1/3)*255,n(a)*255,n(a-1/3)*255,j)},hue:function(a){return new e.Dimension(Math.round(a.toHSL().h))}, +saturation:function(a){return new e.Dimension(Math.round(a.toHSL().s*100),"%")},lightness:function(a){return new e.Dimension(Math.round(a.toHSL().l*100),"%")},alpha:function(a){return new e.Dimension(a.toHSL().a)},saturate:function(a,i){a=a.toHSL();a.s+=i.value/100;a.s=g(a.s);return b(a)},desaturate:function(a,i){a=a.toHSL();a.s-=i.value/100;a.s=g(a.s);return b(a)},lighten:function(a,i){a=a.toHSL();a.l+=i.value/100;a.l=g(a.l);return b(a)},darken:function(a,i){a=a.toHSL();a.l-=i.value/100;a.l=g(a.l); +return b(a)},spin:function(a,i){a=a.toHSL();i=(a.h+i.value)%360;a.h=i<0?360+i:i;return b(a)},greyscale:function(a){return this.desaturate(a,new e.Dimension(100))},e:function(a){return new e.Anonymous(a instanceof e.JavaScript?a.evaluated:a)},"%":function(a){for(var i=Array.prototype.slice.call(arguments,1),h=a.value,j=0;j<i.length;j++)h=h.replace(/%s/,i[j].value).replace(/%[da]/,i[j].toCSS());h=h.replace(/%%/g,"%");return new e.Quoted('"'+h+'"',h)}}})(q("less/tree"));(function(e){e.Alpha=function(b){this.value= +b};e.Alpha.prototype={toCSS:function(){return"alpha(opacity="+(this.value.toCSS?this.value.toCSS():this.value)+")"},eval:function(){return this}}})(q("less/tree"));(function(e){e.Anonymous=function(b){this.value=b.value||b};e.Anonymous.prototype={toCSS:function(){return this.value},eval:function(){return this}}})(q("less/tree"));(function(e){e.Call=function(b,d){this.name=b;this.args=d};e.Call.prototype={eval:function(b){var d=this.args.map(function(g){return g.eval(b)});return this.name in e.functions? +e.functions[this.name].apply(e.functions,d):new e.Anonymous(this.name+"("+d.map(function(g){return g.toCSS()}).join(", ")+")")},toCSS:function(b){return this.eval(b).toCSS()}}})(q("less/tree"));(function(e){e.Color=function(b,d){this.rgb=Array.isArray(b)?b:b.length==6?b.match(/.{2}/g).map(function(g){return parseInt(g,16)}):b.split("").map(function(g){return parseInt(g+g,16)});this.alpha=typeof d==="number"?d:1};e.Color.prototype={eval:function(){return this},toCSS:function(){return this.alpha<1? +"rgba("+this.rgb.map(function(b){return Math.round(b)}).concat(this.alpha).join(", ")+")":"#"+this.rgb.map(function(b){b=Math.round(b);b=(b>255?255:b<0?0:b).toString(16);return b.length===1?"0"+b:b}).join("")},operate:function(b,d){var g=[];d instanceof e.Color||(d=d.toColor());for(var a=0;a<3;a++)g[a]=e.operate(b,this.rgb[a],d.rgb[a]);return new e.Color(g)},toHSL:function(){var b=this.rgb[0]/255,d=this.rgb[1]/255,g=this.rgb[2]/255,a=this.alpha,i=Math.max(b,d,g),h=Math.min(b,d,g),j,n=(i+h)/2,r=i- +h;if(i===h)j=h=0;else{h=n>0.5?r/(2-i-h):r/(i+h);switch(i){case b:j=(d-g)/r+(d<g?6:0);break;case d:j=(g-b)/r+2;break;case g:j=(b-d)/r+4;break}j/=6}return{h:j*360,s:h,l:n,a:a}}}})(q("less/tree"));(function(e){e.Comment=function(b,d){this.value=b;this.silent=!!d};e.Comment.prototype={toCSS:function(b){return b.compress?"":this.value},eval:function(){return this}}})(q("less/tree"));(function(e){e.Dimension=function(b,d){this.value=parseFloat(b);this.unit=d||null};e.Dimension.prototype={eval:function(){return this}, +toColor:function(){return new e.Color([this.value,this.value,this.value])},toCSS:function(){return this.value+this.unit},operate:function(b,d){return new e.Dimension(e.operate(b,this.value,d.value),this.unit||d.unit)}}})(q("less/tree"));(function(e){e.Directive=function(b,d){this.name=b;if(Array.isArray(d))this.ruleset=new e.Ruleset([],d);else this.value=d};e.Directive.prototype={toCSS:function(b,d){if(this.ruleset){this.ruleset.root=true;return this.name+(d.compress?"{":" {\n ")+this.ruleset.toCSS(b, +d).trim().replace(/\n/g,"\n ")+(d.compress?"}":"\n}\n")}else return this.name+" "+this.value.toCSS()+";\n"},eval:function(b){b.frames.unshift(this);this.ruleset=this.ruleset&&this.ruleset.eval(b);b.frames.shift();return this},variable:function(b){return e.Ruleset.prototype.variable.call(this.ruleset,b)},find:function(){return e.Ruleset.prototype.find.apply(this.ruleset,arguments)},rulesets:function(){return e.Ruleset.prototype.rulesets.apply(this.ruleset)}}})(q("less/tree"));(function(e){e.Element= +function(b,d){this.combinator=b instanceof e.Combinator?b:new e.Combinator(b);this.value=d.trim()};e.Element.prototype.toCSS=function(b){return this.combinator.toCSS(b||{})+this.value};e.Combinator=function(b){this.value=b===" "?" ":b?b.trim():""};e.Combinator.prototype.toCSS=function(b){return{"":""," ":" ","&":"",":":" :","::":"::","+":b.compress?"+":" + ","~":b.compress?"~":" ~ ",">":b.compress?">":" > "}[this.value]}})(q("less/tree"));(function(e){e.Expression=function(b){this.value=b};e.Expression.prototype= +{eval:function(b){return this.value.length>1?new e.Expression(this.value.map(function(d){return d.eval(b)})):this.value[0].eval(b)},toCSS:function(b){return this.value.map(function(d){return d.toCSS(b)}).join(" ")}}})(q("less/tree"));(function(e){e.Import=function(b,d){var g=this;this._path=b;this.path=b instanceof e.Quoted?/\.(le?|c)ss$/.test(b.value)?b.value:b.value+".less":b.value.value||b.value;(this.css=/css$/.test(this.path))||d.push(this.path,function(a){if(!a)throw new Error("Error parsing "+ +g.path);g.root=a})};e.Import.prototype={toCSS:function(){return this.css?"@import "+this._path.toCSS()+";\n":""},eval:function(b){var d;if(this.css)return this;else{d=new e.Ruleset(null,this.root.rules.slice(0));for(var g=0;g<d.rules.length;g++)d.rules[g]instanceof e.Import&&Array.prototype.splice.apply(d.rules,[g,1].concat(d.rules[g].eval(b)));return d.rules}}}})(q("less/tree"));(function(e){e.JavaScript=function(b,d){this.expression=b;this.index=d};e.JavaScript.prototype={toCSS:function(){return JSON.stringify(this.evaluated)}, +eval:function(b){var d=new Function("return ("+this.expression+")"),g={};for(var a in b.frames[0].variables())g[a.slice(1)]={value:b.frames[0].variables()[a].value,toJS:function(){return this.value.eval(b).toCSS()}};try{this.evaluated=d.call(g)}catch(i){throw{message:"JavaScript evaluation error: '"+i.name+": "+i.message+"'",index:this.index};}return this}}})(q("less/tree"));(function(e){e.Keyword=function(b){this.value=b};e.Keyword.prototype={eval:function(){return this},toCSS:function(){return this.value}}})(q("less/tree")); +(function(e){e.mixin={};e.mixin.Call=function(b,d,g){this.selector=new e.Selector(b);this.arguments=d;this.index=g};e.mixin.Call.prototype={eval:function(b){for(var d,g=[],a=false,i=0;i<b.frames.length;i++)if((d=b.frames[i].find(this.selector)).length>0){for(i=0;i<d.length;i++)if(d[i].match(this.arguments,b))try{Array.prototype.push.apply(g,d[i].eval(b,this.arguments).rules);a=true}catch(h){throw{message:h.message,index:h.index,stack:h.stack,call:this.index};}if(a)return g;else throw{message:"No matching definition was found for `"+ +this.selector.toCSS().trim()+"("+this.arguments.map(function(j){return j.toCSS()}).join(", ")+")`",index:this.index};}throw{message:this.selector.toCSS().trim()+" is undefined",index:this.index};}};e.mixin.Definition=function(b,d,g){this.name=b;this.selectors=[new e.Selector([new e.Element(null,b)])];this.params=d;this.arity=d.length;this.rules=g;this._lookups={};this.required=d.reduce(function(a,i){return i.name&&!i.value?a+1:a},0);this.parent=e.Ruleset.prototype;this.frames=[]};e.mixin.Definition.prototype= +{toCSS:function(){return""},variable:function(b){return this.parent.variable.call(this,b)},variables:function(){return this.parent.variables.call(this)},find:function(){return this.parent.find.apply(this,arguments)},rulesets:function(){return this.parent.rulesets.apply(this)},eval:function(b,d){for(var g=new e.Ruleset(null,[]),a=0,i;a<this.params.length;a++)if(this.params[a].name)if(i=d&&d[a]||this.params[a].value)g.rules.unshift(new e.Rule(this.params[a].name,i.eval(b)));else throw{message:"wrong number of arguments for "+ +this.name+" ("+d.length+" for "+this.arity+")"};return(new e.Ruleset(null,this.rules.slice(0))).eval({frames:[this,g].concat(this.frames,b.frames)})},match:function(b,d){var g=b&&b.length||0;if(g<this.required)return false;g=Math.min(g,this.arity);for(var a=0;a<g;a++)if(!this.params[a].name)if(b[a].eval(d).toCSS()!=this.params[a].value.eval(d).toCSS())return false;return true}}})(q("less/tree"));(function(e){e.Operation=function(b,d){this.op=b.trim();this.operands=d};e.Operation.prototype.eval=function(b){var d= +this.operands[0].eval(b);b=this.operands[1].eval(b);var g;if(d instanceof e.Dimension&&b instanceof e.Color)if(this.op==="*"||this.op==="+"){g=b;b=d;d=g}else throw{name:"OperationError",message:"Can't substract or divide a color from a number"};return d.operate(this.op,b)};e.operate=function(b,d,g){switch(b){case "+":return d+g;case "-":return d-g;case "*":return d*g;case "/":return d/g}}})(q("less/tree"));(function(e){e.Quoted=function(b,d){this.value=d||"";this.quote=b.charAt(0)};e.Quoted.prototype= +{toCSS:function(){return this.quote+this.value+this.quote},eval:function(){return this}}})(q("less/tree"));(function(e){e.Rule=function(b,d,g,a){this.name=b;this.value=d instanceof e.Value?d:new e.Value([d]);this.important=g?" "+g.trim():"";this.index=a;this.variable=b.charAt(0)==="@"?true:false};e.Rule.prototype.toCSS=function(b){return this.variable?"":this.name+(b.compress?":":": ")+this.value.toCSS(b)+this.important+";"};e.Rule.prototype.eval=function(b){return new e.Rule(this.name,this.value.eval(b), +this.important,this.index)};e.Shorthand=function(b,d){this.a=b;this.b=d};e.Shorthand.prototype={toCSS:function(b){return this.a.toCSS(b)+"/"+this.b.toCSS(b)},eval:function(){return this}}})(q("less/tree"));(function(e){e.Ruleset=function(b,d){this.selectors=b;this.rules=d;this._lookups={}};e.Ruleset.prototype={eval:function(b){var d=new e.Ruleset(this.selectors,this.rules.slice(0));d.root=this.root;b.frames.unshift(d);if(d.root)for(var g=0;g<d.rules.length;g++)d.rules[g]instanceof e.Import&&Array.prototype.splice.apply(d.rules, +[g,1].concat(d.rules[g].eval(b)));for(g=0;g<d.rules.length;g++)if(d.rules[g]instanceof e.mixin.Definition)d.rules[g].frames=b.frames.slice(0);for(g=0;g<d.rules.length;g++)d.rules[g]instanceof e.mixin.Call&&Array.prototype.splice.apply(d.rules,[g,1].concat(d.rules[g].eval(b)));g=0;for(var a;g<d.rules.length;g++){a=d.rules[g];a instanceof e.mixin.Definition||(d.rules[g]=a.eval?a.eval(b):a)}b.frames.shift();return d},match:function(b){return!b||b.length===0},variables:function(){return this._variables? +this._variables:(this._variables=this.rules.reduce(function(b,d){if(d instanceof e.Rule&&d.variable===true)b[d.name]=d;return b},{}))},variable:function(b){return this.variables()[b]},rulesets:function(){return this._rulesets?this._rulesets:(this._rulesets=this.rules.filter(function(b){return b instanceof e.Ruleset||b instanceof e.mixin.Definition}))},find:function(b,d){d=d||this;var g=[],a=b.toCSS();if(a in this._lookups)return this._lookups[a];this.rulesets().forEach(function(i){if(i!==d)for(var h= +0;h<i.selectors.length;h++)if(b.match(i.selectors[h])){b.elements.length>1?Array.prototype.push.apply(g,i.find(new e.Selector(b.elements.slice(1)),d)):g.push(i);break}});return this._lookups[a]=g},toCSS:function(b,d){var g=[],a=[],i=[],h=[];if(!this.root)if(b.length===0)h=this.selectors.map(function(r){return[r]});else for(var j=0;j<this.selectors.length;j++)for(var n=0;n<b.length;n++)h.push(b[n].concat([this.selectors[j]]));for(j=0;j<this.rules.length;j++){b=this.rules[j];if(b.rules||b instanceof +e.Directive)i.push(b.toCSS(h,d));else if(b instanceof e.Comment)b.silent||(this.root?i.push(b.toCSS(d)):a.push(b.toCSS(d)));else if(b.toCSS&&!b.variable)a.push(b.toCSS(d));else b.value&&!b.variable&&a.push(b.value.toString())}i=i.join("");if(this.root)g.push(a.join(d.compress?"":"\n"));else if(a.length>0){h=h.map(function(r){return r.map(function(w){return w.toCSS(d)}).join("").trim()}).join(d.compress?",":h.length>3?",\n":", ");g.push(h,(d.compress?"{":" {\n ")+a.join(d.compress?"":"\n ")+(d.compress? +"}":"\n}\n"))}g.push(i);return g.join("")+(d.compress?"\n":"")}}})(q("less/tree"));(function(e){e.Selector=function(b){this.elements=b;if(this.elements[0].combinator.value==="")this.elements[0].combinator.value=" "};e.Selector.prototype.match=function(b){return this.elements[0].value===b.elements[0].value?true:false};e.Selector.prototype.toCSS=function(b){if(this._css)return this._css;return this._css=this.elements.map(function(d){return typeof d==="string"?" "+d.trim():d.toCSS(b)}).join("")}})(q("less/tree")); +(function(e){e.URL=function(b,d){if(!/^(?:https?:\/|file:\/)?\//.test(b.value)&&d.length>0&&typeof y!=="undefined")b.value=d[0]+(b.value.charAt(0)==="/"?b.value.slice(1):b.value);this.value=b;this.paths=d};e.URL.prototype={toCSS:function(){return"url("+this.value.toCSS()+")"},eval:function(b){return new e.URL(this.value.eval(b),this.paths)}}})(q("less/tree"));(function(e){e.Value=function(b){this.value=b;this.is="value"};e.Value.prototype={eval:function(b){return this.value.length===1?this.value[0].eval(b): +new e.Value(this.value.map(function(d){return d.eval(b)}))},toCSS:function(b){return this.value.map(function(d){return d.toCSS(b)}).join(b.compress?",":", ")}}})(q("less/tree"));(function(e){e.Variable=function(b,d){this.name=b;this.index=d};e.Variable.prototype={eval:function(b){var d,g,a=this.name;if(d=e.find(b.frames,function(i){if(g=i.variable(a))return g.value.eval(b)}))return d;else throw{message:"variable "+this.name+" is undefined",index:this.index};}}})(q("less/tree"));q("less/tree").find= +function(e,b){for(var d=0,g;d<e.length;d++)if(g=b.call(e,e[d]))return g;return null};var P=location.protocol==="file:"||location.protocol==="chrome:"||location.protocol==="resource:";o.env=o.env||location.hostname=="127.0.0.1"||location.hostname=="0.0.0.0"||location.hostname=="localhost"||location.port.length>0||P?"development":"production";o.async=false;o.poll=o.poll||(P?1E3:1500);o.watch=function(){return this.watchMode=true};o.unwatch=function(){return this.watchMode=false};if(o.env==="development"){o.optimization= +0;/!watch/.test(location.hash)&&o.watch();o.watchTimer=setInterval(function(){o.watchMode&&W(function(e,b,d){e&&N(e.toCSS(),b,d.lastModified)})},o.poll)}else o.optimization=3;var D;try{D=typeof y.localStorage==="undefined"?null:y.localStorage}catch(ca){D=null}var M=document.getElementsByTagName("link"),V=/^text\/(x-)?less$/;o.sheets=[];for(var J=0;J<M.length;J++)if(M[J].rel==="stylesheet/less"||M[J].rel.match(/stylesheet/)&&M[J].type.match(V))o.sheets.push(M[J]);o.refresh=function(e){var b=endTime= +new Date;W(function(d,g,a){if(a.local)I("loading "+g.href+" from cache.");else{I("parsed "+g.href+" successfully.");N(d.toCSS(),g,a.lastModified)}I("css for "+g.href+" generated in "+(new Date-endTime)+"ms");a.remaining===0&&I("css generated in "+(new Date-b)+"ms");endTime=new Date},e);U()};o.refreshStyles=U;o.refresh(o.env==="development")})(window); diff --git a/less/less.js b/less/less.js @@ -0,0 +1 @@ +less-1.0.35.min.js +\ No newline at end of file diff --git a/less/less.js.url b/less/less.js.url @@ -0,0 +1 @@ +http://github.com/cloudhead/less.js/tree/master/dist/ +\ No newline at end of file diff --git a/liens/index.php b/liens/index.php @@ -0,0 +1,7 @@ +<?php + +require_once(dirname(__FILE) . "/./../__cms__/cms.php"); + +CMS::page("/liens"); + +?> diff --git a/nouveautes/4/index.php b/nouveautes/4/index.php @@ -0,0 +1,7 @@ +<?php + +require_once(dirname(__FILE__) . "/./../../__cms__/cms.php"); + +CMS::page("/nouveautes/4"); + +?> +\ No newline at end of file diff --git a/nouveautes/5/index.php b/nouveautes/5/index.php @@ -0,0 +1,7 @@ +<?php + +require_once(dirname(__FILE__) . "/./../../__cms__/cms.php"); + +CMS::page("/nouveautes/5"); + +?> +\ No newline at end of file diff --git a/nouveautes/6/index.php b/nouveautes/6/index.php @@ -0,0 +1,7 @@ +<?php + +require_once(dirname(__FILE__) . "/./../../__cms__/cms.php"); + +CMS::page("/nouveautes/6"); + +?> +\ No newline at end of file diff --git a/nouveautes/Nouvel article/index.php b/nouveautes/Nouvel article/index.php @@ -0,0 +1,7 @@ +<?php + +require_once(dirname(__FILE__) . "/./../../__cms__/cms.php"); + +CMS::page("/nouveautes/Nouvel article"); + +?> diff --git a/permissions.sh b/permissions.sh @@ -1,6 +1,6 @@ #!/bin/sh -fichiers="index.php galerie forum articles nouveautes admin __cms__/donnees" +fichiers="index.php galerie forum nouveautes equipes liens contact admin __cms__/donnees" chgrp -R www-data $fichiers chmod -R 664 $fichiers diff --git a/test.less b/test.less @@ -0,0 +1,181 @@ +// TODO : dans galerie les images ne sont pas centrées verticalement dans leur boîte. + +@largeur-contenu: 63em; + +/* Couleurs principales */ +@base: #ffff00; +@base2: #ba7500; +@fg: #000000; +@bg: #ffffff; +@couleur-important: #ff0000; + +/* Couleurs dérivées */ +@softbase: (2*@base + @bg) / 3; +@softbase2: (4*@bg + @base) / 5; +@bodybg: @softbase2; +@demi: (@fg + @bg) / 2; + +.nospace { + margin: 0; + padding: 0; +} + +.lien-monochrome (@couleur: @fg) { + color: @couleur; + &:link {color: @couleur;} + &:visited {color: @couleur;} + &:hover {color: @couleur;} + &:active {color: @couleur;} +} + +a { + &:visited { + color: @base2; + } + &:hover, &:active { + color: (@base2 + @fg) / 2; + } +} + +body { + .nospace; + background-color: @bodybg; + color: @fg; +} + +h1 { + background-color: @softbase; // @softbase2 + border-bottom: thick solid @fg; + margin: 0 0 0.8em 0; + padding: 0.2em 1em; + a { + .lien-monochrome(@fg); + text-decoration: none; + } +} + +h2 { + margin-top: 0; + + input { + font-size: x-large; + font-weight: bold; + } +} + +.prochain-evenement { + color: @couleur-important; + background-color: (6*@bg + @couleur-important) / 7; + border: thick solid @couleur-important; + margin: 0 5em 1em; + padding: 1em; + text-align: center; +} + +.site { + &.connexion { + a { + .lien-monochrome(@fg); + } + position: absolute; + top: 0; + right: 0; + padding: 0.1em 0.2em; + } + + &.navigation { + background-color: @softbase; + border: thick solid @fg; + float: left; + padding: 0em 0em; + margin: 0 1em 1em; + text-align: center; + + ul { + .nospace; + } + li:hover { + background-color: @fg; + a { + color: @bg; + } + } + li { + border-bottom: thin solid @fg; + &:last-child { + border:none; + } + padding: 0.5em 1.5em; + list-style-type: none; + + } + a { + color: black; + } + } + + &.contenu { + max-width: @largeur-contenu; + float: left; + } +} + +.galerie { + &.infos { + border-bottom: thick solid @demi; + padding-bottom: 1em; + } + &.photos { + ul { + .nospace; + li { + list-style-type: none; + float: left; + margin: 1em; + padding: 0; + width: 9em; + text-align: center; + a { + .lien-monochrome; + display:block; + } + } + } + .miniature { + border: thin solid @demi; + display:block; + height: 70px; + img { + border: none; + } + } + li:hover { + .miniature { + border-color: (@base2)/2; + background-color: (@bg*3 + @base2)/4; + } + .titre { + color: @base2; + } + } + .titre { + display:block; + padding: 0.2em 0.4em; + height: 5em; + } + } +} + +.admin.permissions.regles { + width: 100%; +} + +.clearboth { + clear: both; +} + +textarea { + width: @largeur-contenu / 2; + margin: 1em 0; + /* font-size: large; */ /* Activer pour plus d'accessibilité. */ +}