fixed all linter errors... ignored modal js

pull/1237/head
Josh Barr 2015-04-25 18:38:33 +12:00
rodzic 3319d87195
commit d28e9ab3d6
30 zmienionych plików z 206 dodań i 140 usunięć

22
.jscsrc
Wyświetl plik

@ -1,6 +1,6 @@
{
"validateIndentation": 4,
"safeContextKeyword": ["_this", "widget"],
"safeContextKeyword": ["_this", "widget", "jcropapi"],
"requireSpaceBeforeKeywords": [
"else",
"while",
@ -13,8 +13,24 @@
"**/vendor/**/*.js",
"./wagtail/wagtailadmin/templates/wagtailadmin/edit_handlers/inline_panel.js",
"./wagtail/wagtailsearch/templates/wagtailsearch/editorspicks/includes/editorspicks_formset.js",
"./wagtail/wagtailusers/templates/wagtailusers/groups/includes/page_permissions_formset.js"
"./wagtail/wagtailusers/templates/wagtailusers/groups/includes/page_permissions_formset.js",
"./wagtail/wagtailsnippets/templates/wagtailsnippets/chooser/chosen.js",
"./wagtail/wagtailimages/templates/wagtailimages/chooser/image_chosen.js",
"./wagtail/wagtailimages/templates/wagtailimages/chooser/chooser.js",
"./wagtail/wagtailsearch/templates/wagtailsearch/queries/chooser/chooser.js",
"./wagtail/wagtailimages/templates/wagtailimages/chooser/select_format.js",
"./wagtail/wagtailembeds/templates/wagtailembeds/chooser/embed_chosen.js",
"./wagtail/wagtailembeds/templates/wagtailembeds/chooser/chooser.js",
"./wagtail/wagtaildocs/templates/wagtaildocs/chooser/chooser.js",
"./wagtail/wagtaildocs/templates/wagtaildocs/chooser/document_chosen.js",
"./wagtail/wagtailadmin/templates/wagtailadmin/page_privacy/set_privacy.js",
"./wagtail/wagtailadmin/templates/wagtailadmin/chooser/external_link_chosen.js",
"./wagtail/wagtailadmin/templates/wagtailadmin/chooser/external_link.js",
"./wagtail/wagtailadmin/templates/wagtailadmin/chooser/email_link.js",
"./wagtail/wagtailadmin/templates/wagtailadmin/chooser/browse.js",
"./wagtail/wagtailadmin/templates/wagtailadmin/page_privacy/set_privacy_done.js"
],
"fileExtensions": [".js"],
"preset":"airbnb"
"preset":"airbnb",
"requireCamelCaseOrUpperCaseIdentifiers": "ignoreProperties"
}

Wyświetl plik

