Changeset 669399
- Timestamp:
- 02/17/2013 08:51:11 PM (13 years ago)
- Location:
- expandable-menus
- Files:
-
- 3 added
- 2 edited
-
tags/2.0 (added)
-
tags/2.0/expandable-menus.php (added)
-
tags/2.0/readme.txt (added)
-
trunk/expandable-menus.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
expandable-menus/trunk/expandable-menus.php
r607563 r669399 3 3 Plugin Name: Expandable Menus 4 4 Plugin URI: http://playforward.net 5 Description: Allows you to expand and collapse menus in WordPress admin.5 Description: Allows you to expand and collapse theme menus in WordPress admin. 6 6 Author: Dustin Dempsey 7 Version: 1.17 Version: 2.0 8 8 Author URI: http://playforward.net 9 9 */ … … 20 20 display: none; 21 21 } 22 .minimized .menu-item-handle { 23 border-right: 20px solid #298cba; 22 .minimizing .menu-item-handle, 23 .minimized .menu-item-handle, 24 .hovering .menu-item-handle { 24 25 overflow: visible !important; 25 26 } 26 .minimized .item-type { 27 position:relative; 28 left: 40px; 29 padding-right: 50px; 30 background: url("' . $plus_path . '") 60px -181px no-repeat; 31 cursor: s-resize; 32 } 33 .menu-item-custom.minimized .item-type { 34 background: url("' . $plus_path . '") 76px -181px no-repeat; 35 } 36 .expander { 27 .ie .minimizing .menu-item-handle, 28 .ie .minimized .menu-item-handle, 29 .ie .hovering .menu-item-handle { 30 border-right: 2px solid #42c038; 31 } 32 .minimized dt.menu-item-handle:after { 33 content: attr(data-content); 34 display: inline-block; 37 35 position: absolute; 38 36 top: 0px; 39 left: 420px; 37 left: 417px; 38 background: #298cba; 39 color: #fff; 40 padding-left: 10px; 41 padding-right: 10px; 42 text-shadow: none; 43 -webkit-border-radius: 3px; 44 border-radius: 3px; 45 cursor: s-resize !important; 46 min-width: 113px; 47 text-align: center; 48 } 49 .hovering dt.menu-item-handle:after { 50 content: "double-click to minimize"; 51 display: inline-block; 52 position: absolute; 53 top: 0px; 54 left: 417px; 55 background: #298cba; 56 color: #fff; 57 padding-left: 10px; 58 padding-right: 10px; 59 text-shadow: none; 60 -webkit-border-radius: 3px; 61 border-radius: 3px; 62 cursor: s-resize !important; 63 min-width: 143px; 64 text-align: center; 40 65 } 41 66 </style> 42 67 <!-- Expandable Menu Code --> 43 68 <script type="text/javascript"> 69 70 function expand_set( c_name, value, exdays ) { 71 var exdate = new Date(); 72 exdate.setDate( exdate.getDate() + exdays ); 73 var c_value = escape( value ) + ((exdays==null) ? "" : "; expires = "+exdate.toUTCString()); 74 document.cookie = c_name + "=" + c_value; 75 } 76 77 function expand_get( c_name ) { 78 var i,x,y,ARRcookies = document.cookie.split(";"); 79 for ( i=0; i<ARRcookies.length; i++ ) { 80 x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("=")); 81 y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1); 82 x=x.replace(/^\s+|\s+$/g,""); 83 if ( x == c_name ) { 84 return unescape( y ); 85 } 86 } 87 } 88 44 89 jQuery(document).ready(function(){ 45 var expand_editing = false; 46 jQuery("#menu-to-edit .item-edit").on("dblclick", function(event){ 47 expand_editing = true; 48 setTimeout(function(){ 49 expand_editing = false; 50 },100); 90 91 var cookie = expand_get( "expandable_menus" ); 92 93 // our defaults 94 var expand_depth; 95 var search_for = "menu-item-depth-"; 96 var expanding_status = true; 97 var expand_minimizing = true; 98 var depth_to_block = 9999; 99 100 101 // process element 102 var process_expand_element = function( element, depth ) { 103 104 var $this = element; 105 var $next = $this.next(); 106 var $next_class = $next.attr( "class" ); 107 var depth_next = 0; 108 109 // next element depth 110 if ( $next_class ) { 111 var classes = $next_class.split(" "); 112 jQuery.each( classes, function(index, value) { 113 if ( value.substr( 0, 16 ) == search_for) { 114 depth_next = parseInt( value.split( search_for )[1] ); 115 return depth_next; 116 } 117 }); 118 } 119 120 // minimizing? 121 if ( expand_minimizing ) { 122 123 // hide everything, easy 124 $this.addClass( "expand_hidden" ); 125 126 } else { 127 128 // expanding 129 130 // if the current depth is less than the blocked depth 131 if ( depth < depth_to_block ) { 132 133 // if element is minimized 134 if ( $this.hasClass( "minimized" ) ) { 135 136 // set new depth to block as it is already hidden 137 depth_to_block = depth_next; 138 $this.removeClass( "expand_hidden" ); 139 140 } else { 141 142 // show element 143 $this.removeClass( "expand_hidden" ); 144 } 145 } 146 } 147 148 // if the next element is deeper than the depth we started at 149 if ( depth_next > expand_depth ) { 150 151 // process next element 152 process_expand_element( $next, depth_next ); 153 154 } else { 155 156 var to_cookie = ""; 157 158 // done processing, set minimizing to minimized 159 $element = jQuery( "#menu-to-edit li.minimizing" ); 160 if ( $element ) { 161 $element.addClass( "minimized" ); 162 $element.removeClass( "minimizing" ); 163 } 164 165 // reset blocking depth 166 depth_to_block = 9999; 167 168 // set count 169 jQuery("#menu-to-edit li.minimized").each(function(){ 170 var $this = jQuery(this); 171 var id = $this.attr( "id" ); 172 var count = $this.nextUntil(":not(.expand_hidden)").length; 173 var term = "item"; 174 if ( count > 1 ) { 175 var term = "items"; 176 } 177 $this.find(".menu-item-handle").attr( "data-content", "minimized: "+count+" "+term+"" ); 178 179 // assemle cookie 180 var item = id+"|"; 181 to_cookie = to_cookie+item; 182 183 }); 184 185 // set cookie 186 to_cookie = to_cookie.slice(0,to_cookie.length-1); 187 expand_set( "expandable_menus", to_cookie, 365 ); 188 } 189 } 190 191 // on double click 192 jQuery("#menu-to-edit li").hover( function(){ 193 194 var $this = jQuery(this); 195 196 if ( !$this.hasClass("minimized") ) { 197 198 var $next = $this.next(); 199 var depth = 0; 200 var depth_next = 0; 201 202 // get current depth 203 var classes = $this.attr( "class" ).split(" "); 204 jQuery.each( classes, function(index, value) { 205 if ( value.substr( 0, 16 ) == search_for) { 206 depth = parseInt( value.split( search_for )[1] ); 207 return depth; 208 } 209 }); 210 211 212 // get next depth 213 var $next_class = $next.attr( "class" ); 214 if ( $next_class ) { 215 var classes = $next_class.split(" "); 216 jQuery.each( classes, function(index, value) { 217 if ( value.substr( 0, 16 ) == search_for) { 218 depth_next = parseInt( value.split( search_for )[1] ); 219 return depth_next; 220 } 221 }); 222 } 223 224 if ( depth_next > depth ) { 225 jQuery(this).addClass("hovering"); 226 } 227 } 228 229 },function(){ 230 jQuery(this).removeClass("hovering"); 51 231 }); 52 var the_expand_function = function(){ 53 if ( expand_editing === false ) { 54 var classes = jQuery(this).attr( "class" ).split(" "); 55 if ( jQuery(this).hasClass( "minimized" ) ) { 56 minimizing = false; 57 } 58 if ( classes ) { 59 for(var i = 0; i < classes.length; i++){ 60 if ( classes[i] ) { 61 if(classes[i].substr(0,16) == "menu-item-depth-"){ 62 var the_depth = parseInt(classes[i].split("menu-item-depth-")[1]); 63 var the_index = 0; 64 var current_element = this; 65 var children_check = false; 66 var children_depth = the_depth + 1; 67 if ( the_depth || ( the_depth == 0 ) ) { 68 setTimeout(function(){ 69 the_index = 1; 70 },2000); 71 for(var maini = 0; maini < 200; maini++){ 72 if ( the_index == 1 ) { 73 } else { 74 var next_element = jQuery(current_element).next(); 75 if ( jQuery(next_element).attr( "class" ) ) { 76 var next_classes = jQuery(next_element).attr( "class" ).split(" "); 77 if ( next_classes ) { 78 for(var nexti = 0; nexti < next_classes.length; nexti++){ 79 if ( next_classes[nexti] ) { 80 if(next_classes[nexti].substr(0,16) == "menu-item-depth-"){ 81 var next_depth = parseInt(next_classes[nexti].split("menu-item-depth-")[1]); 82 if ( next_depth || ( next_depth == 0 ) ) { 83 if ( next_depth > the_depth ) { 84 if ( children_check === true ) { 85 if ( next_depth <= children_depth ) { 86 children_check = false; 87 } 88 } 89 if ( children_check === false ) { 90 // hide/show 91 jQuery(next_element).toggleClass( "expand_hidden" ); 92 if ( jQuery(next_element).hasClass( "minimized" ) ) { 93 children_check = true; 94 children_depth = next_depth; 95 } 96 } 97 current_element = next_element; 98 var expanded = true; 99 } else { 100 // stop execution 101 the_index = 1; 102 } 103 } 104 } 105 } 106 } 107 } 108 } 109 } 110 } 111 } 112 if ( expanded === true ) { 113 jQuery(this).toggleClass( "minimized" ); 114 } 115 } 116 } 117 } 118 } 232 233 // on double click 234 jQuery("#menu-to-edit li").on( "dblclick", function(){ 235 236 var $this = jQuery(this); 237 var $next = $this.next(); 238 var depth = 0; 239 var depth_next = 0; 240 241 // get current depth 242 var classes = $this.attr( "class" ).split(" "); 243 jQuery.each( classes, function(index, value) { 244 if ( value.substr( 0, 16 ) == search_for) { 245 depth = parseInt( value.split( search_for )[1] ); 246 return depth; 247 } 248 }); 249 250 // get next depth 251 var $next_class = $next.attr( "class" ); 252 if ( $next_class ) { 253 var classes = $next_class.split(" "); 254 jQuery.each( classes, function(index, value) { 255 if ( value.substr( 0, 16 ) == search_for) { 256 depth_next = parseInt( value.split( search_for )[1] ); 257 return depth_next; 258 } 259 }); 260 } 261 262 // set depth we are working with 263 expand_depth = depth; 264 265 if ( $this.hasClass( "minimized" ) ) { 266 267 // expanding 268 expand_minimizing = false; 269 $this.removeClass( "minimized" ); 270 271 } else { 272 273 // minimizing 274 expand_minimizing = true; 275 $this.addClass( "minimizing" ); 276 } 277 278 // if next element is a child 279 if ( depth_next > depth ) { 280 281 // process next element 282 process_expand_element( $next, depth_next ); 283 284 } else { 285 286 // last element in row 287 $this.removeClass( "minimizing" ); 288 expand_minimizing = true; 289 } 290 }); 291 292 293 var process_cookie = function() { 294 295 // if we still have items in the array to process 296 if ( cookies.length > 0 ) { 297 298 // trigger double click on item 299 var current_item = cookies[0]; 300 jQuery("#"+current_item).trigger( "dblclick" ); 301 302 // remove item from array 303 cookies.splice( 0, 1 ); 304 305 // process again 306 process_cookie(); 307 119 308 } 120 309 } 121 jQuery("#menu-to-edit li").on( "dblclick", the_expand_function ); 310 311 // get minimized items and revrse array to work backwards 312 var cookies = cookie.split("|"); 313 cookies = cookies.reverse(); 314 315 // process cookie items 316 process_cookie(); 122 317 }); 123 318 </script> -
expandable-menus/trunk/readme.txt
r609845 r669399 4 4 Tags: expandable,menu,admin,collapsable 5 5 Requires at least: 3.0 6 Tested up to: 3.4.3 7 Stable tag: 1.1 6 Tested up to: 3.6 7 Stable tag: 2.0 8 License: GPLv2 or later 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html 8 10 9 Allows you to collapse and expand the WordPress admin menus(Appearance > Menus).11 Allows you to collapse and expand the WordPress admin theme menus (Appearance > Menus). 10 12 11 13 == Description == 12 14 13 When creating a menu under the "Appearance -> Menus" tab it allows you to double click to expand and collapse a menu .15 When creating a menu under the "Appearance -> Menus" tab it allows you to double click to expand and collapse a menu tree. 14 16 15 17 This is particularly useful for large menus or menus with many different sub trees that take up screen space. 16 18 19 Minimized menus will be saved as a cookie so when you return they should be minimized again. 20 21 **Requirements** 22 23 * Javascript is required. 24 * A browser that supports the :after CSS selector is required to show the minimized indicators (IE7 and IE8 may not show them). 25 17 26 **Future releases:** 18 * Images to show collapsed menus rather than just a blue marker. 19 * Double-click visual feedback. 20 * your ideas! 27 28 * Images to show collapsed menus rather than just a blue marker. 29 * Double-click visual feedback. 30 * your ideas! 21 31 22 32 == Installation == … … 32 42 = None yet = 33 43 34 Ask me some! 44 **Why isn't this working?** 45 46 * Have you tried double clicking? A lot of people dont understand you have to double click to minimize as there wasn't initially an indicator telling you to do so. 35 47 36 48 … … 43 55 44 56 = 1.0 = 57 45 58 * First Release. 46 59 47 60 = 1.1 = 61 48 62 * Fixed icon alignment issue. 63 64 = 2.0 = 65 66 * Revamped javascript. 67 * Supports over 200 menus now. 68 * Different indicators on hover and when minimized 69 * Saves minimized menus in a cookie so you don't have to minimize every time the page is loaded. 49 70 50 71 == Upgrade Notice == 51 72 52 73 = 1.0 = 74 53 75 First release 54 76 55 77 = 1.1 = 56 *Fixes icon alignment issues. 78 79 * Fixes icon alignment issues. 80 81 = 2.0 = 82 83 * Revamped javascript. 84 * Supports over 200 menus now. 85 * Different indicators on hover and when minimized 86 * Saves minimized menus in a cookie so you don't have to minimize every time the page is loaded.
Note: See TracChangeset
for help on using the changeset viewer.