require( [ "jquery" ], function ( $ ) { "use strict"; $.fn.selectimage = function ( so ) { var action = '', s, sd = { class: { wraper: 'select-image-wrap', list: 'select-image-items', item: 'select-image-item', image: 'select-image-image', element: 'select-image-element', active: 'select-image-selected', } } if ( 'string' === typeof so ) { action = so; } else { s = $.extend( true, { }, sd, so ); } return $( this ).each( function ( ) { var $this = $( this ), $parent = $this.parent( ); if ( !$this.is( 'select' ) && $this.children( ).length ) { return; } var $wraper = $parent.find( '.' + s.class.wraper ), generate_images = function ( $parentlist ) { $this.children( ).each( function ( ) { var $item = $( this ); if ( $item.is( 'optgroup' ) ) { var item_value = $item.attr( 'label' ), $li = $parentlist.find( '.' + s.class.item + '.' + s.class.item + '-optgroup[data-value="' + item_value + '"]' ), $submenu; if ( !$li.length ) { $li = $( '
  • ' ).addClass( s.class.item ).addClass( s.class.item + '-optgroup' ).attr( 'data-value', item_value ).html( $img ); $parentlist.append( $li ); } if ( !$li.children( 'span' ) ) { $li.prepend( $( '' ).text( $item ) ) } $submenu = $li.children( 'ul.' + s.class.list ); if ( !$submenu.length ) { $submenu = $( '