diff options
Diffstat (limited to 'views/default/js')
| -rw-r--r-- | views/default/js/admin.php | 126 | ||||
| -rw-r--r-- | views/default/js/elgg.php | 77 | ||||
| -rw-r--r-- | views/default/js/friendsPickerv1.php | 93 | ||||
| -rw-r--r-- | views/default/js/initialise_elgg.php | 299 | ||||
| -rw-r--r-- | views/default/js/initialize_elgg.php | 52 | ||||
| -rw-r--r-- | views/default/js/languages.php | 33 | ||||
| -rw-r--r-- | views/default/js/languages/en.php | 2 | ||||
| -rw-r--r-- | views/default/js/lightbox.php | 36 | ||||
| -rw-r--r-- | views/default/js/walled_garden.php | 67 |
9 files changed, 397 insertions, 388 deletions
diff --git a/views/default/js/admin.php b/views/default/js/admin.php new file mode 100644 index 000000000..e8aa0d2ed --- /dev/null +++ b/views/default/js/admin.php @@ -0,0 +1,126 @@ +<?php +/** + * Admin-area specific javascript functions. + * + * @since 1.8 + */ + +if (0) { ?><script><?php } +?> +elgg.provide('elgg.admin'); + +elgg.admin.init = function () { + + // system messages do not fade in admin area, instead slide up when clicked + $('.elgg-system-messages li').stop(true); + $('.elgg-system-messages li').die('click'); + $('.elgg-system-messages li').live('click', function() { + $(this).stop().slideUp('medium'); + }); + + // draggable plugin reordering + $('#elgg-plugin-list > ul').sortable({ + items: 'li:has(> .elgg-state-draggable)', + handle: '.elgg-head', + forcePlaceholderSize: true, + placeholder: 'elgg-widget-placeholder', + opacity: 0.8, + revert: 500, + stop: elgg.admin.movePlugin + }); + + // in-line editing for custom profile fields. + // @note this requires jquery.jeditable plugin + $(".elgg-state-editable").editable(elgg.admin.editProfileField, { + type: 'text', + onblur: 'submit', + width: '300px', + height: 'none', + style: 'display:inline;' + }); + + // draggable profile field reordering. + $('#elgg-profile-fields').sortable({ + items: 'li', + handle: 'span.elgg-state-draggable', + stop: elgg.admin.moveProfileField + }); + + // admin notices delete ajax + $('a.elgg-admin-notice').click(elgg.admin.deleteNotice); +}; + +/** + * Save the plugin order after a move event. + * + * @param {Object} e Event object. + * @param {Object} ui jQueryUI object + * @return void + */ +elgg.admin.movePlugin = function(e, ui) { + // get guid from id like elgg-object-<guid> + var pluginGuid = ui.item.attr('id'); + pluginGuid = pluginGuid.replace('elgg-object-', ''); + + elgg.action('admin/plugins/set_priority', { + data: { + plugin_guid: pluginGuid, + // we start at priority 1 + priority: ui.item.index() + 1 + } + }); +}; + +/** + * In-line editing for custom profile fields + * + * @param string value The new value + * @param {Object} settings The settings used for editable + * @return void + */ +elgg.admin.editProfileField = function(value, settings) { + var id = $(this).attr('id'); + id = id.replace('elgg-profile-field-', ''); + + var data = { + id: id, + label: value + }; + + elgg.action('profile/fields/edit', data); + return value; +}; + +/** + * Save the plugin profile order after a move event. + * + * @param {Object} e Event object. + * @param {Object} ui jQueryUI object + * @return void + */ +elgg.admin.moveProfileField = function(e, ui) { + var orderArr = $('#elgg-profile-fields').sortable('toArray'); + var orderStr = orderArr.join(','); + + elgg.action('profile/fields/reorder', { + fieldorder: orderStr + }); +}; + +/** + * Fires the ajax action to delete the admin notice then hides the notice. + * + * @return void + */ +elgg.admin.deleteNotice = function(e) { + e.preventDefault(); + var $container = $(this).closest('p'); + + elgg.action($(this).attr('href'), { + success: function(json) { + $container.slideUp('medium'); + } + }); +}; + +elgg.register_hook_handler('init', 'system', elgg.admin.init, 1000);
\ No newline at end of file diff --git a/views/default/js/elgg.php b/views/default/js/elgg.php new file mode 100644 index 000000000..c3b56e398 --- /dev/null +++ b/views/default/js/elgg.php @@ -0,0 +1,77 @@ +<?php +/** + * Core Elgg javascript loader + */ +global $CONFIG; + +$prereq_files = array( + "vendors/sprintf.js", + "js/lib/elgglib.js", +); + +foreach ($prereq_files as $file) { + include("{$CONFIG->path}$file"); +} + +//No such thing as autoloading classes in javascript +$model_files = array( + 'ElggEntity', + 'ElggUser', + 'ElggPriorityList', +); + +foreach ($model_files as $file) { + include("{$CONFIG->path}js/classes/$file.js"); +} + +//Include library files +$libs = array( + //libraries + 'prototypes', + 'hooks', + 'security', + 'languages', + 'ajax', + 'session', + 'pageowner', + 'configuration', + + //ui + 'ui', + 'ui.widgets', +); + +foreach ($libs as $file) { + include("{$CONFIG->path}js/lib/$file.js"); + // putting a new line between the files to address https://github.com/elgg/elgg/issues/3081 + echo "\n"; +} + +/** + * Set some values that are cacheable + */ +if (0) { ?><script><?php } +?> + +elgg.version = '<?php echo get_version(); ?>'; +elgg.release = '<?php echo get_version(true); ?>'; +elgg.config.wwwroot = '<?php echo elgg_get_site_url(); ?>'; +<?php //@todo make this configurable ?> +elgg.security.interval = 5 * 60 * 1000; +elgg.config.domReady = false; +elgg.config.language = '<?php echo isset($CONFIG->language) ? $CONFIG->language : 'en'; ?>'; +elgg.config.languageReady = false; + +//After the DOM is ready +$(function() { + elgg.config.domReady = true; + elgg.initWhenReady(); +}); + +<?php + +$previous_content = elgg_view('js/initialise_elgg'); +if ($previous_content) { + elgg_deprecated_notice("The view 'js/initialise_elgg' has been deprecated for js/elgg", 1.8); + echo $previous_content; +} diff --git a/views/default/js/friendsPickerv1.php b/views/default/js/friendsPickerv1.php deleted file mode 100644 index d399b35da..000000000 --- a/views/default/js/friendsPickerv1.php +++ /dev/null @@ -1,93 +0,0 @@ -/*
- 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 - adjust this value for different themes/pagewidths
- var panelWidth = 678;
-
- // 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("<div class='friendsPickerNavigationL' id='friendsPickerNavigationL" + iterator + "'><a href='#'>Left</a><\/div>");
- $(this).after("<div class='friendsPickerNavigationR' id='friendsPickerNavigationR" + iterator + "'><a href='#'>Right</a><\/div>");
-
- // generate a-z tabs
- $(this).before("<div class='friendsPickerNavigation' id='friendsPickerNavigation" + iterator + "'><ul><\/ul><\/div>");
- $(this).find("div.panel").each(function(individualTabItemNumber) {
- $("div#friendsPickerNavigation" + iterator + " ul").append("<li class='tab" + (individualTabItemNumber+1) + "'><a href='#" + (individualTabItemNumber+1) + "'>" + $(this).attr("title") + "<\/a><\/li>");
- });
-
- // tabs navigation
- $("div#friendsPickerNavigation" + iterator + " a").each(function(individualTabItemNumber) {
- // calc friendsPickerNavigationWidth by summing width of each li
- friendsPickerNavigationWidth += $(this).parent().width();
- // set-up individual tab clicks
- $(this).bind("click", function() {
- $(this).addClass("current").parent().parent().find("a").not($(this)).removeClass("current");
- var distanceToMoveFriendsPicker_container = - (panelWidth*individualTabItemNumber);
- currentPanel = individualTabItemNumber + 1;
- $(this).parent().parent().parent().next().find("div.friendsPicker_container").animate({ left: distanceToMoveFriendsPicker_container}, settings.easeTime, settings.easeFunc);
- });
- });
-
- // Right arow click function
- $("div#friendsPickerNavigationR" + iterator + " a").click(function() {
- if (currentPanel == panelCount) {
- var distanceToMoveFriendsPicker_container = 0;
- currentPanel = 1;
- $(this).parent().parent().find("div.friendsPickerNavigation a.current").removeClass("current").parent().parent().find("a:eq(0)").addClass("current");
- } else {
- var distanceToMoveFriendsPicker_container = - (panelWidth*currentPanel);
- currentPanel += 1;
- $(this).parent().parent().find("div.friendsPickerNavigation a.current").removeClass("current").parent().next().find("a").addClass("current");
- };
- $(this).parent().parent().find("div.friendsPicker_container").animate({ left: distanceToMoveFriendsPicker_container}, settings.easeTime, settings.easeFunc);
- return false;
- });
-
- // Left arrow click function
- $("div#friendsPickerNavigationL" + iterator + " a").click(function() {
- if (currentPanel == 1) {
- var distanceToMoveFriendsPicker_container = - (panelWidth*(panelCount - 1));
- currentPanel = panelCount;
- $(this).parent().parent().find("div.friendsPickerNavigation a.current").removeClass("current").parent().parent().find("li:last a").addClass("current");
- } else {
- currentPanel -= 1;
- var distanceToMoveFriendsPicker_container = - (panelWidth*(currentPanel - 1));
- $(this).parent().parent().find("div.friendsPickerNavigation a.current").removeClass("current").parent().prev().find("a").addClass("current");
- };
- $(this).parent().parent().find("div.friendsPicker_container").animate({ left: distanceToMoveFriendsPicker_container}, settings.easeTime, settings.easeFunc);
- return false;
- });
-
- // apply 'current' class to currently selected tab link
- $("div#friendsPickerNavigation" + iterator + " a:eq(0)").addClass("current");
- });
-
- $("div#friendsPickerNavigation" + iterator).append("<br />");
- });
-};
-
-
diff --git a/views/default/js/initialise_elgg.php b/views/default/js/initialise_elgg.php index 78cf9388d..3d617953a 100644 --- a/views/default/js/initialise_elgg.php +++ b/views/default/js/initialise_elgg.php @@ -1,295 +1,4 @@ -$(document).ready(function () {
-
- // COLLAPSABLE WIDGETS (on Dashboard & Profile pages)
- // toggle widget box contents
- $('a.toggle_box_contents').bind('click', toggleContent);
-
- // toggle widget box edit panel
- $('a.toggle_box_edit_panel').click(function () {
- $(this.parentNode.parentNode).children("[class=collapsable_box_editpanel]").slideToggle("fast");
- return false;
- });
-
- // toggle customise edit panel
- $('a.toggle_customise_edit_panel').click(function () {
- $('div#customise_editpanel').slideToggle("fast");
- return false;
- });
-
- // toggle plugin's settings nad more info on admin tools admin
- $('a.pluginsettings_link').click(function () {
- $(this.parentNode.parentNode).children("[class=pluginsettings]").slideToggle("fast");
- return false;
- });
- $('a.manifest_details').click(function () {
- $(this.parentNode.parentNode).children("[class=manifest_file]").slideToggle("fast");
- return false;
- });
- // reusable generic hidden panel
- $('a.collapsibleboxlink').click(function () {
- $(this.parentNode.parentNode).children("[class=collapsible_box]").slideToggle("fast");
- return false;
- });
-
- // WIDGET GALLERY EDIT PANEL
- // Sortable widgets
- var els = ['#leftcolumn_widgets', '#middlecolumn_widgets', '#rightcolumn_widgets', '#widget_picker_gallery' ];
- var $els = $(els.toString());
-
- $els.sortable({
- items: '.draggable_widget',
- handle: '.drag_handle',
- cursor: 'move',
- revert: true,
- opacity: 1.0,
- appendTo: 'body',
- placeholder: 'placeholder',
- connectWith: els,
- start:function(e,ui) {
-
- },
- stop: function(e,ui) {
- // refresh list before updating hidden fields with new widget order
- $(this).sortable( "refresh" );
-
- var widgetNamesLeft = outputWidgetList('#leftcolumn_widgets');
- var widgetNamesMiddle = outputWidgetList('#middlecolumn_widgets');
- var widgetNamesRight = outputWidgetList('#rightcolumn_widgets');
-
- document.getElementById('debugField1').value = widgetNamesLeft;
- document.getElementById('debugField2').value = widgetNamesMiddle;
- document.getElementById('debugField3').value = widgetNamesRight;
- }
- });
-
- // bind more info buttons - called when new widgets are created
- widget_moreinfo();
-
- // set-up hover class for dragged widgets
- $("#rightcolumn_widgets").droppable({
- accept: ".draggable_widget",
- hoverClass: 'droppable-hover'
- });
- $("#middlecolumn_widgets").droppable({
- accept: ".draggable_widget",
- hoverClass: 'droppable-hover'
- });
- $("#leftcolumn_widgets").droppable({
- accept: ".draggable_widget",
- hoverClass: 'droppable-hover'
- });
-
-}); /* end document ready function */
-
-
-// List active widgets for each page column
-function outputWidgetList(forElement) {
- return( $("input[@name='handler'], input[@name='guid']", forElement ).makeDelimitedList("value") );
-}
-
-// Make delimited list
-jQuery.fn.makeDelimitedList = function(elementAttribute) {
-
- var delimitedListArray = new Array();
- var listDelimiter = "::";
-
- // Loop over each element in the stack and add the elementAttribute to the array
- this.each(function(e) {
- var listElement = $(this);
- // Add the attribute value to our values array
- delimitedListArray[delimitedListArray.length] = listElement.attr(elementAttribute);
- }
- );
-
- // Return value list by joining the array
- return(delimitedListArray.join(listDelimiter));
-}
-
-
-// Read each widgets collapsed/expanded state from cookie and apply
-function widget_state(forWidget) {
-
- var thisWidgetState = $.cookie(forWidget);
-
- if (thisWidgetState == 'collapsed') {
- forWidget = "#" + forWidget;
- $(forWidget).find("div.collapsable_box_content").hide();
- $(forWidget).find("a.toggle_box_contents").html('+');
- $(forWidget).find("a.toggle_box_edit_panel").fadeOut('medium');
- };
-}
-
-
-// Toggle widgets contents and save to a cookie
-var toggleContent = function(e) {
-var targetContent = $('div.collapsable_box_content', this.parentNode.parentNode);
- if (targetContent.css('display') == 'none') {
- targetContent.slideDown(400);
- $(this).html('-');
- $(this.parentNode).children("[class=toggle_box_edit_panel]").fadeIn('medium');
-
- // set cookie for widget panel open-state
- var thisWidgetName = $(this.parentNode.parentNode.parentNode).attr('id');
- $.cookie(thisWidgetName, 'expanded', { expires: 365 });
-
- } else {
- targetContent.slideUp(400);
- $(this).html('+');
- $(this.parentNode).children("[class=toggle_box_edit_panel]").fadeOut('medium');
- // make sure edit pane is closed
- $(this.parentNode.parentNode).children("[class=collapsable_box_editpanel]").hide();
-
- // set cookie for widget panel closed-state
- var thisWidgetName = $(this.parentNode.parentNode.parentNode).attr('id');
- $.cookie(thisWidgetName, 'collapsed', { expires: 365 });
- }
- return false;
-};
-
-// More info tooltip in widget gallery edit panel
-function widget_moreinfo() {
-
- $("img.more_info").hover(function(e) {
- var widgetdescription = $("input[@name='description']", this.parentNode.parentNode.parentNode ).attr('value');
- $("body").append("<p id='widget_moreinfo'><b>"+ widgetdescription +" </b></p>");
-
- if (e.pageX < 900) {
- $("#widget_moreinfo")
- .css("top",(e.pageY + 10) + "px")
- .css("left",(e.pageX + 10) + "px")
- .fadeIn("medium");
- }
- else {
- $("#widget_moreinfo")
- .css("top",(e.pageY + 10) + "px")
- .css("left",(e.pageX - 210) + "px")
- .fadeIn("medium");
- }
- },
- function() {
- $("#widget_moreinfo").remove();
- });
-
- $("img.more_info").mousemove(function(e) {
- // action on mousemove
- });
-};
-
-// COOKIES
-jQuery.cookie = function(name, value, options) {
- if (typeof value != 'undefined') { // name and value given, set cookie
- options = options || {};
- if (value === null) {
- value = '';
- options.expires = -1;
- }
- var expires = '';
- if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
- var date;
- if (typeof options.expires == 'number') {
- date = new Date();
- date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
- } else {
- date = options.expires;
- }
- expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
- }
- // CAUTION: Needed to parenthesize options.path and options.domain
- // in the following expressions, otherwise they evaluate to undefined
- // in the packed version for some reason.
- var path = options.path ? '; path=' + (options.path) : '';
- var domain = options.domain ? '; domain=' + (options.domain) : '';
- var secure = options.secure ? '; secure' : '';
- document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
-
- } else { // only name given, get cookie
- var cookieValue = null;
- if (document.cookie && document.cookie != '') {
- var cookies = document.cookie.split(';');
- for (var i = 0; i < cookies.length; i++) {
- var cookie = jQuery.trim(cookies[i]);
- // Does this cookie string begin with the name we want?
- if (cookie.substring(0, name.length + 1) == (name + '=')) {
- cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
- break;
- }
- }
- }
- return cookieValue;
- }
-};
-
-// ELGG TOOLBAR MENU
-$.fn.elgg_topbardropdownmenu = function(options) {
-
- options = $.extend({speed: 350}, options || {});
-
- this.each(function() {
-
- var root = this, zIndex = 5000;
-
- function getSubnav(ele) {
- if (ele.nodeName.toLowerCase() == 'li') {
- var subnav = $('> ul', ele);
- return subnav.length ? subnav[0] : null;
- } else {
-
- return ele;
- }
- }
-
- function getActuator(ele) {
- if (ele.nodeName.toLowerCase() == 'ul') {
- return $(ele).parents('li')[0];
- } else {
- return ele;
- }
- }
-
- function hide() {
- var subnav = getSubnav(this);
- if (!subnav) return;
- $.data(subnav, 'cancelHide', false);
- setTimeout(function() {
- if (!$.data(subnav, 'cancelHide')) {
- $(subnav).slideUp(100);
- }
- }, 250);
- }
-
- function show() {
- var subnav = getSubnav(this);
- if (!subnav) return;
- $.data(subnav, 'cancelHide', true);
- $(subnav).css({zIndex: zIndex++}).slideDown(options.speed);
- if (this.nodeName.toLowerCase() == 'ul') {
- var li = getActuator(this);
- $(li).addClass('hover');
- $('> a', li).addClass('hover');
- }
- }
-
- $('ul, li', this).hover(show, hide);
- $('li', this).hover(
- function() { $(this).addClass('hover'); $('> a', this).addClass('hover'); },
- function() { $(this).removeClass('hover'); $('> a', this).removeClass('hover'); }
- );
-
- });
-
-};
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+<?php +/** + * This has been deprecated in 1.8 - see elgg.php in this directory. + */
\ No newline at end of file diff --git a/views/default/js/initialize_elgg.php b/views/default/js/initialize_elgg.php new file mode 100644 index 000000000..b45c33463 --- /dev/null +++ b/views/default/js/initialize_elgg.php @@ -0,0 +1,52 @@ +<?php +/** + * Initialize Elgg's js lib with the uncacheable data + */ + +if (0) { ?><script><?php } +?> +/** + * Don't want to cache these -- they could change for every request + */ +elgg.config.lastcache = <?php echo (int)elgg_get_config('lastcache'); ?>; +elgg.config.viewtype = '<?php echo elgg_get_viewtype(); ?>'; +elgg.config.simplecache_enabled = <?php echo (int)elgg_is_simplecache_enabled(); ?>; + +elgg.security.token.__elgg_ts = <?php echo $ts = time(); ?>; +elgg.security.token.__elgg_token = '<?php echo generate_action_token($ts); ?>'; + +<?php +// @todo json export should be smoother than this... +// @todo Might also be nice to make url exportable. $entity->url? yes please! +$page_owner = elgg_get_page_owner_entity(); + +if ($page_owner instanceof ElggEntity) { + $page_owner_json = array(); + foreach ($page_owner->getExportableValues() as $v) { + $page_owner_json[$v] = $page_owner->$v; + } + + $page_owner_json['subtype'] = $page_owner->getSubtype(); + $page_owner_json['url'] = $page_owner->getURL(); + + echo 'elgg.page_owner = ' . json_encode($page_owner_json) . ';'; +} + +$user = elgg_get_logged_in_user_entity(); + +if ($user instanceof ElggUser) { + $user_json = array(); + foreach ($user->getExportableValues() as $v) { + $user_json[$v] = $user->$v; + } + + $user_json['subtype'] = $user->getSubtype(); + $user_json['url'] = $user->getURL(); + $user_json['admin'] = $user->isAdmin(); + + echo 'elgg.session.user = new elgg.ElggUser(' . json_encode($user_json) . ');'; +} +?> + +//Before the DOM is ready, but elgg's js framework is fully initalized +elgg.trigger_hook('boot', 'system');
\ No newline at end of file diff --git a/views/default/js/languages.php b/views/default/js/languages.php new file mode 100644 index 000000000..fcf903d4b --- /dev/null +++ b/views/default/js/languages.php @@ -0,0 +1,33 @@ +<?php +/** + * @uses $vars['language'] + * @uses $vars['lc'] if present, client will be sent long expires headers + */ + +$language = $vars['language']; +$lastcache = elgg_extract('lc', $vars, 0); + +// @todo add server-side caching +if ($lastcache) { + // we're relying on lastcache changes to predict language changes + $etag = '"' . md5("$language|$lastcache") . '"'; + + header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', strtotime("+6 months")), true); + header("Pragma: public", true); + header("Cache-Control: public", true); + header("ETag: $etag"); + + if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && trim($_SERVER['HTTP_IF_NONE_MATCH']) === $etag) { + header("HTTP/1.1 304 Not Modified"); + exit; + } +} + +$all_translations = elgg_get_config('translations'); +$translations = $all_translations['en']; + +if ($language != 'en') { + $translations = array_merge($translations, $all_translations[$language]); +} + +echo json_encode($translations);
\ No newline at end of file diff --git a/views/default/js/languages/en.php b/views/default/js/languages/en.php new file mode 100644 index 000000000..8a604cc12 --- /dev/null +++ b/views/default/js/languages/en.php @@ -0,0 +1,2 @@ +<?php +echo elgg_view('js/languages', array('language' => 'en'));
\ No newline at end of file diff --git a/views/default/js/lightbox.php b/views/default/js/lightbox.php new file mode 100644 index 000000000..a1f018eea --- /dev/null +++ b/views/default/js/lightbox.php @@ -0,0 +1,36 @@ +<?php +/** + * Elgg lightbox + * + * Usage + * Call elgg_load_js('lightbox') and elgg_load_css('lightbox') then + * apply the class elgg-lightbox to links. + * + * Advanced Usage + * Elgg is distributed with the Fancybox jQuery library. Please go to + * http://fancybox.net for more information on the options of this lightbox. + * + * Overriding + * In a plugin, override this view and override the registration for the + * lightbox JavaScript and CSS (@see elgg_views_boot()). + * + * @todo add support for passing options: $('#myplugin-lightbox').elgg.ui.lightbox(options); + */ + +if (0) { ?><script><?php } +?> + +/** + * Lightbox initialization + */ +elgg.ui.lightbox_init = function() { + $(".elgg-lightbox").fancybox(); +} + +elgg.register_hook_handler('init', 'system', elgg.ui.lightbox_init); + +<?php + +$js_path = elgg_get_config('path'); +$js_path = "{$js_path}vendors/jquery/fancybox/jquery.fancybox-1.3.4.pack.js"; +include $js_path; diff --git a/views/default/js/walled_garden.php b/views/default/js/walled_garden.php new file mode 100644 index 000000000..e228df507 --- /dev/null +++ b/views/default/js/walled_garden.php @@ -0,0 +1,67 @@ +<?php +/** + * Walled garden JavaScript + * + * @since 1.8 + */ + +$cancel_button = elgg_view('input/button', array( + 'value' => elgg_echo('cancel'), + 'class' => 'elgg-button-cancel mlm', +)); +$cancel_button = json_encode($cancel_button); + +if (0) { ?><script><?php } +?> + +elgg.provide('elgg.walled_garden'); + +elgg.walled_garden.init = function () { + + $('.forgot_link').click(elgg.walled_garden.load('lost_password')); + $('.registration_link').click(elgg.walled_garden.load('register')); + + $('input.elgg-button-cancel').live('click', function(event) { + var $wgs = $('.elgg-walledgarden-single'); + if ($wgs.is(':visible')) { + $('.elgg-walledgarden-double').fadeToggle(); + $wgs.fadeToggle(); + $wgs.remove(); + } + event.preventDefault(); + }); +}; + +/** + * Creates a closure for loading walled garden content through ajax + * + * @param {String} view Name of the walled garden view + * @return {Object} + */ +elgg.walled_garden.load = function(view) { + return function(event) { + var id = '#elgg-walledgarden-' + view; + id = id.replace('_', '-'); + //@todo display some visual element that indicates that loading of content is running + elgg.get('walled_garden/' + view, { + 'success' : function(data) { + var $wg = $('.elgg-body-walledgarden'); + $wg.append(data); + $(id).find('input.elgg-button-submit').after(<?php echo $cancel_button; ?>); + + if (view == 'register' && $wg.hasClass('hidden')) { + // this was a failed register, display the register form ASAP + $('#elgg-walledgarden-login').toggle(false); + $(id).toggle(); + $wg.removeClass('hidden'); + } else { + $('#elgg-walledgarden-login').fadeToggle(); + $(id).fadeToggle(); + } + } + }); + event.preventDefault(); + }; +}; + +elgg.register_hook_handler('init', 'system', elgg.walled_garden.init);
\ No newline at end of file |
