Changeset 59686 in spip-zone
- Timestamp:
- Mar 24, 2012, 4:47:28 PM (9 years ago)
- Location:
- _plugins_/ajax_nav
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
_plugins_/ajax_nav/ajax_nav.js
r58817 r59686 7 7 function AjaxNav() { 8 8 "use strict"; 9 var onAjaxNavReq = $.Event("onAjaxNavReq"), 10 onAjaxNavLoad = $.Event("onAjaxNavLoad"), 11 onAjaxNavLocalisedLoad = $.Event("onAjaxNavLocalisedLoad"), 12 HOST = History.getState().url.replace(/^https?:\/\/([^\/]+).*$/, '$1'); 9 10 var HOST = History.getState().url.replace(/^https?:\/\/([^\/]+).*$/, '$1'); 13 11 14 12 function addUrlParam(url, param, value) { … … 75 73 /////////////////////// 76 74 75 /* met a jour un element, l'evenement onDone sera declanche une fois le travail fini */ 76 function updateElement (element, onDone) { 77 $(element).data('ready', false) 78 .bind('ajaxNavReady', function () { 79 $(element).data('ready', true); 80 }); 81 $(element).trigger('onAjaxNavReq'); 82 $.get(addUrlParam(History.getState().url, 'getbyid', element.id), 83 function (data) { 84 var self = this, 85 id = this.url.replace(/.*getbyid=/, ''), 86 updateElFunc = function () { 87 $('#' + id) 88 .empty() 89 .html(data) 90 .trigger(onDone); 91 prepareForAjax('#' + id); 92 $(self).unbind('ajaxNavReady'); 93 }; 94 if (AjaxNav.options.autoReplaceDivs || $('#' + id).data('ready')) { 95 updateElFunc.call(); 96 } else { 97 $('#' + id).bind('ajaxNavReady', updateElFunc); 98 } 99 }); 100 } 101 77 102 // charge la page en ajax a chaque evenement statechange 78 103 $(window).bind('statechange', function() { … … 94 119 $('html').attr('lang', data.lang); 95 120 $('.loc_div').each(function (i) { 96 $(this).trigger(onAjaxNavReq); 97 $.get(addUrlParam(History.getState().url, 'getbyid', this.id), 98 function (data) { 99 var id = this.url.replace(/.*getbyid=/, ''); 100 $('#' + id).empty().html(data).trigger(onAjaxNavLocalisedLoad); 101 prepareForAjax('#' + id); 102 }); 121 updateElement(this, 'onAjaxNavLocalisedLoad'); 103 122 }); 104 123 } 105 124 // on recharge ensuite les elements 'ajax_nav'. 106 $('.ajax_nav').trigger(onAjaxNavReq);107 125 $('.ajax_nav').each(function (i) { 108 $.get(addUrlParam(History.getState().url, 'getbyid', this.id), 109 function (data) { 110 var id = this.url.replace(/.*getbyid=/, ''); 111 $('#' + id).empty().html(data).trigger(onAjaxNavLoad); 112 prepareForAjax('#' + id); 113 }); 126 updateElement(this, 'onAjaxNavLoad'); 114 127 }); 115 128 // comme spip utilise les class sur le body par defaut, il vaut mieux les mettre -
_plugins_/ajax_nav/ajax_nav_balises.php
r58261 r59686 90 90 $title = $title->html(); 91 91 92 $lang = pq('html'); 93 $lang = $lang->attr('lang'); 94 92 95 $tableau_resultat = serialize(array('body_classes' => $bodyClass, 93 'title' => $title, 94 )); 96 'title' => $title, 97 'lang' => $lang, 98 )); 95 99 96 100 return "$tableau_resultat"; -
_plugins_/ajax_nav/ajax_nav_insert_head.php
r58261 r59686 2 2 function ajax_nav_insert_head($flux) { 3 3 4 $options = unserialize($GLOBALS['meta']['ajax_nav_config']); 4 $res = sql_select('valeur', 'spip_meta', 'nom="ajax_nav_config"'); 5 $options = array(); 6 if (sql_count($res) == 1) { 7 $options = sql_fetch($res); 8 $options = unserialize($options['valeur']); 5 9 6 function prepare($options) { 7 $options = preg_replace("/[^a-zA-Z0-9\-\_]+/", "', ", $options); 8 $options = preg_replace("/([a-zA-Z0-9\-\_]+)/", "'$1", $options); 9 $options = preg_replace("/([^'])$/", "$1'", $options); 10 return $options; 10 /* evite les problemes lors de mises a jour du plugin */ 11 if ( ! $options['autoReplaceDivs'] ) { 12 $options['autoReplaceDivs'] = 'on'; 13 } 14 } 15 16 function prepare($option) { 17 $option = preg_replace("/[^a-zA-Z0-9\-\_]+/", "', ", $option); 18 $option = preg_replace("/([a-zA-Z0-9\-\_]+)/", "'$1", $option); 19 $option = preg_replace("/([^'])$/", "$1'", $option); 20 return $option; 11 21 } 12 22 … … 20 30 $flux .= "<script type='text/javascript' src='" . find_in_path("lib/modernizr.js") . "'></script>"; 21 31 } 32 33 $auto_replace_divs = ($options["autoReplaceDivs"] == "on") ? 'true' : 'false'; 22 34 23 35 $flux .= "<script type='text/javascript'> … … 42 54 pagesToAjaxify: [" . prepare($options["pagesToAjaxify"]) . "], 43 55 ajaxDivs: [" . prepare($options["ajaxDivs"]) . "], 44 localizedDivs: [" . prepare($options["localizedDivs"]) . "] 56 localizedDivs: [" . prepare($options["localizedDivs"]) . "], 57 autoReplaceDivs: " . $auto_replace_divs . " 45 58 }; 46 59 AjaxNav(); -
_plugins_/ajax_nav/formulaires/ajax_nav_config.html
r58261 r59686 33 33 label="cocher pour activer"[(#ENV{useHistoryLib}|=={on}|?{ checked="checked",})] /> 34 34 </li> 35 36 <li> 37 <strong><:ajax_nav:auto_replace_divs:></strong> 38 <input id="champ_autoReplaceDivs" class="checkbox" type="checkbox" name="autoReplaceDivs" 39 label="cocher pour activer"[(#ENV{autoReplaceDivs}|=={on}|?{ checked="checked",})] /> 40 </li> 35 41 36 42 </ul> -
_plugins_/ajax_nav/formulaires/ajax_nav_config.php
r58261 r59686 7 7 $options = sql_fetch($res); 8 8 $options = unserialize($options['valeur']); 9 10 /* evite les problemes lors de mises a jour du plugin */ 11 if ( ! $options['autoReplaceDivs'] ) { 12 $options['autoReplaceDivs'] = 'on'; 13 } 14 9 15 return $options; 10 16 } … … 23 29 "useModernLib" => "on", 24 30 /* Utilise la lib history.js fournie avec le plug */ 25 "useHistoryLib" => "on", 31 "useHistoryLib" => "on", 32 /* Remplace les divs automatiquement */ 33 "autoReplaceDivs" => "on", 26 34 ); 27 35 return $options; … … 56 64 'useModernLib' => _request('useModernLib'), 57 65 'useHistoryLib' => _request('useHistoryLib'), 66 'autoReplaceDivs' => _request('autoReplaceDivs'), 58 67 ); 59 68 -
_plugins_/ajax_nav/getinfos.html
r58261 r59686 9 9 "page":"#GET{objet}", 10 10 ["id_#GET{objet}":"(#GET{id_objet})",] 11 "lang":" #LANG",11 "lang":"[(#GET{infos_page}|table_valeur{lang})]", 12 12 "body_classes":"[(#GET{infos_page}|table_valeur{body_classes})]", 13 13 "title":"[(#GET{infos_page}|table_valeur{title})]" -
_plugins_/ajax_nav/lang/ajax_nav_en.php
r58261 r59686 15 15 'use_modern_lib' => 'Use the provided Modernizr library : ', 16 16 'use_history_lib' => 'Use the provided History.js library : ', 17 'auto_replace_divs' => 'Automatically replace the divs.', 17 18 ); 18 19 -
_plugins_/ajax_nav/lang/ajax_nav_fr.php
r58261 r59686 15 15 'use_modern_lib' => 'Utiliser la librairie Modernizr fournie avec le plugin : ', 16 16 'use_history_lib' => 'Utiliser la libraire History.js fournie avec le plugin : ', 17 'auto_replace_divs' => 'Remplacer les divs automatiquement : ', 17 18 ); 18 19
Note: See TracChangeset
for help on using the changeset viewer.