From 045664b54f728649666e9be57b1ac3cd65aeb086 Mon Sep 17 00:00:00 2001 From: Sanj Date: Fri, 14 Sep 2012 14:45:05 +0530 Subject: [PATCH] draggable works, clean up jquery noconflict behaviour, remove un-needed plugins --- edgware/static/js/editor.js | 39 +++++++++++++++++++++++++++++++++++ edgware/templates/editor.html | 18 ++++++---------- 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/edgware/static/js/editor.js b/edgware/static/js/editor.js index 4580706..2a35035 100644 --- a/edgware/static/js/editor.js +++ b/edgware/static/js/editor.js @@ -1,4 +1,42 @@ (function($) { + + + Aloha.ready(function() { + var $aloha = Aloha.jQuery; + $aloha('.textbox_canvas_content').aloha(); + + Aloha.bind("aloha-smart-content-changed", function(e, obj) { + //var $editable = $(obj.editable.obj); + //console.log(e, obj); + var edited_obj = jQuery(obj.editable.obj); + var html = edited_obj.html(); + var boxJq = edited_obj.parents('.box'); + var boxIndex = parseInt(boxJq.attr("data-index")); + var canvasIndex = boxJq.parents('.canvas').attr("data-index"); + if (boxJq.hasClass("textBox")) { + var thisBox = edgeArticle[canvasIndex].textBoxes[boxIndex]; + } + + thisBox.setHTML(html); + + // console.log($editable.attr("data-field")); + }); + + Aloha.bind("aloha-editable-activated", function(event, properties) { + var thisElem = properties.editable; + var thisBox = $(thisElem.obj).parents(".box"); + thisBox.draggable("disable"); + + }); + + Aloha.bind("aloha-editable-deactivated", function(event, properties) { + var thisElem = properties.editable; + var thisBox = $(thisElem.obj).parents(".box"); + thisBox.draggable("enable"); + }); + }); + + //var ARTICLE_ID = 0; var BASE_URL = "http://edgwareroad.org/edit/" var edgeArticle = window.edgeArticle = []; @@ -662,6 +700,7 @@ TextBox.prototype.init = function() { // thisBox.updateCSS(css); } }); + //Aloha.jQuery(e).find(".textbox_canvas_content").aloha(); return e; }; diff --git a/edgware/templates/editor.html b/edgware/templates/editor.html index 7b6dc6d..6414ff2 100644 --- a/edgware/templates/editor.html +++ b/edgware/templates/editor.html @@ -33,29 +33,23 @@ common/table, common/list, common/link, - common/highlighteditables, common/undo, common/contenthandler, common/paste, - extra/cite, common/characterpicker, common/commands, common/block, - common/image, common/abbr, common/horizontalruler, common/align, extra/formatlesspaste, - extra/toc, extra/headerids, extra/listenforcer, extra/metaview, extra/numerated-headers, extra/ribbon, - extra/wai-lang, extra/flag-icons, extra/linkbrowser, - extra/imagebrowser, extra/cite">