Changeset 898873
- Timestamp:
- 04/20/2014 07:41:40 PM (12 years ago)
- File:
-
- 1 edited
-
optimized-dropdown-menus/trunk/optimized-dm.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
optimized-dropdown-menus/trunk/optimized-dm.php
r888001 r898873 42 42 $nav_menu = isset( $instance['nav_menu'] ) ? $instance['nav_menu'] : ''; 43 43 $html5 = isset( $instance['html5'] ) ? $instance['html5'] : ''; 44 $newindow = isset( $instance['new_window'] ) ? $instance['new_window'] : ''; 44 45 45 46 // Get menus … … 76 77 <label for="<?php echo $this->get_field_id( 'html5' ); ?>"> <?php echo sprintf( _x( 'Use HTML5 %s element?', '<nav>', 'optimized_dd' ), '<code><nav></code>' ); ?></label> 77 78 </p> 79 <p> 80 <input class="checkbox" type="checkbox" <?php echo ($newindow == 'on') ? 'checked="checked"' : ''; ?> id="<?php echo $this->get_field_id( 'new_window' ); ?>" name="<?php echo $this->get_field_name( 'new_window' ); ?>" /> 81 <label for="<?php echo $this->get_field_id( 'new_window' ); ?>"> <?php _e( 'Open links in new window?', 'optimized_dd' ); ?></label> 82 </p> 78 83 <?php 79 84 } 80 85 81 86 function update( $new_instance, $old_instance ) { 82 $instance['title'] = $new_instance['title']; 83 $instance['nav_menu'] = (int) $new_instance['nav_menu']; 84 $instance['html5'] = $new_instance['html5']; 87 $instance['title'] = $new_instance['title']; 88 $instance['nav_menu'] = (int) $new_instance['nav_menu']; 89 $instance['html5'] = $new_instance['html5']; 90 $instance['new_window'] = $new_instance['new_window']; 85 91 return $instance; 86 92 } … … 92 98 if ( !$nav_menu ) 93 99 return; 100 101 // links open in a new tab? 102 $link_scope_css_class = ( isset( $instance['new_window'] ) && 'on' == $instance['new_window'] ) ? 'odm-new-window' : 'odm-self-window'; 94 103 95 104 $instance['title'] = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); … … 104 113 'menu' => $nav_menu, 105 114 'container' => (($instance['html5'] == 'on') ? 'nav' : 'div'), 106 'container_class' => "odm-widget ",115 'container_class' => "odm-widget $link_scope_css_class", 107 116 'menu_id' => "odm-{$nav_menu->term_id}-widget" 108 117 ); … … 154 163 /* ref: https://gist.github.com/1918689 */ 155 164 jQuery(document).ready(function($) { 156 $('.odm-widget ul').each(function(){ 165 var $widget = $('.odm-widget'); 166 167 $('ul', $widget).each(function(){ 157 168 var list = $(this); 158 169 var select = $(document.createElement('select')) … … 167 178 list.remove(); 168 179 $(document.createElement('button')) 169 .attr('onclick','window.location.href=jQuery(\'#'+$(this).attr('id')+'\').val();') 180 .attr('onclick', 181 $widget.hasClass('odm-new-window') 182 ? 'window.open(jQuery(\'#'+$(this).attr('id')+'\').val(), \'_blank\');' 183 : 'window.location.href=jQuery(\'#'+$(this).attr('id')+'\').val();') 170 184 .html('Go') 171 185 .insertAfter(select);
Note: See TracChangeset
for help on using the changeset viewer.