All Projects → rukavina → Live Css Editor

rukavina / Live Css Editor

jquery online css editor, themeroller like tool for customizing your web page

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Live Css Editor

Trumbowyg
A lightweight and amazing WYSIWYG JavaScript editor under 10kB
Stars: ✭ 3,664 (+4480%)
Mutual labels:  jquery-plugin, wysiwyg-editor
cazary
jQuery plugin of WYSIWYG editor that aims for fast, lightweight, stylish, customizable, cross-browser, and multi-language.
Stars: ✭ 12 (-85%)
Mutual labels:  jquery-plugin, wysiwyg-editor
Brickyeditor
WYSIWYG block editor jQuery plugin.
Stars: ✭ 112 (+40%)
Mutual labels:  jquery-plugin, wysiwyg-editor
Jwysiwyg
WYSIWYG jQuery Plugin
Stars: ✭ 1,076 (+1245%)
Mutual labels:  jquery-plugin, wysiwyg-editor
Covering Bad
A simple jQuery Plugin for covering an item with another item by dragging it
Stars: ✭ 75 (-6.25%)
Mutual labels:  jquery-plugin
React Page
Next-gen, highly customizable content editor for the browser - based on React and written in TypeScript. WYSIWYG on steroids.
Stars: ✭ 8,704 (+10780%)
Mutual labels:  wysiwyg-editor
Datepicker
⚠️ [Deprecated] No longer maintained. A simple jQuery datepicker plugin.
Stars: ✭ 1,133 (+1316.25%)
Mutual labels:  jquery-plugin
Ajax Image Upload
jQuery图片上传插件,支持批量上传、预览、删除、放大、上传数量和尺寸限制以及上传前、上传中和上传后的回调函数。
Stars: ✭ 59 (-26.25%)
Mutual labels:  jquery-plugin
Bootstrap Strength Meter
Password strength meter based on Twitter Bootstrap and Password Score.
Stars: ✭ 79 (-1.25%)
Mutual labels:  jquery-plugin
Richtext
WYSIWYG editor developed as jQuery plugin
Stars: ✭ 77 (-3.75%)
Mutual labels:  jquery-plugin
Jquery.toaster
jQuery plugin for displaying customizable toast notifications via Bootstrap alerts
Stars: ✭ 74 (-7.5%)
Mutual labels:  jquery-plugin
Jquery Calendar
A responsive jquery calendar scheduler built with bootstrap and moment.js
Stars: ✭ 67 (-16.25%)
Mutual labels:  jquery-plugin
Ngx Summernote
Summernote editor for Angular 😎
Stars: ✭ 76 (-5%)
Mutual labels:  wysiwyg-editor
Jtap
Tap Event for jQuery
Stars: ✭ 65 (-18.75%)
Mutual labels:  jquery-plugin
Ditherjs
A javascript library which dithers an <img> using a fixed palette
Stars: ✭ 76 (-5%)
Mutual labels:  jquery-plugin
Selectivity
Modular and light-weight selection library
Stars: ✭ 1,113 (+1291.25%)
Mutual labels:  jquery-plugin
Tokenize2
Tokenize2 is a plugin which allows your users to select multiple items from a predefined list or ajax, using autocompletion as they type to find each item. You may have seen a similar type of text entry when filling in the recipients field sending messages on facebook or tags on tumblr.
Stars: ✭ 74 (-7.5%)
Mutual labels:  jquery-plugin
Tag Handler
Tag Handler is a jQuery plugin used for managing tag-type metadata.
Stars: ✭ 76 (-5%)
Mutual labels:  jquery-plugin
Jalert
jQuery alert/modal/lightbox plugin
Stars: ✭ 73 (-8.75%)
Mutual labels:  jquery-plugin
Vue Mobiledoc Editor
A lightweight and customizable editor that allows you to embed rich content using Vuejs components.
Stars: ✭ 73 (-8.75%)
Mutual labels:  wysiwyg-editor

Live CSS Editor

Overview

Live CSS Editor (LCE) is jquery plugin, "themeroller like" tool for customizing your web page design. Basically, you provide json with configuration and LCE shows: live preview and CSS editor with ability to edit properties you defined. So you can control which properties can be customized.

