Page title

Signed-off-by: bachy <git@g-u-i.net>
This commit is contained in:
bachy 2012-11-09 11:51:55 +01:00
parent b1bf1c9387
commit 948913bc82
12 changed files with 178 additions and 25 deletions

File diff suppressed because one or more lines are too long

27
js/materio_page_title.js Normal file
View File

@ -0,0 +1,27 @@
// @codekit-prepend "gui.js"
(function($) {
MaterioPageTitle = function(){
function init(){
$(document).bind('materio-page-title-refresh-block', onRefreshBlock);
};
function onRefreshBlock(event){
trace('onRefreshBlock', event);
// var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materio_page_title/refresh/block';
// $.getJSON(url, function(json){
// trace('page title json', json);
// $('#block-materio-page-title-materio-page-title').replaceWith(json.block);
// });
if(typeof event.title !== 'undefined')
$('#block-materio-page-title-materio-page-title h1').html(event.title);
};
init();
};
var materiopagetitle = new MaterioPageTitle();
})(jQuery);

File diff suppressed because one or more lines are too long

View File

@ -36,7 +36,7 @@ MaterioSearchApiAjax = function(){
$("#edit-searchfield").bind('autocompleteSelect', function(event) {
$(this).parents('.form').trigger('submit');
});
$(document)
.bind('init-scroller-pager', onInitScrollerPager)
.bind('load-scroller-pager', onLoadScrollerPager)
@ -44,17 +44,17 @@ MaterioSearchApiAjax = function(){
.bind('history-state-change', onHistoryStateChange);
// trigger updated event for direct html loading
setTimeout(function(){
var event = jQuery.Event('resultschanged');
if(isExplore())
event.container = '#content .search-results';
setTimeout(function(){
var event = jQuery.Event('resultschanged');
if(isExplore())
event.container = '#content .search-results';
if(isActuality())
event.container = '#content .actuality-items';
if(isActuality())
event.container = '#content .actuality-items';
$.event.trigger(event);
}, 10);
$.event.trigger(event);
}, 10);
};
@ -95,7 +95,7 @@ MaterioSearchApiAjax = function(){
var event = jQuery.Event('new-history-page');
event.path = path;
event.title = json.keys;
event.title = json.title;
event.content = json.return;
$.event.trigger(event);
@ -130,6 +130,7 @@ MaterioSearchApiAjax = function(){
};
function changeContent(json){
trace('MaterioSearchApiAjax changeContent | json', json);
if(json.return){
$.event.trigger('loaded-content');
$('.inner-content',_$content).html(json.return);
@ -142,6 +143,7 @@ MaterioSearchApiAjax = function(){
function triggerContentChanged(){
var event = jQuery.Event('resultschanged');
event.container = '#content .search-results, #content .actuality-items';
// event.title = json.title;
$.event.trigger(event);
};
@ -230,8 +232,8 @@ MaterioSearchApiAjax = function(){
if (json.statut == "saved"){
// loadResults(getSearchKeys());
$.event.trigger('view-mode-changed');
$('.viewmode-link').removeClass('active');
$btn.addClass('active');
$('.viewmode-link, .viewmode-link i').removeClass('active');
$btn.addClass('active').find('i').addClass('active');
}
});

View File

@ -207,14 +207,15 @@ function materio_flag_entity_info_alter(&$entity_info) {
*/
function materio_flag_entity_view($entity, $type, $view_mode, $langcode) {
if($type == 'node'){
if(user_access('create flag lists')){
$flaglists_links = materio_flag_get_entity_links($entity, $type, $view_mode);
// dsm($flaglists_links, 'flaglists_links');
$flaglists_links = materio_flag_get_entity_links($entity, $type, $view_mode);
// dsm($flaglists_links, 'flaglists_links');
$entity->content['links']['flaglistslinks'] = array('#markup' => $flaglists_links,"#html"=>true);
$entity->content['links']['flaglistslinks'] = array('#markup' => $flaglists_links,"#html"=>true);
drupal_add_css(drupal_get_path('module', 'flag') . '/theme/flag.css');
drupal_add_js(drupal_get_path('module', 'flag') . '/theme/flag.js');
drupal_add_css(drupal_get_path('module', 'flag') . '/theme/flag.css');
drupal_add_js(drupal_get_path('module', 'flag') . '/theme/flag.js');
}
}
}

View File

@ -151,6 +151,8 @@ function materio_flag_user_lists($fid){
$flag = flag_lists_get_flag($fid);
// dsm($flag, 'flag');
drupal_set_title('<i class="icon-materio-folder"></i>'.check_plain($flag->title), PASS_THROUGH);
$flaged_content = flag_lists_get_flagged_content($fid, $user->uid);
// dsm($flaged_content, 'flaged_content');
@ -222,7 +224,7 @@ function materio_flag_ajax_list($fid, $page = 0){
$rep = array(
'return' => $return,
'path' => $path,
'title' => 'folder',
'title' => drupal_get_title(),
);
if ($debug) {

23
materio_page_title.info Normal file
View File

@ -0,0 +1,23 @@
name = Materio Page Title
description = "Provide a block with the current page title, and the ajax api to refresh it"
; Core version (required)
core = 7.x
; Package name (see http://drupal.org/node/542202 for a list of names)
package = Materio
; PHP version requirement (optional)
; php = 5.2
; Loadable code files
files[] = materio_page_title.module
; Module dependencies
; dependencies[] = materio_search_api
; Configuration page
; configure = admin/config/materio_search_api_ajax
; For further information about configuration options, see
; - http://drupal.org/node/542202

76
materio_page_title.module Normal file
View File

@ -0,0 +1,76 @@
<?php
/**
* Implements hook_block_info().
*/
function materio_page_title_block_info() {
// This example comes from node.module.
/*
*$blocks['syndicate'] = array(
* 'info' => t('Syndicate'),
* 'cache' => DRUPAL_NO_CACHE
*);
*/
$blocks['materio_page_title'] = array(
'info' => t('Materio page title'),
'cache' => DRUPAL_NO_CACHE
);
return $blocks;
}
/**
* Implements hook_block_view().
*/
function materio_page_title_block_view($delta = '') {
$block = array();
switch ($delta) {
case 'materio_page_title':
$block['subject'] = t('Page title');
$block['content'] = theme('materio_page_title', array('title' => drupal_get_title()));
drupal_add_js(drupal_get_path('module', 'materio_page_title').'/js/materio_page_title-ck.js');
break;
}
return $block;
}
/**
* Implements hook_theme().
*/
function materio_page_title_theme($existing, $type, $theme, $path) {
return array(
'materio_page_title' => array(
'variables' => array('title' => NULL,),
),
);
}
function theme_materio_page_title($vars){
if($vars['title'])
return '<h1 id="materio-page-title" class="page-title">'.$vars['title'].'</h1>';
return;
}
/**
* Implements hook_menu().
*/
// function materio_page_title_menu() {
// $items = array();
// $base = array(
// 'type' => MENU_CALLBACK,
// 'file' => 'materio_page_title.pages.inc',
// );
// $items['materio_page_title/refresh/block'] = $base+array(
// 'title' => 'Materio page title refresh block',
// 'page callback' => 'materio_page_title_refresh_block',
// 'page arguments' => array(),
// 'access callback' => TRUE,
// );
// return $items;
// }

View File

@ -0,0 +1,14 @@
<?php
// function materio_page_title_refresh_block(){
// $block = block_load('materio_page_title', 'materio_page_title');
// $block_content = _block_render_blocks(array($block));
// $build = _block_get_renderable_array($block_content);
// $block_rendered = drupal_render($build);
// $rep['block'] = $block_rendered;
// drupal_json_output($rep);
// }

View File

@ -258,7 +258,7 @@ function materio_search_api_search_form($form, &$form_state){
'#type'=>'checkboxes',
'#options' => $bundles_options,
'#default_value' => $user_bundles_filter,
'#attributes' => array('class'=>array('btn-group')),
// '#attributes' => array('class'=>array('btn-group')),
);
}
@ -421,7 +421,7 @@ function template_preprocess_materio_search_api_select_viewmode_block(&$vars){
foreach ($entity_infos['node']['view modes'] as $viewmode => $value) {
if(in_array($viewmode, $availableviewmodes)){
$link = l(
'<span class="inner">'.$value['label'].'</span>',
'<i class="icon-materio-viewmode-'.$viewmode.($active == $viewmode ? " active" : '').'"></i><span class="inner">'.$value['label'].'</span>',
'materiosearchapi/viewmode/change/'.$viewmode,
array(
'query' => drupal_get_destination(),

View File

@ -144,7 +144,7 @@ function materio_search_api_results_search(){
foreach ($words[0] as $word) {
// $word = preg_replace('/\b-/', '\-', trim($word));
// dsm($word);
$keys[] = $word;
$keys[] = trim($word);
}
$index_machine_name = variable_get('mainsearchindex', -1);
@ -224,6 +224,7 @@ function materio_search_api_results_search(){
$ret['results']['#view_mode'] = $viewmode;
$ret['results']['#keys'] = $keys;
drupal_set_title('<i class="icon-materio-search"></i>'.check_plain($typed), PASS_THROUGH);
// Load pager.
// if ($results['result count'] > $page->options['per_page']) {
@ -305,7 +306,7 @@ function materio_search_api_actuality(){
}
}
drupal_set_title(t('Actualities'));
return theme('materio_search_api_actuality', array(
'items' => $items,

View File

@ -73,6 +73,7 @@ function materio_search_api_ajax_search($keys, $page = 0){
'search_path'=>$search_path,
'return'=>$return,
'active_types'=>$active_types,
'title' => drupal_get_title(),
);
if ($debug) {
@ -146,6 +147,7 @@ function materio_search_api_ajax_actuality($page = 0){
$rep = array(
'return'=>$return,
'title' => drupal_get_title(),
);
if ($debug) {