[geeklog-hg] geeklog: Fixed denim and professional themes to work with jQuery...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Mon Feb 4 08:00:43 EST 2013


changeset 8937:13fc4d49c782
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/13fc4d49c782
user: Kenji ITO <mystralkk at gmail.com>
date: Mon Feb 04 21:55:44 2013 +0900
description:
Fixed denim and professional themes to work with jQuery-1.9.0 and jQuery UI-1.10.0

diffstat:

 public_html/javascript/ver.1.8/admin.configuration.js |  261 ++++++++++-------
 public_html/layout/denim/javascript/script.js         |    8 +-
 2 files changed, 161 insertions(+), 108 deletions(-)

diffs (truncated from 570 to 300 lines):

diff -r 07633a763515 -r 13fc4d49c782 public_html/javascript/ver.1.8/admin.configuration.js
--- a/public_html/javascript/ver.1.8/admin.configuration.js	Mon Feb 04 20:52:59 2013 +0900
+++ b/public_html/javascript/ver.1.8/admin.configuration.js	Mon Feb 04 21:55:44 2013 +0900
@@ -27,15 +27,45 @@
 // |                                                                           |
 // +---------------------------------------------------------------------------+
 
-$j = jQuery.noConflict();
+var geeklog;
 
-// custome autocomplete with categories
+geeklog = geeklog || {};
+
+// Since jQuery UI v1.10.0, tabs.length(), tabs.add(), tabs.remove(),
+// tabs.select(), tabs.show() methods and select event are removed.
+geeklog.admin = {
+    configuration: {
+        getTabLength: function (tabs) {
+            return $(tabs).find('li').length;
+        },
+
+        addTab: function (tabs, url, text, index) {
+            var newItem = $('<li><a href="' + url + '">' + text + '</a></li>');
+
+            if (index <= this.getTabLength(tabs) - 1) {
+                newItem.before($(tabs).find('li').eq(index));
+            } else {
+                newItem.insertAfter($(tabs).find('li').last());
+            }
+
+            tabs.tabs('refresh');
+        },
+
+        removeTab: function (tabs, index) {
+            $(tabs).find('li').eq(index).remove();
+            tabs.tabs('refresh');
+        }
+    }
+};
+
+// custom autocomplete with categories
 var minLength = 10;