Demo

http://rukavina.github.com/live-css-editor/demo

Installation and setup

You have to include this dependencies in your page (head):

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../dependencies/microtpl.js"></script>
<script type="text/javascript" src="../dependencies/jscolor/jscolor.js"></script>
<script type="text/javascript" src="../dependencies/chosen/chosen.jquery.min.js"></script>

<!-- Editor -->
<script src="../source/livecsseditor/livecsseditor-2.0.js"></script>
<script src="../source/livecsseditor/editors/lceColor.js"></script>
<script src="../source/livecsseditor/editors/lceFont.js"></script>
<script src="../source/livecsseditor/editors/lceBackground.js"></script>            

In the page's body provide div where editor will be placed - give it enough space. Note: there cannot be 2 LCEs on a single page.

<div id="livecsseditor"></div> 

Init LCE when document is ready, ex.

$(document).ready(function(){
    $('#livecsseditor').livecsseditor({
        pages: {
            'targets/simple.html': {
                name: 'First Page',
                def: {
                    'h1':{
                        name: 'Heading',
                        props:['color','background-color','font-family','font-weight','text-align'],
                        labels: ['Color','Background color','Font','Font Weight','Align'],
                        description: 'Update heading here',
                        editorsConfig:{
                            "font-family": {
                                "names": ["Verdana","Arial", "Times New Roman"]
                            }
                        },
                        iconClass: "glyphicon glyphicon-star"
                    },
                    'p,span':{
                        name: 'Text',
                        props:['font-size','color'],
                        labels: ['Font size','Color'],
                        editorsConfig:{
                            "font-size": {
                                "fixedValues": ["original","10px","11px","12px"]
                            }
                        },
                        iconClass: "glyphicon glyphicon-font"
                    }
                }
            }
        }
    });               
});

Options

option description default possible values
pages JSON definition of pages, styles and properties to be customized null Object
layout_tpl Micro template layout default template String
props_tpl Micro template property list layout default template String
hoverColor Background color or selected element in the live preview #faf3ba String

Methods

getCss( pagePath )

Get customized css string for defined page pagePath or all pages

Returns: String

  • pagePath, Type: String, Default: null
$('.selector').livecsseditor('getCss','page.html');</pre>

getJson( pagePath )

Get customized JSON Object for defined page pagePath or all pages

Returns: Object

  • pagePath, Type: String, Default: null
$('.selector').livecsseditor('getJson','page.html');</pre>

setJson( jsonObject )

Set JSON Object for customized prepared style

  • jsonObject, Type: Object, Default: null
$('.selector').livecsseditor('setJson',{
    "page.html":{
        "h1": {
            "background-color": "#F9FF40",
            "color": "#FA2B46"
        }
    }
});

Examples


Standard Setup

VIEW DEMO

Follow standard installation. Start livecsseditor when the document is ready.

$('#livecsseditor').livecsseditor({
    pages: {
        'targets/simple.html': {
            name: 'First Page',
            def: {
                'h1':{
                    name: 'Heading',
                    props:['color','background-color','font-family','font-weight','text-align'],
                    labels: ['Color','Background color','Font','Font Weight','Align'],
                    description: 'Update heading here',
                    editorsConfig:{
                        "font-family": {
                            "names": ["Verdana","Arial", "Times New Roman"]
                        }
                    },
                    iconClass: "glyphicon glyphicon-star"
                },
                'p,span':{
                    name: 'Text',
                    props:['font-size','color'],
                    labels: ['Font size','Color'],
                    editorsConfig:{
                        "font-size": {
                            "fixedValues": ["original","10px","11px","12px"]
                        }
                    },
                    iconClass: "glyphicon glyphicon-font"
                }
            }
        }
    }
});                

Options JSON has the following structure:

  • pages
    • page url URL to a page to be customized
      • name Descriptive page name
      • def
        • element css selector CSS selector of a DOM element
          • name Descriptive element name
          • props Array of editable CSS properties
          • labels Array of descriptive names of editable properties
          • description Description of the current element
          • iconClass Optional element's icons css class
          • editorsConfig Optional properties for particular editors
            • property Value for each key is configuration for particular editor

