diff --git a/.gitignore b/.gitignore index d98495eec9..0414de0317 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ /.tox/ /venv /node_modules/ +npm-debug.log diff --git a/wagtail/wagtailadmin/static/wagtailadmin/js/blocks/sequence.js b/wagtail/wagtailadmin/static/wagtailadmin/js/blocks/sequence.js index e87e6009f4..8bdf5d83c4 100644 --- a/wagtail/wagtailadmin/static/wagtailadmin/js/blocks/sequence.js +++ b/wagtail/wagtailadmin/static/wagtailadmin/js/blocks/sequence.js @@ -46,7 +46,7 @@ CODE FOR SETTING UP SPECIFIC UI WIDGETS, SUCH AS DELETE BUTTONS OR MENUS, DOES N self.container.slideDown(); // focus first suitable input found - var timeout = setTimeout(function(){ + var timeout = setTimeout(function() { $('.input input,.input textarea,.input .richtext', self.container).first().focus(); }, 250); }; @@ -76,8 +76,10 @@ CODE FOR SETTING UP SPECIFIC UI WIDGETS, SUCH AS DELETE BUTTONS OR MENUS, DOES N countField.val(newIndex + 1); return opts.prefix + '-' + newIndex; } + function setInitialMoveUpDownState(newMember) { } + function postInsertMember(newMember) { /* run any supplied initializer functions */ if (opts.onInitializeMember) { @@ -121,6 +123,7 @@ CODE FOR SETTING UP SPECIFIC UI WIDGETS, SUCH AS DELETE BUTTONS OR MENUS, DOES N for (var i = index; i < members.length; i++) { members[i].setIndex(i + 1); } + members.splice(index, 0, newMember); newMember.setIndex(index); @@ -147,6 +150,7 @@ CODE FOR SETTING UP SPECIFIC UI WIDGETS, SUCH AS DELETE BUTTONS OR MENUS, DOES N for (var i = index; i < members.length; i++) { members[i].setIndex(i + 1); } + members.splice(index, 0, newMember); newMember.setIndex(index); @@ -176,6 +180,7 @@ CODE FOR SETTING UP SPECIFIC UI WIDGETS, SUCH AS DELETE BUTTONS OR MENUS, DOES N for (var i = 0; i < members.length; i++) { members[i].setIndex(i + 1); } + members.unshift(newMember); newMember.setIndex(0); @@ -224,6 +229,7 @@ CODE FOR SETTING UP SPECIFIC UI WIDGETS, SUCH AS DELETE BUTTONS OR MENUS, DOES N /* deleting the first member; the new first member cannot move up now */ opts.onDisableMoveUp(members[0]); } + if (index === members.length && members.length > 0 && opts.onDisableMoveDown) { /* deleting the last member; the new last member cannot move down now */ opts.onDisableMoveDown(members[members.length - 1]); @@ -252,6 +258,7 @@ CODE FOR SETTING UP SPECIFIC UI WIDGETS, SUCH AS DELETE BUTTONS OR MENUS, DOES N if (opts.onDisableMoveUp) opts.onDisableMoveUp(member); if (opts.onEnableMoveUp) opts.onEnableMoveUp(swappedMember); } + if (oldIndex === (members.length - 1)) { /* member was previously the last member, and can now move down; @@ -285,6 +292,7 @@ CODE FOR SETTING UP SPECIFIC UI WIDGETS, SUCH AS DELETE BUTTONS OR MENUS, DOES N if (opts.onDisableMoveDown) opts.onDisableMoveDown(member); if (opts.onEnableMoveDown) opts.onEnableMoveDown(swappedMember); } + if (oldIndex === 0) { /* member was previously the first member, and can now move up; diff --git a/wagtail/wagtailadmin/static/wagtailadmin/js/blocks/stream.js b/wagtail/wagtailadmin/static/wagtailadmin/js/blocks/stream.js index 818d600c61..39ae14211a 100644 --- a/wagtail/wagtailadmin/static/wagtailadmin/js/blocks/stream.js +++ b/wagtail/wagtailadmin/static/wagtailadmin/js/blocks/stream.js @@ -13,22 +13,22 @@ self.inner = $('.stream-menu-inner', self.container); self.blocklist = $('ul', self.inner); - if(self.container.hasClass('stream-menu-closed')){ - self.inner.css('height',0); + if (self.container.hasClass('stream-menu-closed')) { + self.inner.css('height', 0); } - self.show = function(){ - self.inner.animate({height: self.blocklist.outerHeight()}, 250, 'swing', function(){ + self.show = function() { + self.inner.animate({height: self.blocklist.outerHeight()}, 250, 'swing', function() { $(this).height('auto'); }); self.container.removeClass('stream-menu-closed'); }; - self.hide = function(){ + self.hide = function() { self.inner.animate({height: 0}, 250) self.container.addClass('stream-menu-closed'); }; - self.toggle = function(){ - if(self.container.hasClass('stream-menu-closed')){ + self.toggle = function() { + if (self.container.hasClass('stream-menu-closed')) { self.show(); } else { self.hide(); @@ -36,7 +36,7 @@ }; /* set up show/hide on click behaviour */ - self.container.click(function(e){ + self.container.click(function(e) { e.preventDefault(); self.toggle(); }); diff --git a/wagtail/wagtailadmin/static/wagtailadmin/js/core.js b/wagtail/wagtailadmin/static/wagtailadmin/js/core.js index 21966a3bff..1734478f88 100644 --- a/wagtail/wagtailadmin/static/wagtailadmin/js/core.js +++ b/wagtail/wagtailadmin/static/wagtailadmin/js/core.js @@ -1,36 +1,36 @@ /* generic function for adding a message to message area through JS alone */ -function addMessage(status,text){ +function addMessage(status, text) { $('.messages').addClass('new').empty().append('
- if(el.html().length && !jQuery(this.options.blockElements.toString(), el).length){ - this.options.editable.execute('formatBlock', 'p'); - } - } - }); - })(jQuery); -}).call(this); \ No newline at end of file + (function(jQuery) { + return jQuery.widget("IKS.hallorequireparagraphs", { + options: { + editable: null, + uuid: '', + blockElements: ["dd", "div", "dl", "figure", "form", "ul", "ol", "table", "p", "h1", "h2", "h3", "h4", "h5", "h6"] + }, + cleanupContentClone: function(el) { + // if the editable element contains no block-level elements wrap the contents in a
+ if (el.html().length && !jQuery(this.options.blockElements.toString(), el).length) { + this.options.editable.execute('formatBlock', 'p'); + } + } + }); + })(jQuery); +}).call(this); diff --git a/wagtail/wagtailadmin/static/wagtailadmin/js/hallo-plugins/hallo-wagtaillink.js b/wagtail/wagtailadmin/static/wagtailadmin/js/hallo-plugins/hallo-wagtaillink.js index 03732110d1..e606b9e28c 100644 --- a/wagtail/wagtailadmin/static/wagtailadmin/js/hallo-plugins/hallo-wagtaillink.js +++ b/wagtail/wagtailadmin/static/wagtailadmin/js/hallo-plugins/hallo-wagtaillink.js @@ -1,74 +1,77 @@ // Generated by CoffeeScript 1.6.2 (function() { - (function($) { - return $.widget("IKS.hallowagtaillink", { - options: { - uuid: '', - editable: null - }, - populateToolbar: function(toolbar) { - var button, getEnclosingLink, widget; + (function($) { + return $.widget("IKS.hallowagtaillink", { + options: { + uuid: '', + editable: null + }, + populateToolbar: function(toolbar) { + var button, getEnclosingLink, widget; - widget = this; - getEnclosingLink = function() { - var node; + widget = this; + getEnclosingLink = function() { + var node; - node = widget.options.editable.getSelection().commonAncestorContainer; - return $(node).parents('a').get(0); - }; - button = $(''); - button.hallobutton({ - uuid: this.options.uuid, - editable: this.options.editable, - label: 'Links', - icon: 'icon-link', - command: null, - queryState: function(event) { - return button.hallobutton('checked', !!getEnclosingLink()); - } - }); - toolbar.append(button); - return button.on("click", function(event) { - var enclosingLink, lastSelection, url; + node = widget.options.editable.getSelection().commonAncestorContainer; + return $(node).parents('a').get(0); + }; + button = $(''); + button.hallobutton({ + uuid: this.options.uuid, + editable: this.options.editable, + label: 'Links', + icon: 'icon-link', + command: null, + queryState: function(event) { + return button.hallobutton('checked', !!getEnclosingLink()); + } + }); + toolbar.append(button); + return button.on("click", function(event) { + var enclosingLink, lastSelection, url; - enclosingLink = getEnclosingLink(); - if (enclosingLink) { - $(enclosingLink).replaceWith(enclosingLink.innerHTML); - button.hallobutton('checked', false); - return widget.options.editable.element.trigger('change'); - } else { - lastSelection = widget.options.editable.getSelection(); - if (lastSelection.collapsed) { - url = window.chooserUrls.pageChooser + '?allow_external_link=true&allow_email_link=true&prompt_for_link_text=true'; - } else { - url = window.chooserUrls.pageChooser + '?allow_external_link=true&allow_email_link=true'; + enclosingLink = getEnclosingLink(); + if (enclosingLink) { + $(enclosingLink).replaceWith(enclosingLink.innerHTML); + button.hallobutton('checked', false); + return widget.options.editable.element.trigger('change'); + } else { + lastSelection = widget.options.editable.getSelection(); + if (lastSelection.collapsed) { + url = window.chooserUrls.pageChooser + '?allow_external_link=true&allow_email_link=true&prompt_for_link_text=true'; + } else { + url = window.chooserUrls.pageChooser + '?allow_external_link=true&allow_email_link=true'; + } + + return ModalWorkflow({ + url: url, + responses: { + pageChosen: function(pageData) { + var a; + + a = document.createElement('a'); + a.setAttribute('href', pageData.url); + if (pageData.id) { + a.setAttribute('data-id', pageData.id); + a.setAttribute('data-linktype', 'page'); + } + + if ((!lastSelection.collapsed) && lastSelection.canSurroundContents()) { + lastSelection.surroundContents(a); + } else { + a.appendChild(document.createTextNode(pageData.title)); + lastSelection.insertNode(a); + } + + return widget.options.editable.element.trigger('change'); + } + } + }); + } + }); } - return ModalWorkflow({ - url: url, - responses: { - pageChosen: function(pageData) { - var a; - - a = document.createElement('a'); - a.setAttribute('href', pageData.url); - if (pageData.id) { - a.setAttribute('data-id', pageData.id); - a.setAttribute('data-linktype', 'page'); - } - if ((!lastSelection.collapsed) && lastSelection.canSurroundContents()) { - lastSelection.surroundContents(a); - } else { - a.appendChild(document.createTextNode(pageData.title)); - lastSelection.insertNode(a); - } - return widget.options.editable.element.trigger('change'); - } - } - }); - } }); - } - }); - })(jQuery); + })(jQuery); -}).call(this); \ No newline at end of file +}).call(this); diff --git a/wagtail/wagtailadmin/static/wagtailadmin/js/modal-workflow.js b/wagtail/wagtailadmin/static/wagtailadmin/js/modal-workflow.js index bba601468d..f70ee77b81 100644 --- a/wagtail/wagtailadmin/static/wagtailadmin/js/modal-workflow.js +++ b/wagtail/wagtailadmin/static/wagtailadmin/js/modal-workflow.js @@ -62,6 +62,7 @@ function ModalWorkflow(opts) { self.body.html(response.html); container.modal('show'); } + if (response.onload) { // if the response is a function response.onload(self); diff --git a/wagtail/wagtailadmin/static/wagtailadmin/js/page-chooser.js b/wagtail/wagtailadmin/static/wagtailadmin/js/page-chooser.js index b3488e05ad..5e3c84d650 100644 --- a/wagtail/wagtailadmin/static/wagtailadmin/js/page-chooser.js +++ b/wagtail/wagtailadmin/static/wagtailadmin/js/page-chooser.js @@ -9,6 +9,7 @@ function createPageChooser(id, pageType, openAtParentId) { if (openAtParentId) { initialUrl += openAtParentId + '/'; } + ModalWorkflow({ 'url': initialUrl, 'urlParams': {'page_type': pageType}, diff --git a/wagtail/wagtailadmin/static/wagtailadmin/js/page-editor.js b/wagtail/wagtailadmin/static/wagtailadmin/js/page-editor.js index 448d4c052a..b78990cce3 100644 --- a/wagtail/wagtailadmin/static/wagtailadmin/js/page-editor.js +++ b/wagtail/wagtailadmin/static/wagtailadmin/js/page-editor.js @@ -127,6 +127,7 @@ function initTagField(id, autocompleteUrl) { if (val && val[0] != '"' && val.indexOf(' ') > -1) { return '"' + val + '"'; } + return val; } }); @@ -135,15 +136,15 @@ function initTagField(id, autocompleteUrl) { function InlinePanel(opts) { var self = {}; - self.setHasContent = function(){ - if($('> li', self.formsUl).not(".deleted").length){ + self.setHasContent = function() { + if ($('> li', self.formsUl).not(".deleted").length) { self.formsUl.parent().removeClass('empty'); - }else{ + } else { self.formsUl.parent().addClass('empty'); } }; - self.initChildControls = function (prefix) { + self.initChildControls = function(prefix) { var childId = 'inline_child_' + prefix; var deleteInputId = 'id_' + prefix + '-DELETE'; @@ -205,7 +206,7 @@ function InlinePanel(opts) { /* Hide container on page load if it is marked as deleted. Remove the error message so that it doesn't count towards the number of errors on the tab at the top of the page. */ - if ($('#' + deleteInputId).val() === "1" ) { + if ($('#' + deleteInputId).val() === "1") { $('#' + childId).addClass('deleted').hide(0, function() { self.updateMoveButtonDisabledStates(); self.setHasContent(); @@ -226,7 +227,7 @@ function InlinePanel(opts) { } }; - self.animateSwap = function(item1, item2){ + self.animateSwap = function(item1, item2) { var parent = self.formsUl; var children = parent.children('li:visible'); @@ -234,7 +235,7 @@ function InlinePanel(opts) { // Also set it's relatively calculated height to be an absolute one, to prevent the container collapsing while its children go absolute parent.addClass('moving').css('height', parent.height()); - children.each(function(){ + children.each(function() { // console.log($(this)); $(this).css('top', $(this).position().top); }).addClass('moving'); @@ -242,13 +243,13 @@ function InlinePanel(opts) { // animate swapping around item1.animate({ top:item2.position().top - }, 200, function(){ + }, 200, function() { parent.removeClass('moving').removeAttr('style'); children.removeClass('moving').removeAttr('style'); }); item2.animate({ top:item1.position().top - }, 200, function(){ + }, 200, function() { parent.removeClass('moving').removeAttr('style'); children.removeClass('moving').removeAttr('style'); }); @@ -264,6 +265,7 @@ function InlinePanel(opts) { to ensure it's *greater* than previous item */ $('#id_' + newChildPrefix + '-ORDER').val(formCount + 1); } + self.updateMoveButtonDisabledStates(); if (opts.onAdd) opts.onAdd(); @@ -273,66 +275,67 @@ function InlinePanel(opts) { return self; } -function cleanForSlug(val, useURLify){ - if(URLify != undefined && useURLify !== false) { // Check to be sure that URLify function exists, and that we want to use it. +function cleanForSlug(val, useURLify) { + if (URLify != undefined && useURLify !== false) { // Check to be sure that URLify function exists, and that we want to use it. return URLify(val, val.length); } else { // If not just do the "replace" - return val.replace(/\s/g,"-").replace(/[^A-Za-z0-9\-]/g,"").toLowerCase(); + return val.replace(/\s/g, "-").replace(/[^A-Za-z0-9\-]/g, "").toLowerCase(); } } -function initSlugAutoPopulate(){ - $('#id_title').on('focus', function(){ +function initSlugAutoPopulate() { + $('#id_title').on('focus', function() { $('#id_slug').data('previous-val', $('#id_slug').val()); $(this).data('previous-val', $(this).val()); }); - $('#id_title').on('keyup keydown keypress blur', function(){ - if($('body').hasClass('create') || (!$('#id_slug').data('previous-val').length || cleanForSlug($('#id_title').data('previous-val')) === $('#id_slug').data('previous-val'))){ + $('#id_title').on('keyup keydown keypress blur', function() { + if ($('body').hasClass('create') || (!$('#id_slug').data('previous-val').length || cleanForSlug($('#id_title').data('previous-val')) === $('#id_slug').data('previous-val'))) { // only update slug if the page is being created from scratch, if slug is completely blank, or if title and slug prior to typing were identical $('#id_slug').val(cleanForSlug($('#id_title').val())); } }); } -function initSlugCleaning(){ - $('#id_slug').blur(function(){ +function initSlugCleaning() { + $('#id_slug').blur(function() { // if a user has just set the slug themselves, don't remove stop words etc, just illegal characters $(this).val(cleanForSlug($(this).val(), false)); }); } -function initErrorDetection(){ +function initErrorDetection() { var errorSections = {}; // first count up all the errors - $('.error-message').each(function(){ + $('.error-message').each(function() { var parentSection = $(this).closest('section'); - if(!errorSections[parentSection.attr('id')]){ + if (!errorSections[parentSection.attr('id')]) { errorSections[parentSection.attr('id')] = 0; } - errorSections[parentSection.attr('id')] = errorSections[parentSection.attr('id')]+1; + errorSections[parentSection.attr('id')] = errorSections[parentSection.attr('id')] + 1; }); // now identify them on each tab - for(var index in errorSections) { - $('.tab-nav a[href=#'+ index +']').addClass('errors').attr('data-count', errorSections[index]); + for (var index in errorSections) { + $('.tab-nav a[href=#' + index + ']').addClass('errors').attr('data-count', errorSections[index]); } } -function initCollapsibleBlocks(){ - $(".object.multi-field.collapsible").each(function(){ +function initCollapsibleBlocks() { + $(".object.multi-field.collapsible").each(function() { var $li = $(this); var $fieldset = $li.find("fieldset"); - if($li.hasClass("collapsed")){ + if ($li.hasClass("collapsed")) { $fieldset.hide(); } - $li.find("h2").click(function(){ - if(!$li.hasClass("collapsed")){ + + $li.find("h2").click(function() { + if (!$li.hasClass("collapsed")) { $li.addClass("collapsed"); $fieldset.hide("slow"); - }else{ + } else { $li.removeClass("collapsed"); $fieldset.show("show"); } @@ -356,22 +359,22 @@ $(function() { e.preventDefault(); var $this = $(this); - if(previewWindow){ + if (previewWindow) { previewWindow.close(); } previewWindow = window.open($this.data('placeholder'), $this.data('windowname')); - if(/MSIE/.test(navigator.userAgent)){ + if (/MSIE/.test(navigator.userAgent)) { // If IE, load contents immediately without fancy effects submitPreview.call($this, false); } else { - previewWindow.onload = function(){ + previewWindow.onload = function() { submitPreview.call($this, true); } } - function submitPreview(enhanced){ + function submitPreview(enhanced) { var previewDoc = previewWindow.document; $.ajax({ @@ -380,7 +383,7 @@ $(function() { data: $('#page-edit-form').serialize(), success: function(data, textStatus, request) { if (request.getResponseHeader('X-Wagtail-Preview') == 'ok') { - if(enhanced){ + if (enhanced) { var frame = previewDoc.getElementById('preview-frame'); frame = frame.contentWindow || frame.contentDocument.document || frame.contentDocument; @@ -388,10 +391,12 @@ $(function() { frame.document.write(data); frame.document.close(); - var hideTimeout = setTimeout(function(){ + var hideTimeout = setTimeout(function() { previewDoc.getElementById('loading-spinner-wrapper').className += ' remove'; clearTimeout(hideTimeout); - }) // just enough to give effect without adding discernible slowness + }) + + // just enough to give effect without adding discernible slowness } else { previewDoc.open(); previewDoc.write(data); diff --git a/wagtail/wagtailadmin/static/wagtailadmin/js/submenu.js b/wagtail/wagtailadmin/static/wagtailadmin/js/submenu.js index 8b1cbac820..2dc3b300dc 100644 --- a/wagtail/wagtailadmin/static/wagtailadmin/js/submenu.js +++ b/wagtail/wagtailadmin/static/wagtailadmin/js/submenu.js @@ -1,16 +1,16 @@ -$(function(){ +$(function() { var $explorer = $('#explorer'); - $('.nav-main .submenu-trigger').on('click', function(){ - if($(this).closest('li').find('.nav-submenu').length){ + $('.nav-main .submenu-trigger').on('click', function() { + if ($(this).closest('li').find('.nav-submenu').length) { // Close explorer menu, although it may not be instantiated yet - if($explorer.data('dlmenu') && $explorer.dlmenu('isOpen')){ + if ($explorer.data('dlmenu') && $explorer.dlmenu('isOpen')) { $explorer.dlmenu('closeMenu'); } // Close other active submenus first, if any - if($('.nav-wrapper.submenu-active').length && !$(this).closest('li').hasClass('submenu-active')){ + if ($('.nav-wrapper.submenu-active').length && !$(this).closest('li').hasClass('submenu-active')) { $('.nav-main .submenu-active, .nav-wrapper').removeClass('submenu-active'); } @@ -20,8 +20,8 @@ $(function(){ } }); - $(document).on('keydown click', function(e){ - if($('.nav-wrapper.submenu-active').length && (e.keyCode == 27 || !e.keyCode)){ + $(document).on('keydown click', function(e) { + if ($('.nav-wrapper.submenu-active').length && (e.keyCode == 27 || !e.keyCode)) { $('.nav-main .submenu-active, .nav-wrapper').removeClass('submenu-active'); } }); diff --git a/wagtail/wagtailadmin/static/wagtailadmin/js/userbar.js b/wagtail/wagtailadmin/static/wagtailadmin/js/userbar.js index 443a718eda..a749f2e119 100644 --- a/wagtail/wagtailadmin/static/wagtailadmin/js/userbar.js +++ b/wagtail/wagtailadmin/static/wagtailadmin/js/userbar.js @@ -1,17 +1,17 @@ "use strict"; -document.addEventListener('DOMContentLoaded', function(){ +document.addEventListener('DOMContentLoaded', function() { var body = document.querySelectorAll('body')[0]; var nav = document.querySelectorAll('nav')[0]; var className = 'ready'; var has_pm = window.postMessage; - if(has_pm){ + if (has_pm) { parent.postMessage("fh=" + nav.offsetHeight, '*'); } - if (body.classList){ + if (body.classList) { body.classList.add(className); - }else{ + } else { body.className += ' ' + className; } -}); \ No newline at end of file +}); diff --git a/wagtail/wagtailadmin/static/wagtailadmin/js/userbar_embed.js b/wagtail/wagtailadmin/static/wagtailadmin/js/userbar_embed.js index 2bc6bcb175..331af5ca04 100644 --- a/wagtail/wagtailadmin/static/wagtailadmin/js/userbar_embed.js +++ b/wagtail/wagtailadmin/static/wagtailadmin/js/userbar_embed.js @@ -1,29 +1,29 @@ -(function(w,d){ +(function(w, d) { "use strict"; var l, f, t, frame_height; - function callback(e){ + function callback(e) { var h; - if(e.origin !== w.wagtail.userbar.origin){return;}; + if (e.origin !== w.wagtail.userbar.origin) {return;}; // Get the height from the passed data. - try{ - h = Number(e.data.replace( /.*fh=(\d+)(?:&|$)/, '$1' ) ); - if (!isNaN( h ) && h > 0 && h !== frame_height) { + try { + h = Number(e.data.replace(/.*fh=(\d+)(?:&|$)/, '$1')); + if (!isNaN(h) && h > 0 && h !== frame_height) { f.style.opacity = 1; f.style.height = h + "px"; } - } catch(e){} + } catch (e) {} } - if(!w.wagtail) return; + if (!w.wagtail) return; - if(w.postMessage){ + if (w.postMessage) { if (w.addEventListener) { w.addEventListener('message', callback, false); } else { - w.attachEvent('onmessage', callback ); + w.attachEvent('onmessage', callback); } } @@ -39,11 +39,11 @@ f.src = w.wagtail.userbar.src; // if postMessage is supported, hide iframe till it is loaded - if(w.postMessage){ - f.style.opacity=0; + if (w.postMessage) { + f.style.opacity = 0; } t = d.getElementsByTagName('title')[0]; t.parentNode.insertBefore(l, t.nextSibling); d.body.appendChild(f); -}(window,document)); \ No newline at end of file +}(window, document)); diff --git a/wagtail/wagtaildocs/static/wagtaildocs/js/hallo-plugins/hallo-wagtaildoclink.js b/wagtail/wagtaildocs/static/wagtaildocs/js/hallo-plugins/hallo-wagtaildoclink.js index 8f713a711b..c75b512d6e 100644 --- a/wagtail/wagtaildocs/static/wagtaildocs/js/hallo-plugins/hallo-wagtaildoclink.js +++ b/wagtail/wagtaildocs/static/wagtaildocs/js/hallo-plugins/hallo-wagtaildoclink.js @@ -1,51 +1,52 @@ // Generated by CoffeeScript 1.6.2 (function() { - (function($) { - return $.widget("IKS.hallowagtaildoclink", { - options: { - uuid: '', - editable: null - }, - populateToolbar: function(toolbar) { - var button, widget; + (function($) { + return $.widget("IKS.hallowagtaildoclink", { + options: { + uuid: '', + editable: null + }, + populateToolbar: function(toolbar) { + var button, widget; - widget = this; - button = $(''); - button.hallobutton({ - uuid: this.options.uuid, - editable: this.options.editable, - label: 'Documents', - icon: 'icon-file-text-alt', - command: null - }); - toolbar.append(button); - return button.on("click", function(event) { - var lastSelection; + widget = this; + button = $(''); + button.hallobutton({ + uuid: this.options.uuid, + editable: this.options.editable, + label: 'Documents', + icon: 'icon-file-text-alt', + command: null + }); + toolbar.append(button); + return button.on("click", function(event) { + var lastSelection; - lastSelection = widget.options.editable.getSelection(); - return ModalWorkflow({ - url: window.chooserUrls.documentChooser, - responses: { - documentChosen: function(docData) { - var a; + lastSelection = widget.options.editable.getSelection(); + return ModalWorkflow({ + url: window.chooserUrls.documentChooser, + responses: { + documentChosen: function(docData) { + var a; - a = document.createElement('a'); - a.setAttribute('href', docData.url); - a.setAttribute('data-id', docData.id); - a.setAttribute('data-linktype', 'document'); - if ((!lastSelection.collapsed) && lastSelection.canSurroundContents()) { - lastSelection.surroundContents(a); - } else { - a.appendChild(document.createTextNode(docData.title)); - lastSelection.insertNode(a); - } - return widget.options.editable.element.trigger('change'); - } + a = document.createElement('a'); + a.setAttribute('href', docData.url); + a.setAttribute('data-id', docData.id); + a.setAttribute('data-linktype', 'document'); + if ((!lastSelection.collapsed) && lastSelection.canSurroundContents()) { + lastSelection.surroundContents(a); + } else { + a.appendChild(document.createTextNode(docData.title)); + lastSelection.insertNode(a); + } + + return widget.options.editable.element.trigger('change'); + } + } + }); + }); } - }); }); - } - }); - })(jQuery); + })(jQuery); -}).call(this); \ No newline at end of file +}).call(this); diff --git a/wagtail/wagtailembeds/static/wagtailembeds/js/hallo-plugins/hallo-wagtailembeds.js b/wagtail/wagtailembeds/static/wagtailembeds/js/hallo-plugins/hallo-wagtailembeds.js index eb9f1e05a1..745c18e465 100644 --- a/wagtail/wagtailembeds/static/wagtailembeds/js/hallo-plugins/hallo-wagtailembeds.js +++ b/wagtail/wagtailembeds/static/wagtailembeds/js/hallo-plugins/hallo-wagtailembeds.js @@ -1,47 +1,48 @@ // Generated by CoffeeScript 1.6.2 (function() { - (function($) { - return $.widget("IKS.hallowagtailembeds", { - options: { - uuid: '', - editable: null - }, - populateToolbar: function(toolbar) { - var button, widget; + (function($) { + return $.widget("IKS.hallowagtailembeds", { + options: { + uuid: '', + editable: null + }, + populateToolbar: function(toolbar) { + var button, widget; - widget = this; - button = $(''); - button.hallobutton({ - uuid: this.options.uuid, - editable: this.options.editable, - label: 'Embed', - icon: 'icon-media', - command: null - }); - toolbar.append(button); - return button.on("click", function(event) { - var insertionPoint, lastSelection; + widget = this; + button = $(''); + button.hallobutton({ + uuid: this.options.uuid, + editable: this.options.editable, + label: 'Embed', + icon: 'icon-media', + command: null + }); + toolbar.append(button); + return button.on("click", function(event) { + var insertionPoint, lastSelection; - lastSelection = widget.options.editable.getSelection(); - insertionPoint = $(lastSelection.endContainer).parentsUntil('.richtext').last(); - return ModalWorkflow({ - url: window.chooserUrls.embedsChooser, - responses: { - embedChosen: function(embedData) { - var elem; + lastSelection = widget.options.editable.getSelection(); + insertionPoint = $(lastSelection.endContainer).parentsUntil('.richtext').last(); + return ModalWorkflow({ + url: window.chooserUrls.embedsChooser, + responses: { + embedChosen: function(embedData) { + var elem; - elem = $(embedData).get(0); - lastSelection.insertNode(elem); - if (elem.getAttribute('contenteditable') === 'false') { - insertRichTextDeleteControl(elem); - } - return widget.options.editable.element.trigger('change'); - } + elem = $(embedData).get(0); + lastSelection.insertNode(elem); + if (elem.getAttribute('contenteditable') === 'false') { + insertRichTextDeleteControl(elem); + } + + return widget.options.editable.element.trigger('change'); + } + } + }); + }); } - }); }); - } - }); - })(jQuery); + })(jQuery); -}).call(this); \ No newline at end of file +}).call(this); diff --git a/wagtail/wagtailforms/static/wagtailforms/js/page-editor.js b/wagtail/wagtailforms/static/wagtailforms/js/page-editor.js index 8e7398133c..d9286d5243 100644 --- a/wagtail/wagtailforms/static/wagtailforms/js/page-editor.js +++ b/wagtail/wagtailforms/static/wagtailforms/js/page-editor.js @@ -1,3 +1,3 @@ -$(function(){ +$(function() { -}); \ No newline at end of file +}); diff --git a/wagtail/wagtailimages/static/wagtailimages/js/add-multiple.js b/wagtail/wagtailimages/static/wagtailimages/js/add-multiple.js index 20db7c92eb..3127676fd7 100644 --- a/wagtail/wagtailimages/static/wagtailimages/js/add-multiple.js +++ b/wagtail/wagtailimages/static/wagtailimages/js/add-multiple.js @@ -1,12 +1,12 @@ -$(function(){ +$(function() { // Redirect users that don't support filereader - if(!$('html').hasClass('filereader')){ + if (!$('html').hasClass('filereader')) { document.location.href = window.fileupload_opts.simple_upload_url; return false; } // prevents browser default drag/drop - $(document).bind('drop dragover', function (e) { + $(document).bind('drop dragover', function(e) { e.preventDefault(); }); @@ -24,7 +24,7 @@ $(function(){ acceptFileTypes: window.fileupload_opts.errormessages.accepted_file_types, maxFileSize: window.fileupload_opts.errormessages.max_file_size }, - add: function (e, data) { + add: function(e, data) { var $this = $(this); var that = $this.data('blueimp-fileupload') || $this.data('fileupload') var li = $($('#upload-list-item').html()).addClass('upload-uploading') @@ -33,27 +33,27 @@ $(function(){ $('#upload-list').append(li); data.context = li; - data.process(function () { + data.process(function() { return $this.fileupload('process', data); - }).always(function () { + }).always(function() { data.context.removeClass('processing'); - data.context.find('.left').each(function(index, elm){ + data.context.find('.left').each(function(index, elm) { $(elm).append(data.files[index].name); }); - data.context.find('.preview .thumb').each(function (index, elm) { + data.context.find('.preview .thumb').each(function(index, elm) { $(elm).addClass('hasthumb') $(elm).append(data.files[index].preview); }); - }).done(function () { + }).done(function() { data.context.find('.start').prop('disabled', false); if ((that._trigger('added', e, data) !== false) && (options.autoUpload || data.autoUpload) && data.autoUpload !== false) { data.submit() } - }).fail(function () { + }).fail(function() { if (data.files.error) { - data.context.each(function (index) { + data.context.each(function(index) { var error = data.files[index].error; if (error) { $(this).find('.error_messages').text(error); @@ -63,18 +63,18 @@ $(function(){ }); }, - processfail: function(e, data){ + processfail: function(e, data) { var itemElement = $(data.context); itemElement.removeClass('upload-uploading').addClass('upload-failure'); }, - progress: function (e, data) { + progress: function(e, data) { if (e.isDefaultPrevented()) { return false; } var progress = Math.floor(data.loaded / data.total * 100); - data.context.each(function () { + data.context.each(function() { $(this).find('.progress').addClass('active').attr('aria-valuenow', progress).find('.bar').css( 'width', progress + '%' @@ -82,23 +82,23 @@ $(function(){ }); }, - progressall: function (e, data) { + progressall: function(e, data) { var progress = parseInt(data.loaded / data.total * 100, 10); $('#overall-progress').addClass('active').attr('aria-valuenow', progress).find('.bar').css( 'width', progress + '%' ).html(progress + '%'); - if (progress >= 100){ - $('#overall-progress').removeClass('active').find('.bar').css('width','0%'); + if (progress >= 100) { + $('#overall-progress').removeClass('active').find('.bar').css('width', '0%'); } }, - done: function (e, data) { + done: function(e, data) { var itemElement = $(data.context); var response = $.parseJSON(data.result); - if(response.success){ + if (response.success) { itemElement.addClass('upload-success') $('.right', itemElement).append(response.form); @@ -112,19 +112,19 @@ $(function(){ }, - fail: function(e, data){ + fail: function(e, data) { var itemElement = $(data.context); itemElement.addClass('upload-failure'); }, - always: function(e, data){ + always: function(e, data) { var itemElement = $(data.context); itemElement.removeClass('upload-uploading').addClass('upload-complete'); }, }); // ajax-enhance forms added on done() - $('#upload-list').on('submit', 'form', function(e){ + $('#upload-list').on('submit', 'form', function(e) { var form = $(this); var itemElement = form.closest('#upload-list > li'); @@ -132,16 +132,17 @@ $(function(){ $.post(this.action, form.serialize(), function(data) { if (data.success) { - itemElement.slideUp(function(){$(this).remove()}); - }else{ + itemElement.slideUp(function() {$(this).remove()}); + } else { form.replaceWith(data.form); + // run tagit enhancement on new form $('.tag_field input', form).tagit(window.tagit_opts); } }); }); - $('#upload-list').on('click', '.delete', function(e){ + $('#upload-list').on('click', '.delete', function(e) { var form = $(this).closest('form'); var itemElement = form.closest('#upload-list > li'); @@ -151,11 +152,11 @@ $(function(){ $.post(this.href, {csrfmiddlewaretoken: CSRFToken}, function(data) { if (data.success) { - itemElement.slideUp(function(){$(this).remove()}); - }else{ + itemElement.slideUp(function() {$(this).remove()}); + } else { } }); }); -}); \ No newline at end of file +}); diff --git a/wagtail/wagtailimages/static/wagtailimages/js/focal-point-chooser.js b/wagtail/wagtailimages/static/wagtailimages/js/focal-point-chooser.js index 2ea06a4217..ee6b1efe9b 100644 --- a/wagtail/wagtailimages/static/wagtailimages/js/focal-point-chooser.js +++ b/wagtail/wagtailimages/static/wagtailimages/js/focal-point-chooser.js @@ -1,6 +1,6 @@ var jcropapi; -function setupJcrop(image, original, focalPointOriginal, fields){ +function setupJcrop(image, original, focalPointOriginal, fields) { image.Jcrop({ trueSize: [original.width, original.height], bgColor: "rgb(192, 192, 192)", @@ -21,7 +21,7 @@ function setupJcrop(image, original, focalPointOriginal, fields){ fields.width.val(focalPointOriginal.width); fields.height.val(focalPointOriginal.height); }, - }, function(){ + }, function() { jcropapi = this }); } @@ -64,7 +64,7 @@ $(function() { setupJcrop.apply(this, params) - $(window).resize($.debounce(300, function(){ + $(window).resize($.debounce(300, function() { // jcrop doesn't support responsive images so to cater for resizing the browser // we have to destroy() it, which doesn't properly do it, // so destory it some more, then re-apply it diff --git a/wagtail/wagtailimages/static/wagtailimages/js/hallo-plugins/hallo-wagtailimage.js b/wagtail/wagtailimages/static/wagtailimages/js/hallo-plugins/hallo-wagtailimage.js index a0c9bb14b0..e9d6583d25 100644 --- a/wagtail/wagtailimages/static/wagtailimages/js/hallo-plugins/hallo-wagtailimage.js +++ b/wagtail/wagtailimages/static/wagtailimages/js/hallo-plugins/hallo-wagtailimage.js @@ -1,47 +1,48 @@ // Generated by CoffeeScript 1.6.2 (function() { - (function($) { - return $.widget("IKS.hallowagtailimage", { - options: { - uuid: '', - editable: null - }, - populateToolbar: function(toolbar) { - var button, widget; + (function($) { + return $.widget("IKS.hallowagtailimage", { + options: { + uuid: '', + editable: null + }, + populateToolbar: function(toolbar) { + var button, widget; - widget = this; - button = $(''); - button.hallobutton({ - uuid: this.options.uuid, - editable: this.options.editable, - label: 'Images', - icon: 'icon-picture', - command: null - }); - toolbar.append(button); - return button.on("click", function(event) { - var insertionPoint, lastSelection; + widget = this; + button = $(''); + button.hallobutton({ + uuid: this.options.uuid, + editable: this.options.editable, + label: 'Images', + icon: 'icon-picture', + command: null + }); + toolbar.append(button); + return button.on("click", function(event) { + var insertionPoint, lastSelection; - lastSelection = widget.options.editable.getSelection(); - insertionPoint = $(lastSelection.endContainer).parentsUntil('.richtext').last(); - return ModalWorkflow({ - url: window.chooserUrls.imageChooser + '?select_format=true', - responses: { - imageChosen: function(imageData) { - var elem; + lastSelection = widget.options.editable.getSelection(); + insertionPoint = $(lastSelection.endContainer).parentsUntil('.richtext').last(); + return ModalWorkflow({ + url: window.chooserUrls.imageChooser + '?select_format=true', + responses: { + imageChosen: function(imageData) { + var elem; - elem = $(imageData.html).get(0); - lastSelection.insertNode(elem); - if (elem.getAttribute('contenteditable') === 'false') { - insertRichTextDeleteControl(elem); - } - return widget.options.editable.element.trigger('change'); - } + elem = $(imageData.html).get(0); + lastSelection.insertNode(elem); + if (elem.getAttribute('contenteditable') === 'false') { + insertRichTextDeleteControl(elem); + } + + return widget.options.editable.element.trigger('change'); + } + } + }); + }); } - }); }); - } - }); - })(jQuery); + })(jQuery); -}).call(this); \ No newline at end of file +}).call(this); diff --git a/wagtail/wagtailimages/static/wagtailimages/js/image-url-generator.js b/wagtail/wagtailimages/static/wagtailimages/js/image-url-generator.js index bc78fd5604..fbbd108361 100644 --- a/wagtail/wagtailimages/static/wagtailimages/js/image-url-generator.js +++ b/wagtail/wagtailimages/static/wagtailimages/js/image-url-generator.js @@ -48,9 +48,9 @@ $(function() { } // Display note about scaled down images if image is large - if($widthField.val() > $(window).width()){ + if ($widthField.val() > $(window).width()) { $sizeNote.show(); - }else{ + } else { $sizeNote.hide(); } diff --git a/wagtail/wagtailsearch/templates/wagtailsearch/queries/chooser_field.js b/wagtail/wagtailsearch/templates/wagtailsearch/queries/chooser_field.js index f906f90e97..911c5ea776 100644 --- a/wagtail/wagtailsearch/templates/wagtailsearch/queries/chooser_field.js +++ b/wagtail/wagtailsearch/templates/wagtailsearch/queries/chooser_field.js @@ -14,4 +14,4 @@ function createQueryChooser(id) { } }); }); -} \ No newline at end of file +}