log warning if someone tries to use jqueryUI widgets in .user_content

closes: CNVS-30804

we have schools that are relying on this functionality
where if you give things the .enhanceable_content class
along with .dialog, .draggable, .resizable, .sortable, 
.accordion, or .tabs it will try to make jQueryUI
components out of those elements in their user
content. since we are moving away from using jqueryUI,
(and instead using components from inst-ui)
we should log a message for people to get their
stuff ready for when it is not on the page.


test plan:

* go to a rich text editor,
* go to html view
* type this:
<div class="enhanceable_content tabs">
  <ul>
    <li><a href="#tabs-1">Nunc tincidunt</a></li>
    <li><a href="#tabs-2">Proin dolor</a></li>
    <li><a href="#tabs-3">Aenean lacinia</a></li>
  </ul>
  <div id="tabs-1">
    Proin
  </div>
  <div id="tabs-2">
    Morbi
  </div>
  <div id="tabs-3">
    Mauris
  </div>
</div>

* save
* when you view the page, it should tabs 
  out of that
* it should log an error message in the developer
  console telling you that functionality is going away

Change-Id: I0e8149113cd2c864b01d8e2c2d70dea3d650f784
Reviewed-on: https://gerrit.instructure.com/87039
Tested-by: Jenkins
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
Reviewed-by: Aaron Cannon <acannon@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
This commit is contained in:
Ryan Shaw 2016-08-05 15:58:35 -06:00
parent 42188ca025
commit 6420a69728
1 changed files with 15 additions and 0 deletions

View File

@ -58,6 +58,8 @@ define([
$.trackEvent('Route', location.pathname.replace(/\/$/, '').replace(/\d+/g, '--') || '/');
var JQUERY_UI_WIDGETS_WE_TRY_TO_ENHANCE = '.dialog, .draggable, .resizable, .sortable, .accordion, .tabs';
function enhanceUserContent() {
var $content = $("#content");
$(".user_content:not(.enhanced):visible").addClass('unenhanced');
@ -68,6 +70,19 @@ define([
$this.data('unenhanced_content_html', $this.html());
})
.find(".enhanceable_content").show()
.filter(JQUERY_UI_WIDGETS_WE_TRY_TO_ENHANCE).ifExists(function($elements){
var msg =
"Deprecated use of magic jQueryUI widget markup detected:\n\n" +
"You're relying on undocumented functionality where Canvas makes " +
"jQueryUI widgets out of rich content that has the following class names: " +
JQUERY_UI_WIDGETS_WE_TRY_TO_ENHANCE + ".\n\n" +
"Canvas is moving away from jQueryUI for our own widgets and this behavior " +
"will go away. Rather than relying on the internals of Canvas's JavaScript, " +
"you should use your own custom JS file to do any such customizations."
console.error(msg, $elements);
}).end()
.filter(".dialog").each(function(){
var $dialog = $(this);
$dialog.hide();