From 811215c4855d6698324e33f981db8d9a7eb8db46 Mon Sep 17 00:00:00 2001 From: ben Date: Mon, 6 Oct 2008 12:37:31 +0000 Subject: Elgg Javascript now goes through the views system git-svn-id: https://code.elgg.org/elgg/trunk@2185 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/elgglib.php | 14 ++ views/default/js/friendsPickerv1.php | 94 ++++++++++++ views/default/js/initialise_elgg.php | 253 +++++++++++++++++++++++++++++++++ views/default/page_elements/header.php | 4 +- 4 files changed, 363 insertions(+), 2 deletions(-) create mode 100644 views/default/js/friendsPickerv1.php create mode 100644 views/default/js/initialise_elgg.php diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 0d2b1e073..17766053c 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -1827,6 +1827,18 @@ } + function js_page_handler($page) { + + if (is_array($page) && sizeof($page)) { + header('Content-type: text/javascript'); + $js = str_replace('.js','',$page[0]); + echo elgg_view('js/' . $js); + + exit; + } + + } + function elgg_init() { // Important actions register_action('comments/add'); @@ -1834,6 +1846,8 @@ // Menu global $CONFIG; add_menu(elgg_echo('content:latest'), $CONFIG->wwwroot . 'dashboard/latest.php'); + // Page handler for JS + register_page_handler('js','js_page_handler'); } register_elgg_event_handler('init','system','elgg_init'); diff --git a/views/default/js/friendsPickerv1.php b/views/default/js/friendsPickerv1.php new file mode 100644 index 000000000..73e98af15 --- /dev/null +++ b/views/default/js/friendsPickerv1.php @@ -0,0 +1,94 @@ +/* + elgg friendsPicker plugin + + adapted from Niall Doherty's excellent Coda-Slider - http://www.ndoherty.com/coda-slider +*/ + + +jQuery.fn.friendsPicker = function(iterator) { + + var settings; + settings = $.extend({ easeFunc: "easeOutExpo", easeTime: 1000, toolTip: false }, settings); + + return this.each(function() { + + var container = $(this); + container.addClass("friendsPicker"); + // set panelwidth manually as it's hidden initially + var panelWidth = 685; + + // count the panels in the container + var panelCount = container.find("div.panel").size(); + // calculate the width of all the panels lined up end-to-end + var friendsPicker_containerWidth = panelWidth*panelCount; + // specify width for the friendsPicker_container + container.find("div.friendsPicker_container").css("width" , friendsPicker_containerWidth); + + // global variables for container.each function below + var friendsPickerNavigationWidth = 0; + var currentPanel = 1; + + // generate appropriate nav for each container + container.each(function(i) { + // generate Left and Right arrows + $(this).before("
Left<\/div>"); + $(this).after("
Right<\/div>"); + + // generate a-z tabs + $(this).before("