@ -8,8 +8,8 @@
return function(elementPrefix) {
var sequence = Sequence({
'prefix': elementPrefix,
'onInitializeMember': function(sequenceMember) {
prefix: elementPrefix,
onInitializeMember: function(sequenceMember) {
/* initialize child block's JS behaviour */
if (opts.childInitializer) {
opts.childInitializer(sequenceMember.prefix + '-value');
@ -24,20 +24,25 @@
$('#' + sequenceMember.prefix + '-moveup').click(function() {
sequenceMember.moveUp();
});
$('#' + sequenceMember.prefix + '-movedown').click(function() {
sequenceMember.moveDown();
});
},
'onEnableMoveUp': function(sequenceMember) {
onEnableMoveUp: function(sequenceMember) {
$('#' + sequenceMember.prefix + '-moveup').removeClass('disabled');
},
'onDisableMoveUp': function(sequenceMember) {
onDisableMoveUp: function(sequenceMember) {
$('#' + sequenceMember.prefix + '-moveup').addClass('disabled');
},
'onEnableMoveDown': function(sequenceMember) {
onEnableMoveDown: function(sequenceMember) {
$('#' + sequenceMember.prefix + '-movedown').removeClass('disabled');
},
'onDisableMoveDown': function(sequenceMember) {
onDisableMoveDown: function(sequenceMember) {
$('#' + sequenceMember.prefix + '-movedown').addClass('disabled');
}
});

Wyświetl plik

@ -23,24 +23,30 @@ CODE FOR SETTING UP SPECIFIC UI WIDGETS, SUCH AS DELETE BUTTONS OR MENUS, DOES N
self.delete = function() {
sequence.deleteMember(self);
};
self.prependMember = function(template) {
sequence.insertMemberBefore(self, template);
};
self.appendMember = function(template) {
sequence.insertMemberAfter(self, template);
};
self.moveUp = function() {
sequence.moveMemberUp(self);
};
self.moveDown = function() {
sequence.moveMemberDown(self);
};
self._markDeleted = function() {
/* set this list member's hidden 'deleted' flag to true */
$('#' + self.prefix + '-deleted').val('1');
/* hide the list item */
self.container.fadeOut();
};
self._markAdded = function() {
self.container.hide();
self.container.slideDown();
@ -50,15 +56,18 @@ CODE FOR SETTING UP SPECIFIC UI WIDGETS, SUCH AS DELETE BUTTONS OR MENUS, DOES N
$('.input input,.input textarea,.input .richtext', self.container).first().focus();
}, 250);
};
self.getIndex = function() {
return parseInt(indexField.val(), 10);
};
self.setIndex = function(i) {
indexField.val(i);
};
return self;
};
window.Sequence = function(opts) {
var self = {};
var list = $('#' + opts.prefix + '-list');

Wyświetl plik

@ -21,12 +21,15 @@
self.inner.animate({height: self.blocklist.outerHeight()}, 250, 'swing', function() {
$(this).height('auto');
});
self.container.removeClass('stream-menu-closed');
};
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.show();
@ -67,8 +70,8 @@
return function(elementPrefix) {
var sequence = Sequence({
'prefix': elementPrefix,
'onInitializeMember': function(sequenceMember) {
prefix: elementPrefix,
onInitializeMember: function(sequenceMember) {
/* initialize child block's JS behaviour */
var blockTypeName = $('#' + sequenceMember.prefix + '-type').val();
var blockOpts = childBlocksByName[blockTypeName];
@ -81,43 +84,49 @@
$('#' + sequenceMember.prefix + '-delete').click(function() {
sequenceMember.delete();
});
/* initialise move up/down buttons */
$('#' + sequenceMember.prefix + '-moveup').click(function() {
sequenceMember.moveUp();
});
$('#' + sequenceMember.prefix + '-movedown').click(function() {
sequenceMember.moveDown();
});
/* Set up the 'append a block' menu that appears after the block */
StreamBlockMenu({
'childBlocks': opts.childBlocks,
'id': sequenceMember.prefix + '-appendmenu',
'onChooseBlock': function(childBlock) {
childBlocks: opts.childBlocks,
id: sequenceMember.prefix + '-appendmenu',
onChooseBlock: function(childBlock) {
var template = listMemberTemplates[childBlock.name];
sequenceMember.appendMember(template);
}
});
},
'onEnableMoveUp': function(sequenceMember) {
onEnableMoveUp: function(sequenceMember) {
$('#' + sequenceMember.prefix + '-moveup').removeClass('disabled');
},
'onDisableMoveUp': function(sequenceMember) {
onDisableMoveUp: function(sequenceMember) {
$('#' + sequenceMember.prefix + '-moveup').addClass('disabled');
},
'onEnableMoveDown': function(sequenceMember) {
onEnableMoveDown: function(sequenceMember) {
$('#' + sequenceMember.prefix + '-movedown').removeClass('disabled');
},
'onDisableMoveDown': function(sequenceMember) {
onDisableMoveDown: function(sequenceMember) {
$('#' + sequenceMember.prefix + '-movedown').addClass('disabled');
}
});
/* Set up the 'prepend a block' menu that appears above the first block in the sequence */
StreamBlockMenu({
'childBlocks': opts.childBlocks,
'id': elementPrefix + '-prependmenu',
'onChooseBlock': function(childBlock) {
childBlocks: opts.childBlocks,
id: elementPrefix + '-prependmenu',
onChooseBlock: function(childBlock) {
var template = listMemberTemplates[childBlock.name];
sequence.insertMemberAtStart(template);
}

Wyświetl plik

@ -29,7 +29,9 @@ $(function() {
var footerHeight = $('.footer', $(this)).height();
});
};
fitNav();
$(window).resize(function() {
fitNav();
});
@ -44,6 +46,7 @@ $(function() {
$(this).closest('fieldset').addClass('focused');
$(this).closest('li').addClass('focused');
});
$(document).on('blur mouseout', 'input,textarea,select', function() {
$(this).closest('.field').removeClass('focused');
$(this).closest('fieldset').removeClass('focused');
@ -55,6 +58,7 @@ $(function() {
e.preventDefault();
$(this).tab('show');
});
$(document).on('click', '.tab-toggle', function(e) {
e.preventDefault();
$('.tab-nav a[href="' + $(this).attr('href') + '"]').click();
@ -84,8 +88,8 @@ $(function() {
/* Header search behaviour */
if (window.headerSearch) {
var search_current_index = 0;
var search_next_index = 0;
var searchCurrentIndex = 0;
var searchNextIndex = 0;
$(window.headerSearch.termInput).on('input', function() {
clearTimeout($.data(this, 'timer'));
@ -97,21 +101,22 @@ $(function() {
$(window.headerSearch.termInput).trigger('focus');
function search() {
var workingClasses = "icon-spinner";
var workingClasses = 'icon-spinner';
$(window.headerSearch.termInput).parent().addClass(workingClasses);
search_next_index++;
var index = search_next_index;
searchNextIndex++;
var index = searchNextIndex;
$.ajax({
url: window.headerSearch.url,
data: {q: $(window.headerSearch.termInput).val()},
success: function(data, status) {
if (index > search_current_index) {
search_current_index = index;
if (index > searchCurrentIndex) {
searchCurrentIndex = index;
$(window.headerSearch.targetOutput).html(data).slideDown(800);
window.history.pushState(null, "Search results", "?q=" + $(window.headerSearch.termInput).val());
window.history.pushState(null, 'Search results', '?q=' + $(window.headerSearch.termInput).val());
}
},
complete: function() {
$(window.headerSearch.termInput).parent().removeClass(workingClasses);
}

Wyświetl plik

@ -1,7 +1,7 @@
// Generated by CoffeeScript 1.6.2
(function() {
(function(jQuery) {
return jQuery.widget("IKS.hallohr", {
return jQuery.widget('IKS.hallohr', {
options: {
editable: null,
toolbar: null,
@ -11,14 +11,14 @@
populateToolbar: function(toolbar) {
var buttonElement, buttonset;
buttonset = jQuery("<span class=\"" + this.widgetName + "\"></span>");
buttonset = jQuery('<span class="' + this.widgetName + '"></span>');
buttonElement = jQuery('<span></span>');
buttonElement.hallobutton({
uuid: this.options.uuid,
editable: this.options.editable,
label: "Horizontal rule",
command: "insertHorizontalRule",
icon: "icon-horizontalrule",
label: 'Horizontal rule',
command: 'insertHorizontalRule',
icon: 'icon-horizontalrule',
cssClass: this.options.buttonCssClass
});
buttonset.append(buttonElement);

Wyświetl plik

@ -1,10 +1,10 @@
(function() {
(function(jQuery) {
return jQuery.widget("IKS.hallorequireparagraphs", {
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"]
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 <P>

Wyświetl plik

@ -1,7 +1,7 @@
// Generated by CoffeeScript 1.6.2
(function() {
(function($) {
return $.widget("IKS.hallowagtaillink", {
return $.widget('IKS.hallowagtaillink', {
options: {
uuid: '',
editable: null
@ -16,6 +16,7 @@
node = widget.options.editable.getSelection().commonAncestorContainer;
return $(node).parents('a').get(0);
};
button = $('<span></span>');
button.hallobutton({
uuid: this.options.uuid,
@ -27,8 +28,9 @@
return button.hallobutton('checked', !!getEnclosingLink());
}
});
toolbar.append(button);
return button.on("click", function(event) {
return button.on('click', function(event) {
var enclosingLink, lastSelection, url;
enclosingLink = getEnclosingLink();

Wyświetl plik

@ -11,10 +11,10 @@ function createPageChooser(id, pageType, openAtParentId) {
}
ModalWorkflow({
'url': initialUrl,
'urlParams': {'page_type': pageType},
'responses': {
'pageChosen': function(pageData) {
url: initialUrl,
urlParams: { page_type: pageType },
responses: {
pageChosen: function(pageData) {
input.val(pageData.id);
openAtParentId = pageData.parentId;
pageTitle.text(pageData.title);

Wyświetl plik

@ -1,13 +1,13 @@
"use strict";
'use strict';
var halloPlugins = {
'halloformat': {},
'halloheadings': {formatBlocks: ["p", "h2", "h3", "h4", "h5"]},
'hallolists': {},
'hallohr': {},
'halloreundo': {},
'hallowagtaillink': {},
'hallorequireparagraphs': {}
halloformat: {},
halloheadings: {formatBlocks: ['p', 'h2', 'h3', 'h4', 'h5']},
hallolists: {},
hallohr: {},
halloreundo: {},
hallowagtaillink: {},
hallorequireparagraphs: {}
};
function registerHalloPlugin(name, opts) {
@ -75,7 +75,7 @@ function initDateChooser(id) {
$('#' + id).datetimepicker({
timepicker: false,
scrollInput:false,
format: 'Y-m-d',
format: 'Y-m-d'
});
}
}
@ -95,7 +95,7 @@ function initTimeChooser(id) {
} else {
$('#' + id).datetimepicker({
datepicker: false,
format: 'H:i',
format: 'H:i'
});
}
}
@ -113,7 +113,7 @@ function initDateTimeChooser(id) {
});
} else {
$('#' + id).datetimepicker({
format: 'Y-m-d H:i',
format: 'Y-m-d H:i'
});
}
}
@ -137,7 +137,7 @@ function InlinePanel(opts) {
var self = {};
self.setHasContent = function() {
if ($('> li', self.formsUl).not(".deleted").length) {
if ($('> li', self.formsUl).not('.deleted').length) {
self.formsUl.parent().removeClass('empty');
} else {
self.formsUl.parent().addClass('empty');
@ -159,6 +159,7 @@ function InlinePanel(opts) {
self.setHasContent();
});
});
if (opts.canOrder) {
$('#' + prefix + '-move-up').click(function() {
var currentChild = $('#' + childId);
@ -206,12 +207,13 @@ 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();
});
$('#' + childId).find(".error-message").remove();
$('#' + childId).find('.error-message').remove();
}
};
@ -247,6 +249,7 @@ function InlinePanel(opts) {
parent.removeClass('moving').removeAttr('style');
children.removeClass('moving').removeAttr('style');
});
item2.animate({
top:item1.position().top
}, 200, function() {
@ -279,7 +282,7 @@ 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();
}
}
@ -288,6 +291,7 @@ function initSlugAutoPopulate() {
$('#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'))) {
// 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
@ -324,20 +328,20 @@ function initErrorDetection() {
}
function initCollapsibleBlocks() {
$(".object.multi-field.collapsible").each(function() {
$('.object.multi-field.collapsible').each(function() {
var $li = $(this);
var $fieldset = $li.find("fieldset");
if ($li.hasClass("collapsed")) {
var $fieldset = $li.find('fieldset');
if ($li.hasClass('collapsed')) {
$fieldset.hide();
}
$li.find("h2").click(function() {
if (!$li.hasClass("collapsed")) {
$li.addClass("collapsed");
$fieldset.hide("slow");
$li.find('h2').click(function() {
if (!$li.hasClass('collapsed')) {
$li.addClass('collapsed');
$fieldset.hide('slow');
} else {
$li.removeClass("collapsed");
$fieldset.show("show");
$li.removeClass('collapsed');
$fieldset.show('show');
}
});
});
@ -378,7 +382,7 @@ $(function() {
var previewDoc = previewWindow.document;
$.ajax({
type: "POST",
type: 'POST',
url: $this.data('action'),
data: $('#page-edit-form').serialize(),
success: function(data, textStatus, request) {
@ -410,6 +414,7 @@ $(function() {
document.close();
}
},
error: function(xhr, textStatus, errorThrown) {
/* If an error occurs, display it in the preview window so that
we aren't just showing the spinner forever. We preserve the original

Wyświetl plik

@ -2,9 +2,9 @@ $(function() {
/* Interface to set permissions from the explorer / editor */
$('a.action-set-privacy').click(function() {
ModalWorkflow({
'url': this.href,
'responses': {
'setPermission': function(isPublic) {
url: this.href,
responses: {
setPermission: function(isPublic) {
if (isPublic) {
$('.privacy-indicator').removeClass('private').addClass('public');
} else {

Wyświetl plik

@ -1,12 +1,13 @@
"use strict";
'use strict';
document.addEventListener('DOMContentLoaded', function() {
var body = document.querySelectorAll('body')[0];
var nav = document.querySelectorAll('nav')[0];
var className = 'ready';
var has_pm = window.postMessage;
var hasPostMessage = window.postMessage;
if (has_pm) {
parent.postMessage("fh=" + nav.offsetHeight, '*');
if (hasPostMessage) {
parent.postMessage('fh=' + nav.offsetHeight, '*');
}
if (body.classList) {

Wyświetl plik

@ -1,18 +1,22 @@
(function(w, d) {
"use strict";
'use strict';
var l, f, t, frame_height;
var l, f, t, frameHeight;
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) {
// TODO: frameHeight is always undefined
if (!isNaN(h) && h > 0 && h !== frameHeight) {
f.style.opacity = 1;
f.style.height = h + "px";
f.style.height = h + 'px';
}
} catch (e) {}
}

Wyświetl plik

@ -5,7 +5,10 @@ var searchUrl = $('form.search-form', modal.body).attr('action');
function search() {
$.ajax({
url: searchUrl,
data: {q: $('#id_q', modal.body).val(), 'results_only': true},
data: {
q: $('#id_q', modal.body).val(),
results_only: true
},
success: function(data, status) {
$('.page-results', modal.body).html(data);
ajaxifySearchResults();

Wyświetl plik

@ -6,9 +6,9 @@ function createDocumentChooser(id) {
$('.action-choose', chooserElement).click(function() {
ModalWorkflow({
'url': window.chooserUrls.documentChooser,
'responses': {
'documentChosen': function(docData) {
url: window.chooserUrls.documentChooser,
responses: {
documentChosen: function(docData) {
input.val(docData.id);
docTitle.text(docData.title);
chooserElement.removeClass('blank');

Wyświetl plik

@ -1,7 +1,7 @@
// Generated by CoffeeScript 1.6.2
(function() {
(function($) {
return $.widget("IKS.hallowagtaildoclink", {
return $.widget('IKS.hallowagtaildoclink', {
options: {
uuid: '',
editable: null
@ -19,7 +19,7 @@
command: null
});
toolbar.append(button);
return button.on("click", function(event) {
return button.on('click', function(event) {
var lastSelection;
lastSelection = widget.options.editable.getSelection();

Wyświetl plik

@ -1,7 +1,7 @@
// Generated by CoffeeScript 1.6.2
(function() {
(function($) {
return $.widget("IKS.hallowagtailembeds", {
return $.widget('IKS.hallowagtailembeds', {
options: {
uuid: '',
editable: null
@ -18,12 +18,15 @@
icon: 'icon-media',
command: null
});
toolbar.append(button);
return button.on("click", function(event) {
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: {

Wyświetl plik

@ -40,10 +40,12 @@ $(function() {
data.context.find('.left').each(function(index, elm) {
$(elm).append(data.files[index].name);
});
data.context.find('.preview .thumb').each(function(index, elm) {
$(elm).addClass('hasthumb')
$(elm).append(data.files[index].preview);
});
}).done(function() {
data.context.find('.start').prop('disabled', false);
if ((that._trigger('added', e, data) !== false) &&
@ -120,7 +122,7 @@ $(function() {
always: function(e, data) {
var itemElement = $(data.context);
itemElement.removeClass('upload-uploading').addClass('upload-complete');
},
}
});
// ajax-enhance forms added on done()
@ -153,8 +155,6 @@ $(function() {
$.post(this.href, {csrfmiddlewaretoken: CSRFToken}, function(data) {
if (data.success) {
itemElement.slideUp(function() {$(this).remove()});
} else {
}
});
});

Wyświetl plik

@ -3,7 +3,7 @@ var jcropapi;
function setupJcrop(image, original, focalPointOriginal, fields) {
image.Jcrop({
trueSize: [original.width, original.height],
bgColor: "rgb(192, 192, 192)",
bgColor: 'rgb(192, 192, 192)',
onSelect: function(box) {
var x = Math.floor((box.x + box.x2) / 2);
var y = Math.floor((box.y + box.y2) / 2);
@ -15,12 +15,13 @@ function setupJcrop(image, original, focalPointOriginal, fields) {
fields.width.val(w);
fields.height.val(h);
},
onRelease: function() {
fields.x.val(focalPointOriginal.x);
fields.y.val(focalPointOriginal.y);
fields.width.val(focalPointOriginal.width);
fields.height.val(focalPointOriginal.height);
},
}
}, function() {
jcropapi = this
});

Wyświetl plik

@ -1,7 +1,7 @@
// Generated by CoffeeScript 1.6.2
(function() {
(function($) {
return $.widget("IKS.hallowagtailimage", {
return $.widget('IKS.hallowagtailimage', {
options: {
uuid: '',
editable: null
@ -19,7 +19,7 @@
command: null
});
toolbar.append(button);
return button.on("click", function(event) {
return button.on('click', function(event) {
var insertionPoint, lastSelection;
lastSelection = widget.options.editable.getSelection();

Wyświetl plik

@ -6,15 +6,15 @@ function createImageChooser(id) {
$('.action-choose', chooserElement).click(function() {
ModalWorkflow({
'url': window.chooserUrls.imageChooser,
'responses': {
'imageChosen': function(imageData) {
url: window.chooserUrls.imageChooser,
responses: {
imageChosen: function(imageData) {
input.val(imageData.id);
previewImage.attr({
'src': imageData.preview.url,
'width': imageData.preview.width,
'height': imageData.preview.height,
'alt': imageData.title
src: imageData.preview.url,
width: imageData.preview.width,
height: imageData.preview.height,
alt: imageData.title
});
chooserElement.removeClass('blank');
editLink.attr('href', imageData.edit_link);

Wyświetl plik

@ -1,5 +1,5 @@
$(function() {
"use strict";
'use strict';
$('.image-url-generator').each(function() {
var $this = $(this);
@ -57,12 +57,12 @@ $(function() {
// Fields with width and height
$.getJSON(generatorUrl.replace('__filterspec__', filterSpec))
.done(function(data) {
$result.val(data['url']);
$preview.attr('src', data['preview_url']);
$result.val(data.url);
$preview.attr('src', data.preview_url);
$loadingMask.removeClass('loading');
})
.fail(function(data) {
$result.val(data.responseJSON['error']);
$result.val(data.responseJSON.error);
$preview.attr('src', '');
$loadingMask.removeClass('loading');
});

Wyświetl plik

@ -6,9 +6,9 @@ function createQueryChooser(id) {
var initialUrl = '{% url "wagtailsearch_queries_chooser" %}';
ModalWorkflow({
'url': initialUrl,
'responses': {
'queryChosen': function(queryData) {
url: initialUrl,
responses: {
queryChosen: function(queryData) {
input.val(queryData.querystring);
}
}

Wyświetl plik

@ -6,9 +6,9 @@ function createSnippetChooser(id, contentType) {
$('.action-choose', chooserElement).click(function() {
ModalWorkflow({
'url': window.chooserUrls.snippetChooser + contentType + '/',
'responses': {
'snippetChosen': function(snippetData) {
url: window.chooserUrls.snippetChooser + contentType + '/',
responses: {
snippetChosen: function(snippetData) {
input.val(snippetData.id);
docTitle.text(snippetData.string);
chooserElement.removeClass('blank');

Wyświetl plik

@ -1,15 +1,15 @@
function(modal) {
function initModal(modal) {
var listingUrl = $('#snippet-chooser-list', modal.body).data('url');
function ajaxifyLinks (context) {
function ajaxifyLinks(context) {
$('a.snippet-choice', modal.body).click(function() {
modal.loadUrl(this.href);
return false;
});
$('.pagination a', context).click(function() {
var page = this.getAttribute("data-page");
var page = this.getAttribute('data-page');
setPage(page);
return false;
});
@ -19,17 +19,20 @@ function(modal) {
$.ajax({
url: listingUrl,
data: {p: page},
dataType: "html",
data: { p: page },
dataType: 'html',
success: function(data, status, xhr) {
var response = eval('(' + data + ')');
$(modal.body).html(response.html);
if (response.onload) {
response.onload(self);
}
ajaxifyLinks($('#snippet-chooser-list'));
}
});
return false;
}