Commit 411fcfd0 by Tom Giannattasio

Merge branch 'feature/bridger/new_wiki' of github.com:MITx/mitx into feature/bridger/new_wiki

parents 1411c0e0 b05bace1
var schematic_height = 480;
var schematic_width = 640;
var schematic_height = 220;
var schematic_width = 400;
var schematic_editor_height = 300;
var schematic_editor_width = 500;
$(function(){
$(document).ready(function() {
//$("a[rel*=leanModal]").leanModal(); //TODO: Make this work with the new modal library. Try and integrate this with the "slices"
$("body").append('<div id="circuit_editor" class="leanModal_box" style="z-index: 11000; left: 50%; margin-left: -250px; position: absolute; top: 100px; opacity: 1; "><div align="center">'+
'<input class="schematic" height="' + schematic_height + '" width="' + schematic_width + '" id="schematic_editor" name="schematic" type="hidden" value=""/>' +
'<input class="schematic" height="' + schematic_editor_height + '" width="' + schematic_editor_width + '" id="schematic_editor" name="schematic" type="hidden" value=""/>' +
'<button type="button" id="circuit_save_btn">save</button></div></div>');
//This is the editor that pops up as a modal
......
from django import forms
from django.forms.util import flatatt
from django.utils.encoding import force_unicode
from django.utils.html import conditional_escape
from django.utils.safestring import mark_safe
from wiki.editors.base import BaseEditor
from wiki.editors.markitup import MarkItUpAdminWidget
class CodeMirrorWidget(forms.Widget):
def __init__(self, attrs=None):
# The 'rows' and 'cols' attributes are required for HTML correctness.
default_attrs = {'class': 'markItUp',
'rows': '10', 'cols': '40',}
if attrs:
default_attrs.update(attrs)
super(CodeMirrorWidget, self).__init__(default_attrs)
def render(self, name, value, attrs=None):
if value is None: value = ''
final_attrs = self.build_attrs(attrs, name=name)
return mark_safe(u'<div><textarea%s>%s</textarea></div>' % (flatatt(final_attrs),
conditional_escape(force_unicode(value))))
class CodeMirror(BaseEditor):
editor_id = 'codemirror'
def get_admin_widget(self, instance=None):
return MarkItUpAdminWidget()
def get_widget(self, instance=None):
return CodeMirrorWidget()
class AdminMedia:
css = {
'all': ("wiki/markitup/skins/simple/style.css",
"wiki/markitup/sets/admin/style.css",)
}
js = ("wiki/markitup/admin.init.js",
"wiki/markitup/jquery.markitup.js",
"wiki/markitup/sets/admin/set.js",
)
class Media:
css = {
'all': ("js/vendor/CodeMirror/codemirror.css",)
}
js = ("js/vendor/CodeMirror/codemirror.js",
"js/vendor/CodeMirror/xml.js",
"js/vendor/CodeMirror/mitx_markdown.js",
"js/wiki/CodeMirror.init.js",
)
......@@ -297,6 +297,7 @@ SIMPLE_WIKI_REQUIRE_LOGIN_VIEW = False
################################# WIKI ###################################
WIKI_ACCOUNT_HANDLING = False
WIKI_EDITOR = 'course_wiki.editors.CodeMirror'
################################# Jasmine ###################################
JASMINE_TEST_DIRECTORY = PROJECT_ROOT + '/static/coffee'
......
$(document).ready(function() {
var editor = CodeMirror.fromTextArea(document.getElementById("id_content"), {
mode: 'mitx_markdown',
matchBrackets: true,
theme: "default",
lineWrapping: true,
});
//Store the inital contents so we can compare for unsaved changes
var initial_contents = editor.getValue();
window.onbeforeunload = function askConfirm() { //Warn the user before they navigate away
if ( editor.getValue() != initial_contents ) {
return "You have made changes to the article that have not been saved yet.";
}
};
$(".btn-primary").click(function() {
initial_contents = editor.getValue();
});
});
\ No newline at end of file
<!DOCTYPE html>
{% load compressed %}{% load sekizai_tags i18n %}{% load url from future %}
{% load compressed %}{% load sekizai_tags i18n %}{% load url from future %}{% load staticfiles %}
<html>
<head>
{% block title %}<title>edX</title>{% endblock %}
<link rel="icon" type="image/x-icon" href="${static.url('images/favicon.ico')}" />
<link rel="icon" type="image/x-icon" href="{% static "images/favicon.ico" %}" />
{% compressed_css 'application' %}
{% compressed_js 'main_vendor' %}
......
{% extends "main_django.html" %}
{% load compressed %}{% load sekizai_tags i18n %}{% load url from future %}
{% load compressed %}{% load sekizai_tags i18n %}{% load url from future %}{% load staticfiles %}
{% block title %}<title>{% block pagetitle %}{% endblock %} | edX Wiki</title>{% endblock %}
{% block headextra %}
{% compressed_css 'course' %}
<script src="{{ STATIC_URL }}js/bootstrap-alert.js"></script>
<script src="{{ STATIC_URL }}js/bootstrap-collapse.js"></script>
<script src="{{ STATIC_URL }}js/bootstrap-modal.js"></script>
<script src="{% static 'js/bootstrap-alert.js' %}"></script>
<script src="{% static 'js/bootstrap-collapse.js' %}"></script>
<script src="{% static 'js/bootstrap-modal.js' %}"></script>
<script type="text/javascript">
function ajaxError(){}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment