Sha256: 6f7315226e0be487d71fe11b512184434ad1e6d88c59ccc89701ab89345c3c42

Contents?: true

Size: 1.94 KB

Versions: 39

Compression:

Stored size: 1.94 KB

Contents

/**
* Theme: Ubold Admin Template
* Author: Coderthemes
* Code Editors page
*/

!function($) {
    "use strict";

    var CodeEditor = function() {};

    CodeEditor.prototype.getSelectedRange = function(editor) {
        return { from: editor.getCursor(true), to: editor.getCursor(false) };
    },
    CodeEditor.prototype.autoFormatSelection = function(editor) {
        var range = this.getSelectedRange(editor);
        editor.autoFormatRange(range.from, range.to);
    },
    CodeEditor.prototype.commentSelection = function(isComment, editor) {
        var range = this.getSelectedRange(editor);
        editor.commentRange(isComment, range.from, range.to);
    },
    CodeEditor.prototype.init = function() {
        var $this = this;
        //init plugin
        CodeMirror.fromTextArea(document.getElementById("code"), {
            mode: {name: "xml", alignCDATA: true},
            lineNumbers: true
        });
        //example 2
        CodeMirror.fromTextArea(document.getElementById("code2"), {
            mode: {name: "javascript"},
            lineNumbers: true,
            theme: 'ambiance'
        });

        //example 3
        var editor = CodeMirror.fromTextArea(document.getElementById("code3"), {
            mode: {name: "javascript"},
            lineNumbers: true,
        });
        CodeMirror.commands["selectAll"](editor);

        //binding controlls
        $('.autoformat').click(function(){
            $this.autoFormatSelection(editor);
        });
        
        $('.commentbtn').click(function(){
            $this.commentSelection(true, editor);
        });
        
        $('.uncomment').click(function(){
            $this.commentSelection(false, editor);
        });
    },
    //init
    $.CodeEditor = new CodeEditor, $.CodeEditor.Constructor = CodeEditor
}(window.jQuery),

//initializing 
function($) {
    "use strict";
    $.CodeEditor.init()
}(window.jQuery);

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
wbase-0.3.20 lib/vendor/admin/jquery.codemirror.init.js
wbase-0.3.19 lib/vendor/admin/jquery.codemirror.init.js
wbase-0.3.18 lib/vendor/admin/jquery.codemirror.init.js
wbase-0.3.17 lib/vendor/admin/jquery.codemirror.init.js
wbase-0.3.16 lib/vendor/admin/jquery.codemirror.init.js
wbase-0.3.15 lib/vendor/admin/jquery.codemirror.init.js
wbase-0.3.14 lib/vendor/admin/jquery.codemirror.init.js
wbase-0.3.13 lib/vendor/admin/jquery.codemirror.init.js
wbase-0.3.12 lib/vendor/admin/jquery.codemirror.init.js
wbase-0.3.11 lib/vendor/admin/jquery.codemirror.init.js
wbase-0.3.10 lib/vendor/admin/jquery.codemirror.init.js
wbase-0.3.9 lib/vendor/admin/jquery.codemirror.init.js
wbase-0.3.8 lib/vendor/admin/jquery.codemirror.init.js
wbase-0.3.7 lib/vendor/admin/jquery.codemirror.init.js
wbase-0.3.6 lib/vendor/admin/jquery.codemirror.init.js
wbase-0.3.5 lib/vendor/admin/jquery.codemirror.init.js
wbase-0.3.4 lib/vendor/admin/jquery.codemirror.init.js
wbase-0.3.3 lib/vendor/admin/jquery.codemirror.init.js
wbase-0.3.2 lib/vendor/admin/jquery.codemirror.init.js
wbase-0.3.1 lib/vendor/admin/jquery.codemirror.init.js