-$j.widget("custom.search_config", $j.ui.autocomplete, {
+$.widget("custom.search_config", $.ui.autocomplete, {
     _renderMenu: function( ul, items ) {
         var self = this,
-        currentCategory = "";
-        $j.each( items, function( index, item ) {
+            currentCategory = "";
+
+        $.each( items, function( index, item ) {
             if ( index > minLength ) {
                 return false;
             } else {
@@ -43,48 +73,56 @@
                     ul.append( "<li class='ui-autocomplete-category'>" + item.category + "</li>" );
                     currentCategory = item.category;
                 }
-                self._renderItem( ul, item );
+                self._renderItemData(ul, item);
             }
         });
+    },
+
+    // Since jQuery UI v1.10.0, "item.autocomplete" key of data() is removed.
+    //Instead, "ui-autocomplete-item" should be used.
+    _renderItemData: function (ul, item) {
+        return this._renderItem(ul, item).data('ui-autocomplete-item', item);
+    },
+
+    _renderItem: function (ul, item) {
+        return $('<li>').append($('<a>').text(item.label)).appendTo(ul);
     }
 });
 
 // currently selected tab
 var selectedTab;
-$j(function() {
+$(function() {
     // start bootstrap
     var bootstrap = true;
     
     // dropdown menu when tabs overflow
     var dropDown = '';
     // init tabs
-    var tabs = $j("#tabs").tabs({
-        tabTemplate : 
-            '<li><a href="#{href}">#{label}</a></li>',
-        select: function(e, ui) {
-            if ( $j(ui.tab).attr('href') == '#tab-dropdown' ) {
-                var container = $j(ui.tab).parent();
+    var tabs = $("#tabs").tabs({
+        beforeActivate: function(e, ui) {
+            if (ui.newTab.children('a').attr('href') === '#tab-dropdown') {
+                var container = ui.newTab.parent();
                 
-                if ( $j('#tabs-dropdown').length ) {
-                    $j('#tabs-dropdown').toggle();
+                if ($('#tabs-dropdown').length > 0) {
+                    $('#tabs-dropdown').toggle();
                 } else {
                     container.append( dropDown ).removeClass('ui-tabs-selected ui-state-active');
                     
                     // show it and the positioning!
-                    $j('#tabs-dropdown').show().position({
-                        of: $j(ui.tab),
+                    $('#tabs-dropdown').show().position({
+                        of: ui.newTab,
                         my: 'right top',
-                        at: 'right top',
-                        offset: '0 ' + $j(ui.tab).parent().height()
+                        at: 'right bottom',
+                        offset: '0 ' + ui.newTab.parent().height()
                     });
                 }
                 
-                return false;
+//                return false;
             } else {
-                $j('#tabs-dropdown').hide().parent().removeClass('ui-tabs-selected ui-state-active');
-                $j('.ui-tabs-panel').addClass('ui-tabs-hide');
+                $('#tabs-dropdown').hide().parent().removeClass('ui-tabs-selected ui-state-active');
+                $('.ui-tabs-panel').removeClass('ui-tabs-hide');
             }
-            selectedTab = $j(ui.tab).attr('href');
+            selectedTab = ui.newTab.children('a').attr('href');
         }
     });
     // tabs were getting overflow
@@ -93,31 +131,31 @@
     var lastTabsWidth = 0;
     
     // init autocomplete
-    $j('#search-configuration').search_config({
+    $('#search-configuration').search_config({
         delay: 0,
         source: autocomplete_data,
         focus: function(event, ui) {
-            $j('#search-configuration').val(ui.item.label);
-            
+            $('#search-configuration').val(ui.item.label);
+
             return false;
         },
         select: function(event, ui) {
-            $j('#search-configuration').val(ui.item.label);
-            $j('#tab-id').val(ui.item.tab_id);
+            $('#search-configuration').val(ui.item.label);
+            $('#tab-id').val(ui.item.tab_id);
             
             document.group.conf_group.value = ui.item.group;
             document.group.subgroup.value = ui.item.subgroup;
             
             // we need this input for #search-configuration value
             // after submitted
-            if ( $j(document.group['search-configuration-cached']).length ) {
-                $j(document.group['search-configuration-cached']).val(ui.item.label);
-                $j(document.group['tab-id-cached']).val(ui.item.tab_id);
+            if ( $(document.group['search-configuration-cached']).length ) {
+                $(document.group['search-configuration-cached']).val(ui.item.label);
+                $(document.group['tab-id-cached']).val(ui.item.tab_id);
             } else {
                 search_label = '<input type="hidden" name="search-configuration-cached" value="'+ui.item.label+'">';
                 tab_id = '<input type="hidden" name="tab-id-cached" value="'+ui.item.label+'">';
-                $j(document.group).append( search_label);
-                $j(document.group).append( tab_id );
+                $(document.group).append( search_label);
+                $(document.group).append( tab_id );
             }
             
             document.group.action = frmGroupAction + '?' + 'tab-' + ui.item.tab_id + '#' + ui.item.value;
@@ -131,7 +169,7 @@
     var tooltipCachedPage = '';
     var tooltipHideDelay = 300;
     var tooltipHideTimer = null;
-    var tooltipContainer = $j(
+    var tooltipContainer = $(
         '<div id="tooltip-container">' +
             '<div id="tootip-loading"><img src="'+ imgSpinner +'" /> Loading...</div>' +
             '<div id="tooltip-header"></div>' +
@@ -139,31 +177,32 @@
             '<div id="tooltip-tip"></div>' +
         '</div>'
     );
-    $j('body').append(tooltipContainer);
-    $j('.tooltip').live('mouseover', function() {
-        var attrTarget = $j(this).attr('target');
-        var attrHref = $j(this).attr('href');
+    $('body').append(tooltipContainer);
+
+    $(document).on('mouseover', '.tooltip', function() {
+        var attrTarget = $(this).attr('target');
+        var attrHref = $(this).attr('href');
         
-        if ( attrTarget != 'help' && !attrHref ) return;
+        if ((attrTarget !== 'help') && !attrHref) return;
         var confVar = attrHref.substr(attrHref.indexOf('#')+1);
         
         if ( tooltipHideTimer ) clearTimeout(tooltipHideTimer);
         
-        var pos = $j(this).offset();
-        var height = $j(this).height();
+        var pos = $(this).offset();
+        var height = $(this).height();
         
         tooltipContainer.css({
             left: pos.left + 'px',
             top: (pos.top + height + 5) + 'px'
         });
         
-        $j('#tootip-loading').show();
-        $j.get(attrHref, function(data) {
-            $j('#tootip-loading').hide();
+        $('#tootip-loading').show();
+        $.get(attrHref, function(data) {
+            $('#tootip-loading').hide();
             if (data.indexOf(confVar) > 0) {
-                var a = $j(data).find('a[name=' + confVar + ']');
+                var a = $(data).find('a[name=' + confVar + ']');
                 var row = a.parent().parent().html();
-                $j('#tooltip-content').html(
+                $('#tooltip-content').html(
                     '<table>' +
                         '<thead><tr>' +
                             '<th>Variable</th>' +
@@ -176,7 +215,7 @@
                     '</table>'
                 );
             } else {
-                $j('#tooltip-content').html(
+                $('#tooltip-content').html(
                     '<span>Help page is not found.</span>'
                 )
             }
@@ -184,52 +223,56 @@
         
         tooltipContainer.show();
     });
-    $j('.tooltip').live('mouseout', function() {
+    $(document).on('mouseout', '.tooltip', function() {
         if ( tooltipHideTimer ) clearTimeout(tooltipHideTimer);
         
         tooltipHideTimer = setTimeout(function() {
             tooltipContainer.hide();
         }, tooltipHideDelay);
     });
-    $j('#tooltip-container').mouseover(function() {
+    $('#tooltip-container').mouseover(function() {
         if ( tooltipHideTimer ) clearTimeout(tooltipHideTimer);
     });
-    $j('#tooltip-container').mouseout(function() {
+    $('#tooltip-container').mouseout(function() {
         if ( tooltipHideTimer ) clearTimeout(tooltipHideTimer);
         
         tooltipHideTimer = setTimeout(function() {
             tooltipContainer.hide();
         }, tooltipHideDelay);
     });
-    
+    $(document).on('click touchout', '#tooltip-close', function() {
+        if ( tooltipHideTimer ) clearTimeout(tooltipHideTimer);
+        tooltipContainer.hide();
+    });
+
     // check overflow on resize
-    $j(window).resize(function() {
+    $(window).resize(function() {
         tabsOverflowHandler();
     });
     
     // click event handler
-    $j(document.body).click(function(e) {
-        var target = $j(e.target);
+    $(document.body).click(function(e) {
+        var target = $(e.target);
         var targetParent = target.parent();
         
-        if ( $j('#tabs-dropdown').length ) {
-            if ( target.is('a') && target.attr('href') == '#tab-dropdown' ) {
-                $j('#tabs-dropdown').toggle();
-                
+        if ($('#tabs-dropdown').length > 0) {
+            if ( target.is('a') && (target.attr('href') === '#tab-dropdown')) {
+//                $('#tabs-dropdown').toggle();
                 e.preventDefault();
                 return false;
             }
             
-            if ( target.attr('id') == 'tabs-dropdown' ) return dropDownHandler(e);
-            if ( targetParent.attr('id') == 'tabs-dropdown' ) return dropDownHandler(e);
-            if ( targetParent.parent().attr('id') == 'tabs-dropdown' ) return dropDownHandler(e);
-            
+            if ((target.attr('id') === 'tabs-dropdown') ||
+                    (targetParent.attr('id') === 'tabs-dropdown') ||
+                    (targetParent.parent().attr('id') === 'tabs-dropdown' )) {
+                return dropDownHandler(e);
+            }
         }
-        $j('#tabs-dropdown').hide();
-        $j('.config_name', tabs).removeClass('active-config');



More information about the geeklog-cvs mailing list