Multipage Setup

VIEW DEMO

Livecsseditor let you manage multiple pages from the same screen.


Size and Position Editors

VIEW DEMO

In this example we have included custom position and size editors for in place, WYSIWYG editing. After standard installation you need to include these 2 editors:

<script src="../source/livecsseditor/editors/lceSize.js"></script>
<script src="../source/livecsseditor/editors/lcePosition.js"></script>

Options JSON has to include definition for this properties on proper elements:

'div.resizable':{
    name:'Resizable',
    props:['width','height'],
    iconClass: "glyphicon glyphicon-fullscreen"
},
'div.movable':{
    name:'Movable',
    props:['left','top'],
    iconClass: "glyphicon glyphicon-fullscreen"
}

Note that movable element needs to have absolute position in order to be draggable.


Background image editor

VIEW DEMO

Selecting a background image for your elements is more of a backend task, thus you might want to create custom editor with integrated file manager or similar.

Still, there's a simple built-in option. Basically, it's a simple select box with predefined options provided by you.

'div.resizable':{
    name:'BG Image',
    props:['background-image'],
    labels: ['Background Image'],
    description: 'Choose BG Image',
    editorsConfig:{
        "background-image": {
            "urls": ["images/bg1.jpg","images/bg2.jpg", "images/bg3.jpg"]
        }
    },
    iconClass: "glyphicon glyphicon-fullscreen"
}

API Interaction

VIEW DEMO

livecsseditor has two methodsgetCss andgetJson for you to store somewhere definition of made customization. On the hand,setJson provides a way to load styles from JSON object:

Options JSON has to include definition for this properties on proper elements:

//css button
$('#cssBtn').click(function(){
    alert($('#livecsseditor').livecsseditor('getCss','targets/complex.html'));
});
//json get button
$('#jsonBtn').click(function(){
    console.log($('#livecsseditor').livecsseditor('getJson','targets/complex.html'));
});
//json set button
$('#jsonSetBtn').click(function(){
    $('#livecsseditor').livecsseditor('setJson',{
        "targets/complex.html":{
            "h1": {
                "background-color": "#F9FF40",
                "color": "#FA2B46"
            }
        }
    });
});

Custom Editor

VIEW DEMO

Whenever you are not satisfied with built-in editor or you need some custom editing logic, you can easily plug in your custom editing function.

In this example we attached our custom color editor. Let's say we want our users to choose just red or green color, peace of cake:

$.fn.livecsseditor.setPropertyEditor(['color','background-color'],
    function customColorEditor(customizer, vars, config){
        var $select = $('&lt;select class="form-control"&gt;&lt;/select&gt;'),
            html = '',
            options = {
                "original": "",
                "#FF0000": "Red",
                "#00FF00": "Green"
            };
        vars.container.append($select);
        for(var value in options){
            var selected = '';
            if (vars.value == value) {
                selected = ' selected="selected"';
            }
            html += '&lt;option value="' + value + '"' + selected  + '"&gt;' + options[value] + '&lt;/option&gt;';
        }
        $select.html(html).change(function(){
            vars.setValue($(this).val());
        })                    
});

We attached editor function using$.fn.livecsseditor.setPropertyEditor. Basically, we define in this call which properties we edit and callback function. During callback execution, livecsseditor provides 3 arguments:

  • customizer - livecsseditor instance
  • vars - running environment: value, setValue function, etc.
  • config - editor local configuration

Fixed values

VIEW DEMO

Whenever you want to limit available options to predefined set, there's no need to create custom editor, you can just define property editor configuration:

$('#livecsseditor').livecsseditor({
    pages: {
        'targets/complex.html': {
            name: 'Complex page',
            def: {
                'h1':{
                    name: 'Heading',
                    props:['font-size'],
                    labels: ['Font size'],
                    editorsConfig:{
                        "font-size": {
                            "fixedValues": ["14px","15px", "16px"]
                        }
                    },
                    iconClass: "glyphicon glyphicon-star"
                }                                
            }
        }
    }
});

Credits

This projects was inspired or uses the following projects:

Licence

The MIT License (MIT)

Copyright (c) 2012 Milan Rukavina

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].