Skip to content

assadnazar/jQuery-Menu-Editor

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jQuery Menu Editor

>>> DEMO

Features

This project was inspirated and based in jQuery-Sortable-lists http://camohub.github.io/jquery-sortable-lists/index.html and added many features.

The Form item editor

menu-multilevel

The Multilevel Drag & Drop

multilevel-menu

Documentation

Requirements

  • Bootstrap 3.x
  • jQuery
  • Fontawesome (or another iconset)

How to use

Include the Css and scripts

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css">
<link rel="stylesheet" href="bs-iconpicker/css/bootstrap-iconpicker.min.css">

<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js'></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src='jquery-menu-editor.js'></script>
<script src='bs-iconpicker/js/iconset/iconset-fontawesome-4.2.0.min.js'></script>
<script src='bs-iconpicker/js/bootstrap-iconpicker.js'></script>

Creating the Drag & Drop list

<div class="panel-body" id="cont">
    <ul id="myEditor" class="sortableLists list-group">
    </ul>
</div>

Creating the form

  • The inputs for items should be have the class="item-menu"
  • The icon picker should be have the id=[LIST_ID]+"_icon"
<form id="frmEdit" class="form-horizontal">
    <div class="form-group">
        <label for="text" class="col-sm-2 control-label">Text</label>
        <div class="col-sm-10">
            <div class="input-group">
                <input type="text" class="form-control item-menu" id="text" name="text" placeholder="Text">
                <div class="input-group-btn">
                    <button id="myEditor_icon" class="btn btn-default" data-iconset="fontawesome" data-icon="" type="button"></button>
                </div>
                <input type="hidden" name="icon" class="item-menu">
            </div>
        </div>
    </div>
    <div class="form-group">
        <label for="mnu_href" class="col-sm-2 control-label">URL</label>
        <div class="col-sm-10">
            <input type="text" class="form-control item-menu" id="href" name="href" placeholder="URL">
        </div>
    </div>
    <div class="form-group">
        <label for="target" class="col-sm-2 control-label">Target</label>
        <div class="col-sm-10">
            <select name="target" id="target" class="form-control item-menu">
                <option value="_self">Self</option>
                <option value="_blank">Blank</option>
                <option value="_top">Top</option>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label for="title" class="col-sm-2 control-label">Tooltip</label>
        <div class="col-sm-10">
            <input type="text" class="form-control item-menu" id="title" name="title" placeholder="Text">
        </div>
    </div>
</form>

Create and Setting the MenuEditor object

//icon picker options
var iconPickerOptions = {searchText: 'Buscar...', labelHeader: '{0} de {1} Pags.'};
//sortable list options
var sortableListOptions = {
    placeholderCss: {'background-color': 'cyan'}
};
var editor = new MenuEditor('myEditor', {listOptions: sortableListOptions, iconPicker: iconPickerOptions, labelEdit: 'Edit'});

Load data from a Json

We have the method setData:

var arrayJson = [{"href":"http://home.com","icon":"fa fa-home","text":"Home"},{"icon":"fa fa-bar-chart-o","text":"Opcion2"},{"icon":"fa fa-cloud-upload","text":"Opcion3"},{"icon":"fa fa-crop","text":"Opcion4"},{"icon":"fa fa-flask","text":"Opcion5"},{"icon":"fa fa-search","text":"Opcion7","children":[{"icon":"fa fa-plug","text":"Opcion7-1","children":[{"icon":"fa fa-filter","text":"Opcion7-2","children":[{"icon":"fa fa-map-marker","text":"Opcion6"}]}]}]}];
editor.setData(arrayJson);

Output

We have the function getString

var str = editor.getString();
$("#myTextarea").text(str);

About

Multilevel Menu Editor for Bootstrap 3.x (Html & Javascript code)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 92.5%
  • HTML 7.5%