Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * This file is part of the Kdyby (http://www.kdyby.org)
- *
- * Copyright (c) 2008, 2012 Filip Procházka ([email protected])
- *
- * For the full copyright and license information, please view the file license.txt that was distributed with this source code.
- */
- $(document).ready(function () {
- /**
- * @author Filip Procházka <[email protected]>
- */
- $('.kdyby-node-designer').each(function () {
- var designer = $(this);
- /**
- * Init CodeMirror on editor textareas
- */
- var editors = designer.find('textarea.code-editor');
- editors.each(function () {
- var editorTextarea = $(this);
- var editor = CodeMirror.fromTextArea(editorTextarea[0], {
- lineNumbers: true,
- mode: editorTextarea.data('editor-mode'),
- indentUnit: 4,
- indentWithTabs: true,
- tabMode: "indent"
- });
- editorTextarea.data('code-editor', editor);
- });
- /**
- * Fix CodeMirror when changing tabs
- */
- designer.on('click.tab.data-api', '[data-toggle="tab"]', function (e) {
- window.setTimeout(function () {
- editors.each(function () {
- var editor = $(this).data('code-editor');
- if (editor) editor.refresh();
- });
- }, 100);
- });
- /**
- * When CTRL+S is hit inside designer, it tries to find first input:submit with primary class
- * and send a form with it, otherwise just finds the first button and submits with it.
- */
- designer.on('keydown', '*', function (e) {
- if (!e.altKey && !e.metaKey && e.ctrlKey && e.which === 83) {
- var form = $(e.target).closest('form');
- var firstSubmit = form.find('.nav-actions input.btn-primary:submit');
- if (!firstSubmit.length) {
- firstSubmit = form.find('.nav-actions input:submit:first');
- }
- $.nette.ajax({
- cache: false
- }, firstSubmit[0], e);
- }
- });
- /**
- * When in addComponent wizard user clicks on socket, submit form.
- */
- designer.find('.kdyby-choose-container').on('click', 'input:radio', function () {
- designer.find('.nav-actions input[name*=continue]').click();
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment