WordPress.org

Plugin Directory

Changeset 625420


Ignore:
Timestamp:
11/14/12 22:33:31 (17 months ago)
Author:
eskapism
Message:

hey ho version 0.10

Location:
cms-tree-page-view
Files:
10 edited
3 copied

Legend:

Unmodified
Added
Removed
  • cms-tree-page-view/tags/0.10/functions.php

    r623664 r625420  
    7777        wp_enqueue_script( "jquery-jstree", CMS_TPV_URL . "scripts/jquery.jstree.js", false, CMS_TPV_VERSION); 
    7878        wp_enqueue_script( "jquery-alerts", CMS_TPV_URL . "scripts/jquery.alerts.js", false, CMS_TPV_VERSION); 
    79         wp_enqueue_script( "hoverIntent"); 
     79        // wp_enqueue_script( "hoverIntent"); 
    8080        wp_enqueue_script( "cms_tree_page_view", CMS_TPV_URL . "scripts/cms_tree_page_view.js", false, CMS_TPV_VERSION);     
    8181 
  • cms-tree-page-view/tags/0.10/index.php

    r623665 r625420  
    44Plugin URI: http://eskapism.se/code-playground/cms-tree-page-view/ 
    55Description: Adds a CMS-like tree view of all your pages, like the view often found in a page-focused CMS. Use the tree view to edit, view, add pages and search pages (very useful if you have many pages). And with drag and drop you can rearrange the order of your pages. Page management won't get any easier than this! 
    6 Version: 0.9 
     6Version: 0.10 
    77Author: Pär Thernström 
    88Author URI: http://eskapism.se/ 
     
    2929require(dirname(__FILE__)."/functions.php"); 
    3030 
    31 define( "CMS_TPV_VERSION", "0.9"); 
     31define( "CMS_TPV_VERSION", "0.10"); 
    3232define( "CMS_TPV_NAME", "CMS Tree Page View"); 
    3333 
  • cms-tree-page-view/tags/0.10/readme.txt

    r623711 r625420  
    55Requires at least: 3.0 
    66Tested up to: 3.5 
    7 Stable tag: 0.9 
     7Stable tag: 0.10 
    88 
    99Adds a tree of all your pages or custom posts. Use drag & drop to reorder your pages, and edit, view, add, and search your pages. 
     
    8989== Changelog == 
    9090 
     91= 0.10 = 
     92- Fixed position of action div. Now it's always to the right of the page name. 
     93- Fixed so action div never is below the fold of the browser. Instead it's moved up until it's visible. 
     94- Fixed problem related to hoverIntent and mouseover and drag and drop. There was just to many wierd things going on so I switched to my own solution instead. Let me know if it works ok for you too now again! 
     95 
    9196= 0.9 = 
    9297- Only output scripts and styles on pages that the plugin uses. This should speed up other parts of the WordPress admin a little tiny itsy bitsy bit. 
  • cms-tree-page-view/tags/0.10/scripts/cms_tree_page_view.js

    r623711 r625420  
    99 
    1010    // try to override css 
    11     var height = "20", height2 = "18", ins_height = "18"; 
     11    var height = "20", height2 = "18", ins_height = "20"; 
    1212    css_string = '' +  
    1313        '.jstree ul, .jstree li { display:block; margin:0 0 0 0; padding:0 0 0 0; list-style-type:none; } ' +  
     
    8080         
    8181        var isHierarchical = $(elm).closest(".cms_tpv_wrapper").find("[name=cms_tpv_meta_post_type_hierarchical]").val(); 
    82         if (isHierarchical == 0) { 
     82        if (isHierarchical === "0") { 
    8383            // no move to children if not hierarchical 
    8484            treeOptionsTmp.types = { 
     
    9898        }); 
    9999         
    100         $elm.bind("loaded.jstree open_node.jstree", cms_tpv_tree_loaded); 
    101          //$wrapper.find(".cms_tpv_container").bind("loaded.jstree refresh.jstree open_node.jstree reopen.jstree after_open.jstree load_node.jstree", cms_tpv_tree_loaded); 
     100        // whole tre loaded 
     101        $elm.bind("loaded.jstree", cms_tpv_tree_loaded); 
     102         
    102103        $elm.jstree(treeOptionsTmp); 
    103104 
     
    105106 
    106107}); // end ondomready 
     108 
     109 
     110function cms_tpv_mouseover(e) { 
     111 
     112    var $this = jQuery(this); 
     113    var $li = $this.closest("li"); 
     114    cms_tpv_mouseover_li(e, $li.get(0)); 
     115    return true; 
     116 
     117} 
    107118 
    108119 
    109120/** 
    110121 * When tree is loaded: start hoverindenting stuff 
    111  * @todo: this is fireded several times, why not only once 
     122 * @todo: this is fireded several times? why not only once? 
    112123 */ 
    113124function cms_tpv_tree_loaded(event, data) { 
    114125 
    115     // console.log("loaded"); 
    116  
    117     var $target = jQuery(event.target); 
    118     var $lis = $target.find("li a"); 
    119     var $hoverIntentWrap = $target.find("div.cmstpv-hoverIntent-wrap"); 
    120  
    121     // Bind hoverIntent 
    122     $hoverIntentWrap.hoverIntent({     
    123         over: cms_tpv_mouseover, 
    124         out: cms_tpv_mouseout, 
    125         timeout: 500, // default 0, 500 is good 
    126         sensitivity: 4 // default 7 
    127     }); 
    128  
    129     function cms_tpv_mouseover(e) { 
    130         var $this = jQuery(this); 
    131         var $li = $this.closest("li"); 
    132         cms_tpv_mouseover_li(e, $li.get(0)); 
    133     } 
    134  
    135     function cms_tpv_mouseout(e) { 
    136         var $this = jQuery(this); 
    137         var $li = $this.closest("li"); 
    138         cms_tpv_mouseout_li(e, $li.get(0)); 
    139     } 
     126    var $container = jQuery(event.target); 
     127 
     128    // when mouse enters a/link 
     129    // start timer and if no other a/link has been moused over since it started it's ok to show this one 
     130    jQuery($container).on("mouseenter", "a", function(e) { 
     131        var global_timer = $container.data("cmstpv_global_link_timer"); 
     132 
     133        if (global_timer) { 
     134            // global timer exists, so overwrite it with our new one 
     135            // stop that timer before setting ours 
     136            clearTimeout(global_timer); 
     137        } else { 
     138            // no timer exists, overwrite with ours 
     139        } 
     140        // create new timer, no matter if one exists already 
     141        var timeoutID = setTimeout(function(e) { 
     142            cms_tpv_mouseover_li(e); 
     143        }, 500, e); 
     144 
     145        $container.data("cmstpv_global_link_timer", timeoutID); 
     146 
     147    }); 
     148 
     149    /** 
     150     * When mouse down then hide the action div 
     151     */ 
     152    jQuery($container).on("mousedown", "a", function(e) { 
     153        var $target = jQuery(e.target); 
     154        var $container = $target.closest("div.cms_tpv_container"); 
     155        var $wrapper = $container.closest("div.cms_tpv_wrapper"); 
     156        $container.find("li.has-visible-actions").removeClass("has-visible-actions"); 
     157        $container.find("a.hover").removeClass("hover"); 
     158        $wrapper.find("div.cms_tpv_page_actions").removeClass("cms_tpv_page_actions_visible"); 
     159    }); 
    140160 
    141161} 
     
    246266} 
    247267 
    248 /* 
    249 jQuery(".jstree li").live("mouseover", function(e) { 
    250     var $li = jQuery(this); 
    251     var li_id = $li.attr("id"); 
    252     cms_tpv_mouseover_li(this); 
    253 }); 
    254 // ..and hide them again 
    255 jQuery(".jstree li").live("mouseout", function() { 
    256     //cms_tpv_current_li_id = null; 
    257     //console.log("out"); 
    258     cms_tpv_mouseout_li(this); 
    259 }); 
    260 */ 
    261  
    262  
    263  
    264268// fired when mouse is over li 
    265 function cms_tpv_mouseover_li(e, li) { 
    266  
    267     var $li = jQuery(li); 
    268  
    269     var div_actions_for_post_type = cms_tpv_get_page_actions_div(li); 
     269// actually when over a, old name :/ 
     270function cms_tpv_mouseover_li(e) { 
     271 
     272    var $target = jQuery(e.target); 
     273    var $li = $target.closest("li"); 
     274 
     275    var div_actions_for_post_type = cms_tpv_get_page_actions_div($li); 
    270276    var $cms_tpv_container = $li.closest("div.cms_tpv_container"); 
    271277 
    272     if (cms_tpv_is_dragging() == false) { 
     278    if (cms_tpv_is_dragging() === false) { 
    273279         
    274280        var is_visible = div_actions_for_post_type.is(":visible"); 
     
    301307            div_actions_for_post_type.find(".cms_tpv_page_actions_modified_time").text($li.data("modified_time")); 
    302308            div_actions_for_post_type.find(".cms_tpv_page_actions_modified_by").text($li.data("modified_author")); 
    303             div_actions_for_post_type.find(".cms_tpv_page_actions_page_id").text($li.data("post_id"));       
    304              
     309            div_actions_for_post_type.find(".cms_tpv_page_actions_page_id").text($li.data("post_id")); 
    305310            div_actions_for_post_type.find(".cms_tpv_page_actions_columns").html( unescape($li.data("columns")) ); 
    306311 
     
    309314             
    310315            // position and show action div 
    311             // put it inside cmstpv-hoverIntent-wrap so hoverIndent is cool with it 
    312             var $overIntentWrap = $li.find("div.cmstpv-hoverIntent-wrap:first"); 
    313             //console.log( $overIntentWrap.length ); 
     316 
     317            //console.log( jQuery(window).position() ); 
     318            //console.log( jQuery(window).offset() ); 
     319 
    314320            var $a = $li.find("a"); 
    315321            var width = $a.outerWidth(true); 
    316             //$li.append(div_actions_for_post_type); 
    317              
    318             $overIntentWrap.append(div_actions_for_post_type); 
    319              
    320322            var new_offset = div_actions_for_post_type.offset(); 
    321323            var new_offset_left = e.pageX + 35; 
    322             // check that new left offset is not to close to the left of the a 
    323             // i.e. the mouse be x px more than the a for the experience to be optimal IMHO 
    324             var diff = e.pageX - $a.offset().left; 
    325             if (diff < 25) new_offset_left = new_offset_left + 25; 
    326  
     324         
     325            new_offset_left = $a.offset().left + $a.width() + 20; 
    327326            new_offset.left = new_offset_left; 
    328327            new_offset.top = $a.offset().top - 30; 
    329328            div_actions_for_post_type.offset(new_offset); 
     329 
     330            // check if action div bottom is visible in browser window, if not move it up until it is 
     331            var pos_diff = (div_actions_for_post_type.offset().top + div_actions_for_post_type.height()) - (jQuery(window).height() + jQuery(window).scrollTop()); 
     332            if (pos_diff > 0)  { 
     333                 
     334                // set action div to begin at bottom of link instead 
     335                new_offset.top = $a.offset().top - div_actions_for_post_type.height() + 15; // <- ska bli botten på vår div 
     336                div_actions_for_post_type.offset( new_offset ); 
     337                div_actions_for_post_type.addClass("cms_tpv_page_actions_visible_from_bottom"); 
     338                 
     339            } else { 
     340                div_actions_for_post_type.removeClass("cms_tpv_page_actions_visible_from_bottom"); 
     341            } 
     342 
    330343             
    331344            // check if user is allowed to edit page 
    332345            var $cms_tpv_action_add_and_edit_page = div_actions_for_post_type.find(".cms_tpv_action_add_and_edit_page"); 
    333             if ($li.data("user_can_edit_page") == 0) { 
     346            if ($li.data("user_can_edit_page") === "0") { 
    334347                // nooope 
    335348                $edit.hide(); 
     
    347360} 
    348361 
    349 // When mouse leaves the whole cms tree page view-area/div 
     362/** 
     363 * When mouse leaves the whole cms tree page view-area/div 
     364 * hide actions div after moving mouse out of a page and not moving it on again for...a while 
     365 */ 
    350366jQuery(document).on("mouseleave", "div.cms_tpv_container", function(e) { 
    351     // hide actions div after moving mouse out of a page and not moving it on again for...a while 
    352      
    353     //var div_actions_for_post_type = cms_tpv_get_page_actions_div(li); 
    354     //var $cms_tpv_container = $li.closest("div.cms_tpv_container"); 
    355     // console.log("mouse outside container"); 
    356     var $container = jQuery(this); 
    357     jQuery.data(this, "cmstpv_do_hide_after_timeout", true); 
     367     
     368    var $container = jQuery(e.target).closest("div.cms_tpv_container"); 
     369    var $wrapper = $container.closest("div.cms_tpv_wrapper"); 
    358370    var t = this; 
    359  
    360     setTimeout(function() { 
    361         //(function() { 
    362              
    363             // check if container has data value that still tells us to hide 
    364             // this value is reseted when we enter the div again 
    365             //$cms_tpv_container 
    366             //console.log("timeout passed; hide?"); 
    367             //console.log( jQuery.data(t, "cmstpv_do_hide_after_timeout") ); 
    368             if (jQuery.data(t, "cmstpv_do_hide_after_timeout")) { 
    369                 $container.find("li.has-visible-actions").removeClass("has-visible-actions"); 
    370                 $container.find("a.hover").removeClass("hover"); 
    371                 $container.find("div.cms_tpv_page_actions").removeClass("cms_tpv_page_actions_visible"); 
    372             } 
    373  
    374         //})(); 
    375     }, 1000); 
    376  
    377 }); 
     371     
     372    // reset global timer 
     373    var global_timer = $container.data("cmstpv_global_link_timer"); 
     374    if (global_timer) { 
     375        clearTimeout(global_timer); 
     376    } 
     377 
     378    // hide popup after a short while 
     379    var hideTimer = setTimeout(function() { 
     380         
     381        // But don't hide if we are inside the popup 
     382        var $toElement = jQuery(e.toElement); 
     383        if ($toElement.hasClass("cms_tpv_page_actions")) { 
     384            // we are over the actions div, so don't hide 
     385        } else { 
     386            // somewhere else, do hide 
     387            $container.find("li.has-visible-actions").removeClass("has-visible-actions"); 
     388            $container.find("a.hover").removeClass("hover"); 
     389            $wrapper.find("div.cms_tpv_page_actions").removeClass("cms_tpv_page_actions_visible"); 
     390        } 
     391 
     392    }, 500); 
     393 
     394    $container.data("cmstpv_global_hide_timer", hideTimer); 
     395 
     396}); 
     397 
     398/// When mouse enters actions div then cancel possibly global hide timer 
     399/* 
     400jQuery(document).on("mouseenter", "div.cms_tpv_page_actions", function(e) { 
     401     
     402    var $this = jQuery(this); 
     403    var $wrapper = $this.closest("div.cms_tpv_wrapper"); 
     404    var $container = $wrapper.find("div.cms_tpv_container"); 
     405    var hideTimer = $container.data("cmstpv_global_hide_timer"); 
     406    console.log(hideTimer, "hidetimer"); 
     407    if (hideTimer) { 
     408        console.log("clearedIt!"); 
     409        clearTimeout(hideTimer); 
     410    } 
     411 
     412}); 
     413*/ 
     414 
    378415 
    379416// When mouse enter the whole cms tree page view-area/div 
    380417jQuery(document).on("mouseenter", "div.cms_tpv_container", function(e) { 
    381418 
    382     // console.log("mouse inside container, reset hide data"); 
    383419    var $container = jQuery(this); 
    384420    jQuery.data(this, "cmstpv_do_hide_after_timeout", false); 
     
    386422}); 
    387423 
    388  
    389 // fired when mouse leaves li 
    390 function cms_tpv_mouseout_li(e, li) { 
    391  
    392     var $li = jQuery(li); 
    393     var $cms_tpv_container = $li.closest("div.cms_tpv_container"); 
    394  
    395     /* 
    396     var div_actions_for_post_type = cms_tpv_get_page_actions_div(li); 
    397     var $cms_tpv_container = $li.closest("div.cms_tpv_container"); 
    398     var is_visible = div_actions_for_post_type.is(":visible"); 
    399     */ 
    400  
    401     // Remove classes if we are not viewing any 
    402     // This function can get called also when a new li has been hoverIndent:ed 
    403     /* 
    404     $li.find("a:first").removeClass("hover"); 
    405     $li.removeClass("has-visible-actions"); 
    406     if (!is_visible) { 
    407         $cms_tpv_container.removeClass("has-visible-actions"); 
    408     } 
    409     */ 
    410     //div_actions.hide(); 
    411 } 
    412  
    413  
    414 // hide action links on drag 
    415 jQuery.jstree.drag_start = function() { 
    416     jQuery(".cms_tpv_action_view, .cms_tpv_action_edit, .cms_tpv_action_add_page, .cms_tpv_action_add_page_after, .cms_tpv_action_add_page_inside").hide(); 
    417 } 
    418424 
    419425/** 
     
    517523 
    518524                // To make hoverindent work we must wrap something around the a bla bla bla 
    519  
    520                 //li.find() 
    521                 var div_wrap = jQuery("<div class='cmstpv-hoverIntent-wrap' />"); 
    522                 div_wrap.css({ 
    523                     "display": "inline-block", 
    524                     "xwidth": "100%" 
    525                 }); 
    526                 aFirst.wrap(div_wrap); 
    527  
     525                //var div_wrap = jQuery("<div class='cmstpv-hoverIntent-wrap' />"); 
     526                //aFirst.wrap(div_wrap); 
    528527 
    529528            }); 
     
    543542        $wrapper.find(".cms_tree_view_search_form_no_hits").fadeOut("fast"); 
    544543        $wrapper.find(".cms_tree_view_search_form_working").fadeIn("fast"); 
    545         $wrapper.find(".cms_tree_view_search_form_reset") 
     544        $wrapper.find(".cms_tree_view_search_form_reset"); 
    546545        $wrapper.find(".cms_tpv_container").jstree("search", s); 
    547546        $wrapper.find(".cms_tree_view_search_form_reset").fadeIn("fast"); 
  • cms-tree-page-view/tags/0.10/scripts/jquery.jstree.js

    r623479 r625420  
    236236                            $.extend({}, this, {  
    237237                                __callback : function (data) {  
     238                                    //console.log(i); 
    238239                                    this.get_container().triggerHandler( i + '.jstree', { "inst" : this, "args" : args, "rslt" : data, "rlbk" : rlbk }); 
    239240                                }, 
  • cms-tree-page-view/tags/0.10/styles/styles.css

    r623672 r625420  
    268268} 
    269269 
     270.cms_tpv_page_actions_visible_from_bottom:before { 
     271    top: auto; 
     272    bottom: 10px; 
     273} 
     274 
    270275.cms_tpv_page_actions.cms_tpv_page_actions_visible { 
    271276    /*display: block;*/ 
     
    284289} 
    285290*/ 
    286 li.has-visible-actions > div.cmstpv-hoverIntent-wrap:first-of-type > a:first-of-type { 
     291li.has-visible-actions > a:first-of-type { 
    287292    /*font-weight: bold;*/ 
    288     background-color: lightyellow; 
     293    background-color: #d8f5fa; 
     294} 
     295 
     296.jstree a > ins { 
     297     
    289298} 
    290299 
  • cms-tree-page-view/trunk/functions.php

    r623664 r625420  
    7777        wp_enqueue_script( "jquery-jstree", CMS_TPV_URL . "scripts/jquery.jstree.js", false, CMS_TPV_VERSION); 
    7878        wp_enqueue_script( "jquery-alerts", CMS_TPV_URL . "scripts/jquery.alerts.js", false, CMS_TPV_VERSION); 
    79         wp_enqueue_script( "hoverIntent"); 
     79        // wp_enqueue_script( "hoverIntent"); 
    8080        wp_enqueue_script( "cms_tree_page_view", CMS_TPV_URL . "scripts/cms_tree_page_view.js", false, CMS_TPV_VERSION);     
    8181 
  • cms-tree-page-view/trunk/index.php

    r623665 r625420  
    44Plugin URI: http://eskapism.se/code-playground/cms-tree-page-view/ 
    55Description: Adds a CMS-like tree view of all your pages, like the view often found in a page-focused CMS. Use the tree view to edit, view, add pages and search pages (very useful if you have many pages). And with drag and drop you can rearrange the order of your pages. Page management won't get any easier than this! 
    6 Version: 0.9 
     6Version: 0.10 
    77Author: Pär Thernström 
    88Author URI: http://eskapism.se/ 
     
    2929require(dirname(__FILE__)."/functions.php"); 
    3030 
    31 define( "CMS_TPV_VERSION", "0.9"); 
     31define( "CMS_TPV_VERSION", "0.10"); 
    3232define( "CMS_TPV_NAME", "CMS Tree Page View"); 
    3333 
  • cms-tree-page-view/trunk/readme.txt

    r623711 r625420  
    55Requires at least: 3.0 
    66Tested up to: 3.5 
    7 Stable tag: 0.9 
     7Stable tag: 0.10 
    88 
    99Adds a tree of all your pages or custom posts. Use drag & drop to reorder your pages, and edit, view, add, and search your pages. 
     
    8989== Changelog == 
    9090 
     91= 0.10 = 
     92- Fixed position of action div. Now it's always to the right of the page name. 
     93- Fixed so action div never is below the fold of the browser. Instead it's moved up until it's visible. 
     94- Fixed problem related to hoverIntent and mouseover and drag and drop. There was just to many wierd things going on so I switched to my own solution instead. Let me know if it works ok for you too now again! 
     95 
    9196= 0.9 = 
    9297- Only output scripts and styles on pages that the plugin uses. This should speed up other parts of the WordPress admin a little tiny itsy bitsy bit. 
  • cms-tree-page-view/trunk/scripts/cms_tree_page_view.js

    r623711 r625420  
    99 
    1010    // try to override css 
    11     var height = "20", height2 = "18", ins_height = "18"; 
     11    var height = "20", height2 = "18", ins_height = "20"; 
    1212    css_string = '' +  
    1313        '.jstree ul, .jstree li { display:block; margin:0 0 0 0; padding:0 0 0 0; list-style-type:none; } ' +  
     
    8080         
    8181        var isHierarchical = $(elm).closest(".cms_tpv_wrapper").find("[name=cms_tpv_meta_post_type_hierarchical]").val(); 
    82         if (isHierarchical == 0) { 
     82        if (isHierarchical === "0") { 
    8383            // no move to children if not hierarchical 
    8484            treeOptionsTmp.types = { 
     
    9898        }); 
    9999         
    100         $elm.bind("loaded.jstree open_node.jstree", cms_tpv_tree_loaded); 
    101          //$wrapper.find(".cms_tpv_container").bind("loaded.jstree refresh.jstree open_node.jstree reopen.jstree after_open.jstree load_node.jstree", cms_tpv_tree_loaded); 
     100        // whole tre loaded 
     101        $elm.bind("loaded.jstree", cms_tpv_tree_loaded); 
     102         
    102103        $elm.jstree(treeOptionsTmp); 
    103104 
     
    105106 
    106107}); // end ondomready 
     108 
     109 
     110function cms_tpv_mouseover(e) { 
     111 
     112    var $this = jQuery(this); 
     113    var $li = $this.closest("li"); 
     114    cms_tpv_mouseover_li(e, $li.get(0)); 
     115    return true; 
     116 
     117} 
    107118 
    108119 
    109120/** 
    110121 * When tree is loaded: start hoverindenting stuff 
    111  * @todo: this is fireded several times, why not only once 
     122 * @todo: this is fireded several times? why not only once? 
    112123 */ 
    113124function cms_tpv_tree_loaded(event, data) { 
    114125 
    115     // console.log("loaded"); 
    116  
    117     var $target = jQuery(event.target); 
    118     var $lis = $target.find("li a"); 
    119     var $hoverIntentWrap = $target.find("div.cmstpv-hoverIntent-wrap"); 
    120  
    121     // Bind hoverIntent 
    122     $hoverIntentWrap.hoverIntent({     
    123         over: cms_tpv_mouseover, 
    124         out: cms_tpv_mouseout, 
    125         timeout: 500, // default 0, 500 is good 
    126         sensitivity: 4 // default 7 
    127     }); 
    128  
    129     function cms_tpv_mouseover(e) { 
    130         var $this = jQuery(this); 
    131         var $li = $this.closest("li"); 
    132         cms_tpv_mouseover_li(e, $li.get(0)); 
    133     } 
    134  
    135     function cms_tpv_mouseout(e) { 
    136         var $this = jQuery(this); 
    137         var $li = $this.closest("li"); 
    138         cms_tpv_mouseout_li(e, $li.get(0)); 
    139     } 
     126    var $container = jQuery(event.target); 
     127 
     128    // when mouse enters a/link 
     129    // start timer and if no other a/link has been moused over since it started it's ok to show this one 
     130    jQuery($container).on("mouseenter", "a", function(e) { 
     131        var global_timer = $container.data("cmstpv_global_link_timer"); 
     132 
     133        if (global_timer) { 
     134            // global timer exists, so overwrite it with our new one 
     135            // stop that timer before setting ours 
     136            clearTimeout(global_timer); 
     137        } else { 
     138            // no timer exists, overwrite with ours 
     139        } 
     140        // create new timer, no matter if one exists already 
     141        var timeoutID = setTimeout(function(e) { 
     142            cms_tpv_mouseover_li(e); 
     143        }, 500, e); 
     144 
     145        $container.data("cmstpv_global_link_timer", timeoutID); 
     146 
     147    }); 
     148 
     149    /** 
     150     * When mouse down then hide the action div 
     151     */ 
     152    jQuery($container).on("mousedown", "a", function(e) { 
     153        var $target = jQuery(e.target); 
     154        var $container = $target.closest("div.cms_tpv_container"); 
     155        var $wrapper = $container.closest("div.cms_tpv_wrapper"); 
     156        $container.find("li.has-visible-actions").removeClass("has-visible-actions"); 
     157        $container.find("a.hover").removeClass("hover"); 
     158        $wrapper.find("div.cms_tpv_page_actions").removeClass("cms_tpv_page_actions_visible"); 
     159    }); 
    140160 
    141161} 
     
    246266} 
    247267 
    248 /* 
    249 jQuery(".jstree li").live("mouseover", function(e) { 
    250     var $li = jQuery(this); 
    251     var li_id = $li.attr("id"); 
    252     cms_tpv_mouseover_li(this); 
    253 }); 
    254 // ..and hide them again 
    255 jQuery(".jstree li").live("mouseout", function() { 
    256     //cms_tpv_current_li_id = null; 
    257     //console.log("out"); 
    258     cms_tpv_mouseout_li(this); 
    259 }); 
    260 */ 
    261  
    262  
    263  
    264268// fired when mouse is over li 
    265 function cms_tpv_mouseover_li(e, li) { 
    266  
    267     var $li = jQuery(li); 
    268  
    269     var div_actions_for_post_type = cms_tpv_get_page_actions_div(li); 
     269// actually when over a, old name :/ 
     270function cms_tpv_mouseover_li(e) { 
     271 
     272    var $target = jQuery(e.target); 
     273    var $li = $target.closest("li"); 
     274 
     275    var div_actions_for_post_type = cms_tpv_get_page_actions_div($li); 
    270276    var $cms_tpv_container = $li.closest("div.cms_tpv_container"); 
    271277 
    272     if (cms_tpv_is_dragging() == false) { 
     278    if (cms_tpv_is_dragging() === false) { 
    273279         
    274280        var is_visible = div_actions_for_post_type.is(":visible"); 
     
    301307            div_actions_for_post_type.find(".cms_tpv_page_actions_modified_time").text($li.data("modified_time")); 
    302308            div_actions_for_post_type.find(".cms_tpv_page_actions_modified_by").text($li.data("modified_author")); 
    303             div_actions_for_post_type.find(".cms_tpv_page_actions_page_id").text($li.data("post_id"));       
    304              
     309            div_actions_for_post_type.find(".cms_tpv_page_actions_page_id").text($li.data("post_id")); 
    305310            div_actions_for_post_type.find(".cms_tpv_page_actions_columns").html( unescape($li.data("columns")) ); 
    306311 
     
    309314             
    310315            // position and show action div 
    311             // put it inside cmstpv-hoverIntent-wrap so hoverIndent is cool with it 
    312             var $overIntentWrap = $li.find("div.cmstpv-hoverIntent-wrap:first"); 
    313             //console.log( $overIntentWrap.length ); 
     316 
     317            //console.log( jQuery(window).position() ); 
     318            //console.log( jQuery(window).offset() ); 
     319 
    314320            var $a = $li.find("a"); 
    315321            var width = $a.outerWidth(true); 
    316             //$li.append(div_actions_for_post_type); 
    317              
    318             $overIntentWrap.append(div_actions_for_post_type); 
    319              
    320322            var new_offset = div_actions_for_post_type.offset(); 
    321323            var new_offset_left = e.pageX + 35; 
    322             // check that new left offset is not to close to the left of the a 
    323             // i.e. the mouse be x px more than the a for the experience to be optimal IMHO 
    324             var diff = e.pageX - $a.offset().left; 
    325             if (diff < 25) new_offset_left = new_offset_left + 25; 
    326  
     324         
     325            new_offset_left = $a.offset().left + $a.width() + 20; 
    327326            new_offset.left = new_offset_left; 
    328327            new_offset.top = $a.offset().top - 30; 
    329328            div_actions_for_post_type.offset(new_offset); 
     329 
     330            // check if action div bottom is visible in browser window, if not move it up until it is 
     331            var pos_diff = (div_actions_for_post_type.offset().top + div_actions_for_post_type.height()) - (jQuery(window).height() + jQuery(window).scrollTop()); 
     332            if (pos_diff > 0)  { 
     333                 
     334                // set action div to begin at bottom of link instead 
     335                new_offset.top = $a.offset().top - div_actions_for_post_type.height() + 15; // <- ska bli botten på vår div 
     336                div_actions_for_post_type.offset( new_offset ); 
     337                div_actions_for_post_type.addClass("cms_tpv_page_actions_visible_from_bottom"); 
     338                 
     339            } else { 
     340                div_actions_for_post_type.removeClass("cms_tpv_page_actions_visible_from_bottom"); 
     341            } 
     342 
    330343             
    331344            // check if user is allowed to edit page 
    332345            var $cms_tpv_action_add_and_edit_page = div_actions_for_post_type.find(".cms_tpv_action_add_and_edit_page"); 
    333             if ($li.data("user_can_edit_page") == 0) { 
     346            if ($li.data("user_can_edit_page") === "0") { 
    334347                // nooope 
    335348                $edit.hide(); 
     
    347360} 
    348361 
    349 // When mouse leaves the whole cms tree page view-area/div 
     362/** 
     363 * When mouse leaves the whole cms tree page view-area/div 
     364 * hide actions div after moving mouse out of a page and not moving it on again for...a while 
     365 */ 
    350366jQuery(document).on("mouseleave", "div.cms_tpv_container", function(e) { 
    351     // hide actions div after moving mouse out of a page and not moving it on again for...a while 
    352      
    353     //var div_actions_for_post_type = cms_tpv_get_page_actions_div(li); 
    354     //var $cms_tpv_container = $li.closest("div.cms_tpv_container"); 
    355     // console.log("mouse outside container"); 
    356     var $container = jQuery(this); 
    357     jQuery.data(this, "cmstpv_do_hide_after_timeout", true); 
     367     
     368    var $container = jQuery(e.target).closest("div.cms_tpv_container"); 
     369    var $wrapper = $container.closest("div.cms_tpv_wrapper"); 
    358370    var t = this; 
    359  
    360     setTimeout(function() { 
    361         //(function() { 
    362              
    363             // check if container has data value that still tells us to hide 
    364             // this value is reseted when we enter the div again 
    365             //$cms_tpv_container 
    366             //console.log("timeout passed; hide?"); 
    367             //console.log( jQuery.data(t, "cmstpv_do_hide_after_timeout") ); 
    368             if (jQuery.data(t, "cmstpv_do_hide_after_timeout")) { 
    369                 $container.find("li.has-visible-actions").removeClass("has-visible-actions"); 
    370                 $container.find("a.hover").removeClass("hover"); 
    371                 $container.find("div.cms_tpv_page_actions").removeClass("cms_tpv_page_actions_visible"); 
    372             } 
    373  
    374         //})(); 
    375     }, 1000); 
    376  
    377 }); 
     371     
     372    // reset global timer 
     373    var global_timer = $container.data("cmstpv_global_link_timer"); 
     374    if (global_timer) { 
     375        clearTimeout(global_timer); 
     376    } 
     377 
     378    // hide popup after a short while 
     379    var hideTimer = setTimeout(function() { 
     380         
     381        // But don't hide if we are inside the popup 
     382        var $toElement = jQuery(e.toElement); 
     383        if ($toElement.hasClass("cms_tpv_page_actions")) { 
     384            // we are over the actions div, so don't hide 
     385        } else { 
     386            // somewhere else, do hide 
     387            $container.find("li.has-visible-actions").removeClass("has-visible-actions"); 
     388            $container.find("a.hover").removeClass("hover"); 
     389            $wrapper.find("div.cms_tpv_page_actions").removeClass("cms_tpv_page_actions_visible"); 
     390        } 
     391 
     392    }, 500); 
     393 
     394    $container.data("cmstpv_global_hide_timer", hideTimer); 
     395 
     396}); 
     397 
     398/// When mouse enters actions div then cancel possibly global hide timer 
     399/* 
     400jQuery(document).on("mouseenter", "div.cms_tpv_page_actions", function(e) { 
     401     
     402    var $this = jQuery(this); 
     403    var $wrapper = $this.closest("div.cms_tpv_wrapper"); 
     404    var $container = $wrapper.find("div.cms_tpv_container"); 
     405    var hideTimer = $container.data("cmstpv_global_hide_timer"); 
     406    console.log(hideTimer, "hidetimer"); 
     407    if (hideTimer) { 
     408        console.log("clearedIt!"); 
     409        clearTimeout(hideTimer); 
     410    } 
     411 
     412}); 
     413*/ 
     414 
    378415 
    379416// When mouse enter the whole cms tree page view-area/div 
    380417jQuery(document).on("mouseenter", "div.cms_tpv_container", function(e) { 
    381418 
    382     // console.log("mouse inside container, reset hide data"); 
    383419    var $container = jQuery(this); 
    384420    jQuery.data(this, "cmstpv_do_hide_after_timeout", false); 
     
    386422}); 
    387423 
    388  
    389 // fired when mouse leaves li 
    390 function cms_tpv_mouseout_li(e, li) { 
    391  
    392     var $li = jQuery(li); 
    393     var $cms_tpv_container = $li.closest("div.cms_tpv_container"); 
    394  
    395     /* 
    396     var div_actions_for_post_type = cms_tpv_get_page_actions_div(li); 
    397     var $cms_tpv_container = $li.closest("div.cms_tpv_container"); 
    398     var is_visible = div_actions_for_post_type.is(":visible"); 
    399     */ 
    400  
    401     // Remove classes if we are not viewing any 
    402     // This function can get called also when a new li has been hoverIndent:ed 
    403     /* 
    404     $li.find("a:first").removeClass("hover"); 
    405     $li.removeClass("has-visible-actions"); 
    406     if (!is_visible) { 
    407         $cms_tpv_container.removeClass("has-visible-actions"); 
    408     } 
    409     */ 
    410     //div_actions.hide(); 
    411 } 
    412  
    413  
    414 // hide action links on drag 
    415 jQuery.jstree.drag_start = function() { 
    416     jQuery(".cms_tpv_action_view, .cms_tpv_action_edit, .cms_tpv_action_add_page, .cms_tpv_action_add_page_after, .cms_tpv_action_add_page_inside").hide(); 
    417 } 
    418424 
    419425/** 
     
    517523 
    518524                // To make hoverindent work we must wrap something around the a bla bla bla 
    519  
    520                 //li.find() 
    521                 var div_wrap = jQuery("<div class='cmstpv-hoverIntent-wrap' />"); 
    522                 div_wrap.css({ 
    523                     "display": "inline-block", 
    524                     "xwidth": "100%" 
    525                 }); 
    526                 aFirst.wrap(div_wrap); 
    527  
     525                //var div_wrap = jQuery("<div class='cmstpv-hoverIntent-wrap' />"); 
     526                //aFirst.wrap(div_wrap); 
    528527 
    529528            }); 
     
    543542        $wrapper.find(".cms_tree_view_search_form_no_hits").fadeOut("fast"); 
    544543        $wrapper.find(".cms_tree_view_search_form_working").fadeIn("fast"); 
    545         $wrapper.find(".cms_tree_view_search_form_reset") 
     544        $wrapper.find(".cms_tree_view_search_form_reset"); 
    546545        $wrapper.find(".cms_tpv_container").jstree("search", s); 
    547546        $wrapper.find(".cms_tree_view_search_form_reset").fadeIn("fast"); 
  • cms-tree-page-view/trunk/scripts/jquery.jstree.js

    r623479 r625420  
    236236                            $.extend({}, this, {  
    237237                                __callback : function (data) {  
     238                                    //console.log(i); 
    238239                                    this.get_container().triggerHandler( i + '.jstree', { "inst" : this, "args" : args, "rslt" : data, "rlbk" : rlbk }); 
    239240                                }, 
  • cms-tree-page-view/trunk/styles/styles.css

    r623672 r625420  
    268268} 
    269269 
     270.cms_tpv_page_actions_visible_from_bottom:before { 
     271    top: auto; 
     272    bottom: 10px; 
     273} 
     274 
    270275.cms_tpv_page_actions.cms_tpv_page_actions_visible { 
    271276    /*display: block;*/ 
     
    284289} 
    285290*/ 
    286 li.has-visible-actions > div.cmstpv-hoverIntent-wrap:first-of-type > a:first-of-type { 
     291li.has-visible-actions > a:first-of-type { 
    287292    /*font-weight: bold;*/ 
    288     background-color: lightyellow; 
     293    background-color: #d8f5fa; 
     294} 
     295 
     296.jstree a > ins { 
     297     
    289298} 
    290299 
Note: See TracChangeset for help on using the changeset viewer.