Giter Site home page Giter Site logo

monteirosk / jquery-menu-editor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from davicotico/jquery-menu-editor

3.0 2.0 0.0 184 KB

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

Home Page: http://codeignitertutoriales.com/jquery-menu-editor-multinivel/

License: GNU General Public License v3.0

JavaScript 93.59% HTML 6.41%

jquery-menu-editor's Introduction

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 >= 1.10.2
  • Fontawesome (or another iconset)

How to use

Include the Css and scripts

<!-- the css in the <head> -->
<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">

<!-- (Recommended) Just before the closing body tag </body> -->
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/1.10.2/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='bs-iconpicker/js/iconset/iconset-fontawesome-4.2.0.min.js'></script>
<script src='bs-iconpicker/js/bootstrap-iconpicker.js'></script>
<script src='jquery-menu-editor.min.js'></script> //is just 16KB !!!

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);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.