Skip to content

Commit

Permalink
Updated to current version
Browse files Browse the repository at this point in the history
  • Loading branch information
mikima committed Apr 3, 2018
1 parent 2ba6e83 commit 022512b
Show file tree
Hide file tree
Showing 378 changed files with 28,464 additions and 21,877 deletions.
4 changes: 2 additions & 2 deletions baldessari/admin/css/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -796,15 +796,15 @@ table#change-history tbody th {
font-size: 18px;
margin: 8px 0;
font-weight: normal;
color: #f4f379;
color: #11bfcf;
}

#branding h2 {
padding: 0 10px;
font-size: 14px;
margin: -8px 0 8px 0;
font-weight: normal;
color: #ffc;
color: #11bfcf;
}

#user-tools {
Expand Down
41 changes: 23 additions & 18 deletions baldessari/admin/js/SelectFilter2.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ window.SelectFilter = {
// Move help text up to the top so it isn't below the select
// boxes or wrapped off on the side to the right of the add
// button:
from_box.parentNode.insertBefore(ps[i], from_box.parentNode.firstChild);
// from_box.parentNode.insertBefore(ps[i], from_box.parentNode.firstChild);
// GRAPPELLI CUSTOM: remove help-text, because trusted editors should know what to do
from_box.parentNode.removeChild(ps[i]);
}
}

Expand All @@ -43,14 +45,15 @@ window.SelectFilter = {
var selector_available = quickElement('div', selector_div, '');
selector_available.className = 'selector-available';
var title_available = quickElement('h2', selector_available, interpolate(gettext('Available %s') + ' ', [field_name]));
quickElement('img', title_available, '', 'src', admin_media_prefix + 'img/icon-unknown.gif', 'width', '10', 'height', '10', 'class', 'help help-tooltip', 'title', interpolate(gettext('This is the list of available %s. You may choose some by selecting them in the box below and then clicking the "Choose" arrow between the two boxes.'), [field_name]));
// GRAPPELLI CUSTOM: removed help-icon (trusted editors should know what to do)
// quickElement('img', title_available, '', 'src', admin_media_prefix + 'img/icon-unknown.gif', 'width', '10', 'height', '10', 'class', 'help help-tooltip', 'title', interpolate(gettext('This is the list of available %s. You may choose some by selecting them in the box below and then clicking the "Choose" arrow between the two boxes.'), [field_name]));

var filter_p = quickElement('p', selector_available, '', 'id', field_id + '_filter');
filter_p.className = 'selector-filter';

var search_filter_label = quickElement('label', filter_p, '', 'for', field_id + "_input");

var search_selector_img = quickElement('img', search_filter_label, '', 'src', admin_media_prefix + 'img/selector-search.gif', 'class', 'help-tooltip', 'alt', '', 'title', interpolate(gettext("Type into this box to filter down the list of available %s."), [field_name]));
// GRAPPELLI CUSTOM: removed search-icon as it is provided via css
// var search_selector_img = quickElement('img', search_filter_label, '', 'src', admin_media_prefix + 'img/selector-search.gif', 'class', 'help-tooltip', 'alt', '', 'title', interpolate(gettext("Type into this box to filter down the list of available %s."), [field_name]));

filter_p.appendChild(document.createTextNode(' '));

Expand All @@ -73,7 +76,8 @@ window.SelectFilter = {
var selector_chosen = quickElement('div', selector_div, '');
selector_chosen.className = 'selector-chosen';
var title_chosen = quickElement('h2', selector_chosen, interpolate(gettext('Chosen %s') + ' ', [field_name]));
quickElement('img', title_chosen, '', 'src', admin_media_prefix + 'img/icon-unknown.gif', 'width', '10', 'height', '10', 'class', 'help help-tooltip', 'title', interpolate(gettext('This is the list of chosen %s. You may remove some by selecting them in the box below and then clicking the "Remove" arrow between the two boxes.'), [field_name]));
// GRAPPELLI CUSTOM: removed help-icon (trusted editors should know what to do)
// quickElement('img', title_chosen, '', 'src', admin_media_prefix + 'img/icon-unknown.gif', 'width', '10', 'height', '10', 'class', 'help help-tooltip', 'title', interpolate(gettext('This is the list of chosen %s. You may remove some by selecting them in the box below and then clicking the "Remove" arrow between the two boxes.'), [field_name]));

var to_box = quickElement('select', selector_chosen, '', 'id', field_id + '_to', 'multiple', 'multiple', 'size', from_box.size, 'name', from_box.getAttribute('name'));
to_box.className = 'filtered';
Expand All @@ -95,18 +99,19 @@ window.SelectFilter = {
// Move selected from_box options to to_box
SelectBox.move(field_id + '_from', field_id + '_to');

if (!is_stacked) {
// In horizontal mode, give the same height to the two boxes.
var j_from_box = $(from_box);
var j_to_box = $(to_box);
var resize_filters = function() { j_to_box.height($(filter_p).outerHeight() + j_from_box.outerHeight()); }
if (j_from_box.outerHeight() > 0) {
resize_filters(); // This fieldset is already open. Resize now.
} else {
// This fieldset is probably collapsed. Wait for its 'show' event.
j_to_box.closest('fieldset').one('show.fieldset', resize_filters);
}
}
// GRAPPELLI: We don't need this as we assigned a fixed height to the elements
// if (!is_stacked) {
// // In horizontal mode, give the same height to the two boxes.
// var j_from_box = $(from_box);
// var j_to_box = $(to_box);
// var resize_filters = function() { j_to_box.height($(filter_p).outerHeight() + j_from_box.outerHeight()); }
// if (j_from_box.outerHeight() > 0) {
// resize_filters(); // This fieldset is already open. Resize now.
// } else {
// // This fieldset is probably collapsed. Wait for its 'show' event.
// j_to_box.closest('fieldset').one('show.fieldset', resize_filters);
// }
// }

// Initial icon refresh
SelectFilter.refresh_icons(field_id);
Expand Down Expand Up @@ -158,4 +163,4 @@ window.SelectFilter = {
}
}

})(django.jQuery);
})(grp.jQuery);
274 changes: 136 additions & 138 deletions baldessari/admin/js/actions.js
Original file line number Diff line number Diff line change
@@ -1,139 +1,137 @@
/**
* GRAPPELLI ACTIONS.JS
* minor modifications compared with the original js
*
*/

