diff options
author | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-12-29 18:16:54 +0000 |
---|---|---|
committer | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-12-29 18:16:54 +0000 |
commit | 3c083f6c4ff4d354a546e03477e7a4acbb16d4a9 (patch) | |
tree | 961ad1135905070b95a51bc0c6bdbd948754b562 /js | |
parent | 298114995174acf451cc1477fdeec34a42ef608b (diff) | |
download | elgg-3c083f6c4ff4d354a546e03477e7a4acbb16d4a9.tar.gz elgg-3c083f6c4ff4d354a546e03477e7a4acbb16d4a9.tar.bz2 |
rewrote the display of likes
git-svn-id: http://code.elgg.org/elgg/trunk@7748 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'js')
-rw-r--r-- | js/lib/ui.js | 139 |
1 files changed, 28 insertions, 111 deletions
diff --git a/js/lib/ui.js b/js/lib/ui.js index 02d49794d..a1d852e5a 100644 --- a/js/lib/ui.js +++ b/js/lib/ui.js @@ -8,22 +8,11 @@ elgg.ui.init = function () { $('.elgg-toggle').live('click', elgg.ui.toggle);
- $('.elgg-menu-parent').live('click', elgg.ui.menuToggle);
+ $('.elgg-menu-parent').live('click', elgg.ui.toggleMenu);
+ $('.elgg-like-toggle').live('click', elgg.ui.toggleLikes);
$('a.collapsibleboxlink').click(elgg.ui.toggleCollapsibleBox);
-
- // set-up hover class for dragged widgets
- var cols = [
- "#rightcolumn_widgets",
- "#middlecolumn_widgets",
- "#leftcolumn_widgets"
- ].join(',');
-
- $(cols).droppable({
- accept: ".draggable_widget",
- hoverClass: 'droppable-hover'
- });
};
/**
@@ -48,7 +37,7 @@ elgg.ui.toggle = function(event) { * @param {Object} event
* @return void
*/
-elgg.ui.menuToggle = function(event) {
+elgg.ui.toggleMenu = function(event) {
$(this).siblings().slideToggle('medium');
$(this).toggleClass('elgg-menu-closed elgg-menu-opened');
event.preventDefault();
@@ -60,103 +49,31 @@ elgg.ui.toggleCollapsibleBox = function () { return false;
};
-//define some helper jquery plugins
-(function($) {
-
- // ELGG TOOLBAR MENU
- $.fn.elgg_topbardropdownmenu = function(options) {
- var defaults = {
- speed: 350
- };
-
- options = $.extend(defaults, 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), li;
-
- if (!subnav) {
- return;
- }
-
- $.data(subnav, 'cancelHide', true);
-
- $(subnav).css({zIndex: zIndex}).slideDown(options.speed);
- zIndex++;
-
- if (this.nodeName.toLowerCase() === 'ul') {
- 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');
- }
- );
-
+/**
+ * Toggles the likes list
+ *
+ * @param {Object} event
+ * @return void
+ */
+elgg.ui.toggleLikes = function(event) {
+ var $list = $(this).next(".elgg-likes-list");
+ var position = $(this).position();
+ var startTop = position.top;
+ var stopTop = position.top - $list.height();
+ if ($list.css('display') == 'none') {
+ $('.elgg-likes-list').fadeOut();
+
+ $list.css('top', startTop);
+ $list.css('left', position.left - $list.width());
+ $list.animate({opacity: "toggle", top: stopTop}, 500);
+
+ $list.click(function(event) {
+ $list.fadeOut();
});
- };
-
- //Make delimited list
- $.fn.makeDelimitedList = function(elementAttribute) {
-
- var delimitedListArray = [],
- 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);
- };
-})(jQuery);
+ } else {
+ $list.animate({opacity: "toggle", top: startTop}, 500);
+ }
+ event.preventDefault();
+}
elgg.register_event_handler('init', 'system', elgg.ui.init);
\ No newline at end of file |