(function($) {
$.fn.actions = function(opts) {
var options = $.extend({}, $.fn.actions.defaults, opts);
var actionCheckboxes = $(this);
var list_editable_changed = false;
checker = function(checked) {
if (checked) {
showQuestion();
} else {
reset();
}
$(actionCheckboxes).attr("checked", checked)
.parent().parent().toggleClass(options.selectedClass, checked);
}
updateCounter = function() {
var sel = $(actionCheckboxes).filter(":checked").length;
$(options.counterContainer).html(interpolate(
ngettext('%(sel)s of %(cnt)s selected', '%(sel)s of %(cnt)s selected', sel), {
sel: sel,
cnt: _actions_icnt
}, true));
$(options.allToggle).attr("checked", function() {
if (sel == actionCheckboxes.length) {
value = true;
showQuestion();
} else {
value = false;
clearAcross();
}
return value;
});
}
showQuestion = function() {
$(options.acrossClears).hide();
$(options.acrossQuestions).show();
$(options.allContainer).hide();
}
showClear = function() {
$(options.acrossClears).show();
$(options.acrossQuestions).hide();
$(options.actionContainer).toggleClass(options.selectedClass);
$(options.allContainer).show();
$(options.counterContainer).hide();
}
reset = function() {
$(options.acrossClears).hide();
$(options.acrossQuestions).hide();
$(options.allContainer).hide();
$(options.counterContainer).show();
}
clearAcross = function() {
reset();
$(options.acrossInput).val(0);
$(options.actionContainer).removeClass(options.selectedClass);
}
// Show counter by default
$(options.counterContainer).show();
// Check state of checkboxes and reinit state if needed
$(this).filter(":checked").each(function(i) {
$(this).parent().parent().toggleClass(options.selectedClass);
updateCounter();
if ($(options.acrossInput).val() == 1) {
showClear();
}
});
$(options.allToggle).show().click(function() {
checker($(this).attr("checked"));
updateCounter();
});
$("div.actions span.question a").click(function(event) {
event.preventDefault();
$(options.acrossInput).val(1);
showClear();
});
$("div.actions span.clear a").click(function(event) {
event.preventDefault();
$(options.allToggle).attr("checked", false);
clearAcross();
checker(0);
updateCounter();
});
lastChecked = null;
$(actionCheckboxes).click(function(event) {
if (!event) { var event = window.event; }
var target = event.target ? event.target : event.srcElement;
if (lastChecked && $.data(lastChecked) != $.data(target) && event.shiftKey == true) {
var inrange = false;
$(lastChecked).attr("checked", target.checked)
.parent().parent().toggleClass(options.selectedClass, target.checked);
$(actionCheckboxes).each(function() {
if ($.data(this) == $.data(lastChecked) || $.data(this) == $.data(target)) {
inrange = (inrange) ? false : true;
}
if (inrange) {
$(this).attr("checked", target.checked)
.parent().parent().toggleClass(options.selectedClass, target.checked);
}
});
}
$(target).parent().parent().toggleClass(options.selectedClass, target.checked);
lastChecked = target;
updateCounter();
});
$('form#changelist-form table#result_list tr').find('td:gt(0) :input').change(function() {
list_editable_changed = true;
});
$('form#changelist-form button[name="index"]').click(function(event) {
if (list_editable_changed) {
return confirm(gettext("You have unsaved changes on individual editable fields. If you run an action, your unsaved changes will be lost."));
}
});
$('form#changelist-form input[name="_save"]').click(function(event) {
var action_changed = false;
$('div.actions select option:selected').each(function() {
if ($(this).val()) {
action_changed = true;
}
});
if (action_changed) {
if (list_editable_changed) {
return confirm(gettext("You have selected an action, but you haven't saved your changes to individual fields yet. Please click OK to save. You'll need to re-run the action."));
} else {
return confirm(gettext("You have selected an action, and you haven't made any changes on individual fields. You're probably looking for the Go button rather than the Save button."));
}
}
});
}
/* Setup plugin defaults */
$.fn.actions.defaults = {
actionContainer: "div.actions",
counterContainer: "span.action-counter",
allContainer: "div.actions span.all",
acrossInput: "div.actions input.select-across",
acrossQuestions: "div.actions span.question",
acrossClears: "div.actions span.clear",
allToggle: "#action-toggle",
selectedClass: "selected"
}
})(django.jQuery);
$.fn.actions = function(opts) {
var options = $.extend({}, $.fn.actions.defaults, opts);
var actionCheckboxes = $(this);
var list_editable_changed = false;
checker = function(checked) {
if (checked) {
showQuestion();
$(actionCheckboxes).attr("checked", true)
.parent().parent().addClass(options.selectedClass);
} else {
reset();
$(actionCheckboxes).attr("checked", false)
.parent().parent().removeClass(options.selectedClass);
}
};
updateCounter = function() {
var sel = $(actionCheckboxes).filter(":checked").length;
$(options.counterContainer).html(interpolate(
ngettext('%(sel)s of %(cnt)s selected', '%(sel)s of %(cnt)s selected', sel), {
sel: sel,
cnt: _actions_icnt
}, true));
$(options.allToggle).attr("checked", function() {
if (sel == actionCheckboxes.length) {
value = true;
showQuestion();
} else {
value = false;
clearAcross();
}
return value;
});
};
showQuestion = function() {
$(options.acrossClears).hide();
$(options.acrossQuestions).show();
$(options.allContainer).hide();
};
showClear = function() {
$(options.acrossClears).show();
$(options.acrossQuestions).hide();
$(options.actionContainer).toggleClass(options.selectedClass);
$(options.allContainer).show();
$(options.counterContainer).hide();
$(options.counterContainer).parent('li').hide();
};
reset = function() {
$(options.acrossClears).hide();
$(options.acrossQuestions).hide();
$(options.allContainer).hide();
$(options.counterContainer).show();
$(options.counterContainer).parent('li').show();
};
clearAcross = function() {
reset();
$(options.acrossInput).val(0);
$(options.actionContainer).removeClass(options.selectedClass);
};
// Show counter by default
$(options.counterContainer).show();
// Check state of checkboxes and reinit state if needed
$(this).filter(":checked").each(function(i) {
$(this).parent().parent().toggleClass(options.selectedClass);
updateCounter();
if ($(options.acrossInput).val() == 1) {
showClear();
}
});
$(options.allToggle).show().click(function() {
checker($(this).attr("checked"));
updateCounter();
});
$("div.grp-changelist-actions li.grp-question a").click(function(event) {
event.preventDefault();
$(options.acrossInput).val(1);
showClear();
});
$("div.grp-changelist-actions li.grp-clear-selection a").click(function(event) {
event.preventDefault();
$(options.allToggle).attr("checked", false);
clearAcross();
checker(0);
updateCounter();
});
lastChecked = null;
$(actionCheckboxes).click(function(event) {
if (!event) { var event = window.event; }
var target = event.target ? event.target : event.srcElement;
if (lastChecked && $.data(lastChecked) != $.data(target) && event.shiftKey === true) {
var inrange = false;
$(lastChecked).attr("checked", target.checked)
.parent().parent().toggleClass(options.selectedClass, target.checked);
$(actionCheckboxes).each(function() {
if ($.data(this) == $.data(lastChecked) || $.data(this) == $.data(target)) {
inrange = (inrange) ? false : true;
}
if (inrange) {
$(this).attr("checked", target.checked)
.parent().parent().toggleClass(options.selectedClass, target.checked);
}
});
}
$(target).parent().parent().toggleClass(options.selectedClass, target.checked);
lastChecked = target;
updateCounter();
});

// GRAPPELLI CUSTOM: REMOVED ALL JS-CONFIRMS
// TRUSTED EDITORS SHOULD KNOW WHAT TO DO

// GRAPPELLI CUSTOM: submit on select
$(options.actionSelect).attr("autocomplete", "off").change(function(evt){
$(this).parents("form").submit();
});

};
/* Setup plugin defaults */
$.fn.actions.defaults = {
actionContainer: "div.grp-changelist-actions",
counterContainer: "li.grp-action-counter span.grp-action-counter",
allContainer: "div.grp-changelist-actions li.grp-all",
acrossInput: "div.grp-changelist-actions input.select-across",
acrossQuestions: "div.grp-changelist-actions li.grp-question",
acrossClears: "div.grp-changelist-actions li.grp-clear-selection",
allToggle: "#action-toggle",
selectedClass: "grp-selected",
actionSelect: "div.grp-changelist-actions select"
};
})(grp.jQuery);

Loading

0 comments on commit 022512b

Please sign in to comment.