Commits

Stephen McDonald committed 101e804

Removed all use of Django's deprecated ADMIN_MEDIA_PREFIX since we no longer support Django 1.3

Comments (0)

Files changed (49)

grappelli_safe/static/grappelli/js/LICENSE-JQUERY.txt

-Copyright (c) 2010 John Resig, http://jquery.com/
- 
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
- 
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
- 
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

grappelli_safe/static/grappelli/js/SelectBox.js

-var SelectBox = {
-    cache: new Object(),
-    init: function(id) {
-        var box = document.getElementById(id);
-        var node;
-        SelectBox.cache[id] = new Array();
-        var cache = SelectBox.cache[id];
-        for (var i = 0; (node = box.options[i]); i++) {
-            cache.push({value: node.value, text: node.text, displayed: 1});
-        }
-    },
-    redisplay: function(id) {
-        // Repopulate HTML select box from cache
-        var box = document.getElementById(id);
-        box.options.length = 0; // clear all options
-        for (var i = 0, j = SelectBox.cache[id].length; i < j; i++) {
-            var node = SelectBox.cache[id][i];
-            if (node.displayed) {
-                box.options[box.options.length] = new Option(node.text, node.value, false, false);
-            }
-        }
-    },
-    filter: function(id, text) {
-        // Redisplay the HTML select box, displaying only the choices containing ALL
-        // the words in text. (It's an AND search.)
-        var tokens = text.toLowerCase().split(/\s+/);
-        var node, token;
-        for (var i = 0; (node = SelectBox.cache[id][i]); i++) {
-            node.displayed = 1;
-            for (var j = 0; (token = tokens[j]); j++) {
-                if (node.text.toLowerCase().indexOf(token) == -1) {
-                    node.displayed = 0;
-                }
-            }
-        }
-        SelectBox.redisplay(id);
-    },
-    delete_from_cache: function(id, value) {
-        var node, delete_index = null;
-        for (var i = 0; (node = SelectBox.cache[id][i]); i++) {
-            if (node.value == value) {
-                delete_index = i;
-                break;
-            }
-        }
-        var j = SelectBox.cache[id].length - 1;
-        for (var i = delete_index; i < j; i++) {
-            SelectBox.cache[id][i] = SelectBox.cache[id][i+1];
-        }
-        SelectBox.cache[id].length--;
-    },
-    add_to_cache: function(id, option) {
-        SelectBox.cache[id].push({value: option.value, text: option.text, displayed: 1});
-    },
-    cache_contains: function(id, value) {
-        // Check if an item is contained in the cache
-        var node;
-        for (var i = 0; (node = SelectBox.cache[id][i]); i++) {
-            if (node.value == value) {
-                return true;
-            }
-        }
-        return false;
-    },
-    move: function(from, to) {
-        var from_box = document.getElementById(from);
-        var to_box = document.getElementById(to);
-        var option;
-        for (var i = 0; (option = from_box.options[i]); i++) {
-            if (option.selected && SelectBox.cache_contains(from, option.value)) {
-                SelectBox.add_to_cache(to, {value: option.value, text: option.text, displayed: 1});
-                SelectBox.delete_from_cache(from, option.value);
-            }
-        }
-        SelectBox.redisplay(from);
-        SelectBox.redisplay(to);
-    },
-    move_all: function(from, to) {
-        var from_box = document.getElementById(from);
-        var to_box = document.getElementById(to);
-        var option;
-        for (var i = 0; (option = from_box.options[i]); i++) {
-            if (SelectBox.cache_contains(from, option.value)) {
-                SelectBox.add_to_cache(to, {value: option.value, text: option.text, displayed: 1});
-                SelectBox.delete_from_cache(from, option.value);
-            }
-        }
-        SelectBox.redisplay(from);
-        SelectBox.redisplay(to);
-    },
-    sort: function(id) {
-        SelectBox.cache[id].sort( function(a, b) {
-            a = a.text.toLowerCase();
-            b = b.text.toLowerCase();
-            try {
-                if (a > b) return 1;
-                if (a < b) return -1;
-            }
-            catch (e) {
-                // silently fail on IE 'unknown' exception
-            }
-            return 0;
-        } );
-    },
-    select_all: function(id) {
-        var box = document.getElementById(id);
-        for (var i = 0; i < box.options.length; i++) {
-            box.options[i].selected = 'selected';
-        }
-    }
-}

grappelli_safe/static/grappelli/js/SelectFilter2.js

-/*
-SelectFilter2 - Turns a multiple-select box into a filter interface.
-
-Different than SelectFilter because this is coupled to the admin framework.
-
-Requires core.js, SelectBox.js and addevent.js.
-*/
-
-function findForm(node) {
-    // returns the node of the form containing the given node
-    if (node.tagName.toLowerCase() != 'form') {
-        return findForm(node.parentNode);
-    }
-    return node;
-}
-
-var SelectFilter = {
-    init: function(field_id, field_name, is_stacked, admin_media_prefix) {
-        var from_box = document.getElementById(field_id);
-        from_box.id += '_from'; // change its ID
-        from_box.className = 'filtered';
-
-        // Remove <p class="info">, because it just gets in the way.
-        var ps = from_box.parentNode.getElementsByTagName('p');
-        for (var i=0; i<ps.length; i++) {
-            from_box.parentNode.removeChild(ps[i]);
-        }
-
-        // <div class="selector"> or <div class="selector stacked">
-        var selector_div = quickElement('div', from_box.parentNode);
-        selector_div.className = is_stacked ? 'selector stacked' : 'selector';
-
-        // <div class="selector-available">
-        field_id_from = field_id + '_from'
-        var selector_available = quickElement('div', selector_div, '');
-        selector_available.className = 'selector-available';
-        quickElement('h2', selector_available, interpolate(gettext('Available %s'), [field_name]));
-        var filter_p = quickElement('p', selector_available, '');
-        filter_p.className = 'selector-filter';
-        quickElement('img', filter_p, '', 'src', admin_media_prefix + 'img/admin/selector-search.gif');
-        filter_p.appendChild(document.createTextNode(' '));
-        var filter_input = quickElement('input', filter_p, '', 'type', 'text');
-        filter_input.id = field_id_from + '_input';
-        selector_available.appendChild(from_box);
-        var choose_all = quickElement('a', selector_available, gettext('Choose all'), 'href', 'javascript: (function(){ SelectBox.move_all("' + field_id + '_from", "' + field_id + '_to"); })()');
-        choose_all.className = 'selector-chooseall';
-
-        // <ul class="selector-chooser">
-        var selector_chooser = quickElement('ul', selector_div, '');
-        selector_chooser.className = 'selector-chooser';
-        var add_link = quickElement('a', quickElement('li', selector_chooser, ''), gettext('Add'), 'href', 'javascript: (function(){ SelectBox.move("' + field_id + '_from","' + field_id + '_to");})()');
-        add_link.className = 'selector-add';
-        var remove_link = quickElement('a', quickElement('li', selector_chooser, ''), gettext('Remove'), 'href', 'javascript: (function(){ SelectBox.move("' + field_id + '_to","' + field_id + '_from");})()');
-        remove_link.className = 'selector-remove';
-
-        // <div class="selector-chosen">
-        field_id_to = field_id + '_to'
-        var selector_chosen = quickElement('div', selector_div, '');
-        selector_chosen.className = 'selector-chosen';
-        quickElement('h2', selector_chosen, interpolate(gettext('Chosen %s'), [field_name]));
-        var filter_p = quickElement('p', selector_chosen, '');
-        filter_p.className = 'selector-filter';
-        quickElement('img', filter_p, '', 'src', admin_media_prefix + 'img/admin/selector-search.gif');
-        filter_p.appendChild(document.createTextNode(' '));
-        var filter_input_to = quickElement('input', filter_p, '', 'type', 'text');
-        filter_input_to.id = field_id_to + '_input';
-        //var selector_filter = quickElement('p', selector_chosen, gettext('Select your choice(s) and click '));
-        //selector_filter.className = 'selector-filter';
-        //quickElement('img', selector_filter, '', 'src', admin_media_prefix + (is_stacked ? 'img/admin/selector_stacked-add.gif':'img/admin/selector-add.gif'), 'alt', 'Add');
-        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';
-        var clear_all = quickElement('a', selector_chosen, gettext('Clear all'), 'href', 'javascript: (function() { SelectBox.move_all("' + field_id + '_to", "' + field_id + '_from");})()');
-        clear_all.className = 'selector-clearall';
-
-        from_box.setAttribute('name', from_box.getAttribute('name') + '_old');
-
-        // Set up the JavaScript event handlers for the select box filter interface
-        addEvent(filter_input, 'keyup', function(e) { SelectFilter.filter_key_up(e, field_id, '_from'); });
-        addEvent(filter_input, 'keydown', function(e) { SelectFilter.filter_key_down(e, field_id, '_from'); });
-        addEvent(filter_input_to, 'keyup', function(e) { SelectFilter.filter_key_up(e, field_id, '_to'); });
-        addEvent(filter_input_to, 'keydown', function(e) { SelectFilter.filter_key_down(e, field_id, '_to'); });
-        addEvent(from_box, 'dblclick', function() { SelectBox.move(field_id + '_from', field_id + '_to'); });
-        addEvent(to_box, 'dblclick', function() { SelectBox.move(field_id + '_to', field_id + '_from'); });
-        addEvent(findForm(from_box), 'submit', function() { SelectBox.select_all(field_id + '_to'); });
-        SelectBox.init(field_id + '_from');
-        SelectBox.init(field_id + '_to');
-        // Move selected from_box options to to_box
-        SelectBox.move(field_id + '_from', field_id + '_to');
-    },
-    filter_key_up: function(event, field_id, type) {
-        from = document.getElementById(field_id + type);
-        // don't submit form if user pressed Enter
-        if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)) {
-            from.selectedIndex = 0;
-            SelectBox.move(field_id + type, field_id + '_to');
-            from.selectedIndex = 0;
-            return false;
-        }
-        var temp = from.selectedIndex;
-        SelectBox.filter(field_id + type, document.getElementById(field_id + type + '_input').value);
-        from.selectedIndex = temp;
-        return true;
-    },
-    filter_key_down: function(event, field_id, type) {
-        from = document.getElementById(field_id + type);
-        // right arrow -- move across
-        if ((event.which && event.which == 39) || (event.keyCode && event.keyCode == 39)) {
-            var old_index = from.selectedIndex;
-            SelectBox.move(field_id + type, field_id + '_to');
-            from.selectedIndex = (old_index == from.length) ? from.length - 1 : old_index;
-            return false;
-        }
-        // down arrow -- wrap around
-        if ((event.which && event.which == 40) || (event.keyCode && event.keyCode == 40)) {
-            from.selectedIndex = (from.length == from.selectedIndex + 1) ? 0 : from.selectedIndex + 1;
-        }
-        // up arrow -- wrap around
-        if ((event.which && event.which == 38) || (event.keyCode && event.keyCode == 38)) {
-            from.selectedIndex = (from.selectedIndex == 0) ? from.length - 1 : from.selectedIndex - 1;
-        }
-        return true;
-    }
-}

grappelli_safe/static/grappelli/js/actions.js

-/**
-* 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();
-                $(actionCheckboxes).attr("checked", true)
-                    .parent().parent().toggleClass(options.selectedClass, checked);
-            } else {
-                reset();
-                $(actionCheckboxes).attr("checked", false)
-                    .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.changelist-actions li.question a").click(function(event) {
-            event.preventDefault();
-            $(options.acrossInput).val(1);
-            showClear();
-        });
-        $("div.changelist-actions li.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.changelist-actions",
-        counterContainer: "li.action-counter span.action-counter",
-        allContainer: "div.changelist-actions li.all",
-        acrossInput: "div.changelist-actions input.select-across",
-        acrossQuestions: "div.changelist-actions li.question",
-        acrossClears: "div.changelist-actions li.clear-selection",
-        allToggle: "#action-toggle",
-        selectedClass: "selected",
-        actionSelect: "div.changelist-actions select"
-    };
-})(django.jQuery);
-

grappelli_safe/static/grappelli/js/actions.min.js

-/**
-* 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();
-                $(actionCheckboxes).attr("checked", true)
-                    .parent().parent().toggleClass(options.selectedClass, checked);
-            } else {
-                reset();
-                $(actionCheckboxes).attr("checked", false)
-                    .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.changelist-actions li.question a").click(function(event) {
-            event.preventDefault();
-            $(options.acrossInput).val(1);
-            showClear();
-        });
-        $("div.changelist-actions li.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.changelist-actions",
-        counterContainer: "li.action-counter span.action-counter",
-        allContainer: "div.changelist-actions li.all",
-        acrossInput: "div.changelist-actions input.select-across",
-        acrossQuestions: "div.changelist-actions li.question",
-        acrossClears: "div.changelist-actions li.clear-selection",
-        allToggle: "#action-toggle",
-        selectedClass: "selected",
-        actionSelect: "div.changelist-actions select"
-    };
-})(django.jQuery);
-

grappelli_safe/static/grappelli/js/admin/CollapsedFieldsets.js

-$(document).ready(function(){
-    
-    /// FIELDSETS
-    $('fieldset[class*="collapse-closed"]').each(function() {
-        $(this).addClass("collapsed");
-        $(this).find('h2:first').addClass("collapse-toggle");
-    });
-    $('fieldset[class*="collapse-open"]').each(function() {
-        $(this).find('h2:first').addClass("collapse-toggle");
-    });
-    $('h2.collapse-toggle').bind("click", function(e){
-        $(this).parent().toggleClass('collapsed');
-        $(this).parent().toggleClass('collapse-closed');
-        $(this).parent().toggleClass('collapse-open');
-    });
-    
-    /// OPEN FIELDSETS WITH ERRORS
-    $('fieldset[class*="collapse-closed"]').children('div[class*="errors"]').each(function(i) {
-        $(this).parent().toggleClass("collapsed");
-        $(this).parent().toggleClass('collapse-closed');
-        $(this).parent().toggleClass('collapse-open');
-    });
-    
-});

grappelli_safe/static/grappelli/js/admin/CollapsibleGroup.js

-$(document).ready(function(){
-   /// Dashboard Group-Collapsible
-   $('div[class*="group-collapsible collapse-closed"]').each(function() {
-       $(this).addClass("collapsed");
-       $(this).find('h2:first').addClass("collapse-toggle");
-   });
-   $('div[class*="group-collapsible collapse-open"]').each(function() {
-       $(this).find('h2:first').addClass("collapse-toggle");
-   });
-   /// Enable/Disable Collapse Function
-   $("h2.collapse-toggle a").click(function(){
-       $("body").addClass("collapse-hold");
-   });
-   $('h2.collapse-toggle').bind("click", function(e){
-       if (!$("body").hasClass("collapse-hold")) {
-           $(this).parent().toggleClass('collapsed');
-           $(this).parent().toggleClass('collapse-closed');
-           $(this).parent().toggleClass('collapse-open');
-       }
-   });
-});

grappelli_safe/static/grappelli/js/admin/DateTimeShortcuts.js

-// Inserts shortcut buttons after all of the following:
-//     <input type="text" class="vDateField">
-//     <input type="text" class="vTimeField">
-
-var DateTimeShortcuts = {
-    calendars: [],
-    calendarInputs: [],
-    clockInputs: [],
-    calendarDivName1: 'calendarbox', // name of calendar <div> that gets toggled
-    calendarDivName2: 'calendarin',  // name of <div> that contains calendar
-    calendarLinkName: 'calendarlink',// name of the link that is used to toggle
-    clockDivName: 'clockbox',        // name of clock <div> that gets toggled
-    clockLinkName: 'clocklink',      // name of the link that is used to toggle
-    admin_media_prefix: '',
-    init: function() {
-        // Deduce admin_media_prefix by looking at the <script>s in the
-        // current document and finding the URL of *this* module.
-        var scripts = document.getElementsByTagName('script');
-        for (var i=0; i<scripts.length; i++) {
-            if (scripts[i].src.match(/DateTimeShortcuts/)) {
-                var idx = scripts[i].src.indexOf('js/admin/DateTimeShortcuts');
-                DateTimeShortcuts.admin_media_prefix = scripts[i].src.substring(0, idx);
-                break;
-            }
-        }
-        
-        var inputs = document.getElementsByTagName('input');
-        for (i=0; i<inputs.length; i++) {
-            var inp = inputs[i];
-            if (inp.getAttribute('type') == 'text' && inp.className.match(/vTimeField/)) {
-                DateTimeShortcuts.addClock(inp);
-            }
-            else if (inp.getAttribute('type') == 'text' && inp.className.match(/vDateField/)) {
-                DateTimeShortcuts.addCalendar(inp);
-            }
-        }
-        
-        // Grappelli: remove text
-        $('p.datetime')
-            .contents()
-            .filter(function(){
-                return this.nodeType === 3;
-            })
-            .each(function(){
-                this.nodeValue = "";
-            });
-        
-    },
-    // Add clock widget to a given field
-    addClock: function(inp) {
-        
-        var num = DateTimeShortcuts.clockInputs.length;
-        DateTimeShortcuts.clockInputs[num] = inp;
-        
-        // Shortcut links (clock icon and "Now" link)
-        var shortcuts_span = document.createElement('span');
-        inp.parentNode.insertBefore(shortcuts_span, inp.nextSibling);
-        var now_link = document.createElement('a');
-        now_link.setAttribute('href', "javascript:DateTimeShortcuts.handleClockQuicklink(" + num + ", new Date().getHourMinuteSecond());");
-        now_link.appendChild(document.createTextNode(gettext('Now')));
-        var clock_link = document.createElement('a');
-        clock_link.setAttribute('href', 'javascript:DateTimeShortcuts.openClock(' + num + ');');
-        clock_link.id = DateTimeShortcuts.clockLinkName + num;
-        quickElement('img', clock_link, '', 'src', DateTimeShortcuts.admin_media_prefix + 'img/admin/icon_clock.gif', 'alt', gettext('Clock'));
-        shortcuts_span.appendChild(document.createTextNode('\240'));
-        //shortcuts_span.appendChild(now_link);
-        //shortcuts_span.appendChild(document.createTextNode('\240|\240'));
-        shortcuts_span.appendChild(clock_link);
-        
-        // Create clock link div
-        //
-        // Markup looks like:
-        // <div id="clockbox1" class="clockbox module">
-        //     <h2>Choose a time</h2>
-        //     <ul class="timelist">
-        //         <li><a href="#">Now</a></li>
-        //         <li><a href="#">Midnight</a></li>
-        //         <li><a href="#">6 a.m.</a></li>
-        //         <li><a href="#">Noon</a></li>
-        //     </ul>
-        //     <p class="calendar-cancel"><a href="#">Cancel</a></p>
-        // </div>
-        
-        var clock_box = document.createElement('div');
-        clock_box.style.display = 'none';
-        clock_box.style.position = 'absolute';
-        clock_box.className = 'clockbox module';
-        clock_box.setAttribute('id', DateTimeShortcuts.clockDivName + num);
-        document.body.appendChild(clock_box);
-        addEvent(clock_box, 'click', DateTimeShortcuts.cancelEventPropagation);
-        
-        quickElement('h2', clock_box, gettext('Choose a time'));
-        time_list = quickElement('ul', clock_box, '');
-        time_list.className = 'timelist';
-        quickElement("a", quickElement("li", time_list, ""), gettext("Now"), "href", "javascript:DateTimeShortcuts.handleClockQuicklink(" + num + ", new Date().getHourMinuteSecond());")
-        quickElement("a", quickElement("li", time_list, ""), gettext("Midnight"), "href", "javascript:DateTimeShortcuts.handleClockQuicklink(" + num + ", '00:00:00');")
-        quickElement("a", quickElement("li", time_list, ""), gettext("6 a.m."), "href", "javascript:DateTimeShortcuts.handleClockQuicklink(" + num + ", '06:00:00');")
-        quickElement("a", quickElement("li", time_list, ""), gettext("Noon"), "href", "javascript:DateTimeShortcuts.handleClockQuicklink(" + num + ", '12:00:00');")
-        
-        cancel_p = quickElement('p', clock_box, '');
-        cancel_p.className = 'calendar-cancel';
-        quickElement('a', cancel_p, gettext('Cancel'), 'href', 'javascript:DateTimeShortcuts.dismissClock(' + num + ');');
-    },
-    openClock: function(num) {
-        var clock_box = document.getElementById(DateTimeShortcuts.clockDivName+num)
-        var clock_link = document.getElementById(DateTimeShortcuts.clockLinkName+num)
-        
-        // Recalculate the clockbox position
-        // is it left-to-right or right-to-left layout ?
-        if (getStyle(document.body,'direction')!='rtl') {
-            clock_box.style.left = findPosX(clock_link) + 17 + 'px';
-        }
-        else {
-            // since style's width is in em, it'd be tough to calculate
-            // px value of it. let's use an estimated px for now
-            // TODO: IE returns wrong value for findPosX when in rtl mode
-            //       (it returns as it was left aligned), needs to be fixed.
-            clock_box.style.left = findPosX(clock_link) - 110 + 'px';
-        }
-        clock_box.style.top = findPosY(clock_link) - 30 + 'px';
-        
-        // Show the clock box
-        clock_box.style.display = 'block';
-        addEvent(window, 'click', function() { DateTimeShortcuts.dismissClock(num); return true; });
-    },
-    dismissClock: function(num) {
-       document.getElementById(DateTimeShortcuts.clockDivName + num).style.display = 'none';
-       window.onclick = null;
-    },
-    handleClockQuicklink: function(num, val) {
-       DateTimeShortcuts.clockInputs[num].value = val;
-       DateTimeShortcuts.dismissClock(num);
-    },
-    // Add calendar widget to a given field.
-    addCalendar: function(inp) {
-        
-        var num = DateTimeShortcuts.calendars.length;
-        
-        DateTimeShortcuts.calendarInputs[num] = inp;
-        
-        // Shortcut links (calendar icon and "Today" link)
-        var shortcuts_span = document.createElement('span');
-        inp.parentNode.insertBefore(shortcuts_span, inp.nextSibling);
-        var today_link = document.createElement('a');
-        today_link.setAttribute('href', 'javascript:DateTimeShortcuts.handleCalendarQuickLink(' + num + ', 0);');
-        today_link.appendChild(document.createTextNode(gettext('Today')));
-        var cal_link = document.createElement('a');
-        cal_link.setAttribute('href', 'javascript:DateTimeShortcuts.openCalendar(' + num + ');');
-        cal_link.id = DateTimeShortcuts.calendarLinkName + num;
-        quickElement('img', cal_link, '', 'src', DateTimeShortcuts.admin_media_prefix + 'img/admin/icon_calendar.gif', 'alt', gettext('Calendar'));
-        shortcuts_span.appendChild(document.createTextNode('\240'));
-        //shortcuts_span.appendChild(today_link);
-        //shortcuts_span.appendChild(document.createTextNode('\240|\240'));
-        shortcuts_span.appendChild(cal_link);
-        
-        // Create calendarbox div.
-        //
-        // Markup looks like:
-        //
-        // <div id="calendarbox3" class="calendarbox module">
-        //     <h2>
-        //           <a href="#" class="link-previous">&lsaquo;</a>
-        //           <a href="#" class="link-next">&rsaquo;</a> February 2003
-        //     </h2>
-        //     <div class="calendar" id="calendarin3">
-        //         <!-- (cal) -->
-        //     </div>
-        //     <div class="calendar-shortcuts">
-        //          <a href="#">Yesterday</a> | <a href="#">Today</a> | <a href="#">Tomorrow</a>
-        //     </div>
-        //     <p class="calendar-cancel"><a href="#">Cancel</a></p>
-        // </div>
-        var cal_box = document.createElement('div');
-        cal_box.style.display = 'none';
-        cal_box.style.position = 'absolute';
-        cal_box.className = 'calendarbox module';
-        cal_box.setAttribute('id', DateTimeShortcuts.calendarDivName1 + num);
-        document.body.appendChild(cal_box);
-        addEvent(cal_box, 'click', DateTimeShortcuts.cancelEventPropagation);
-        
-        // next-prev links
-        var cal_nav = quickElement('div', cal_box, '');
-        var cal_nav_prev = quickElement('a', cal_nav, '<', 'href', 'javascript:DateTimeShortcuts.drawPrev('+num+');');
-        cal_nav_prev.className = 'calendarnav-previous';
-        var cal_nav_next = quickElement('a', cal_nav, '>', 'href', 'javascript:DateTimeShortcuts.drawNext('+num+');');
-        cal_nav_next.className = 'calendarnav-next';
-        
-        // main box
-        var cal_main = quickElement('div', cal_box, '', 'id', DateTimeShortcuts.calendarDivName2 + num);
-        cal_main.className = 'calendar';
-        DateTimeShortcuts.calendars[num] = new Calendar(DateTimeShortcuts.calendarDivName2 + num, DateTimeShortcuts.handleCalendarCallback(num));
-        DateTimeShortcuts.calendars[num].drawCurrent();
-        
-        // calendar shortcuts
-        var shortcuts = quickElement('div', cal_box, '');
-        shortcuts.className = 'calendar-shortcuts';
-        quickElement('a', shortcuts, gettext('Yesterday'), 'href', 'javascript:DateTimeShortcuts.handleCalendarQuickLink(' + num + ', -1);');
-        shortcuts.appendChild(document.createTextNode('\240|\240'));
-        quickElement('a', shortcuts, gettext('Today'), 'href', 'javascript:DateTimeShortcuts.handleCalendarQuickLink(' + num + ', 0);');
-        shortcuts.appendChild(document.createTextNode('\240|\240'));
-        quickElement('a', shortcuts, gettext('Tomorrow'), 'href', 'javascript:DateTimeShortcuts.handleCalendarQuickLink(' + num + ', +1);');
-        
-        // cancel bar
-        var cancel_p = quickElement('p', cal_box, '');
-        cancel_p.className = 'calendar-cancel';
-        quickElement('a', cancel_p, gettext('Cancel'), 'href', 'javascript:DateTimeShortcuts.dismissCalendar(' + num + ');');
-    },
-    openCalendar: function(num) {
-        var cal_box = document.getElementById(DateTimeShortcuts.calendarDivName1+num)
-        var cal_link = document.getElementById(DateTimeShortcuts.calendarLinkName+num)
-    var inp = DateTimeShortcuts.calendarInputs[num];
-    
-    // Determine if the current value in the input has a valid date.
-    // If so, draw the calendar with that date's year and month.
-    if (inp.value) {
-        var date_parts = inp.value.split('-');
-        var year = date_parts[0];
-        var month = parseFloat(date_parts[1]);
-        if (year.match(/\d\d\d\d/) && month >= 1 && month <= 12) {
-        DateTimeShortcuts.calendars[num].drawDate(month, year);
-        }
-    }
-    
-
-        // Recalculate the clockbox position
-        // is it left-to-right or right-to-left layout ?
-        if (getStyle(document.body,'direction')!='rtl') {
-            cal_box.style.left = findPosX(cal_link) + 17 + 'px';
-        }
-        else {
-            // since style's width is in em, it'd be tough to calculate
-            // px value of it. let's use an estimated px for now
-            // TODO: IE returns wrong value for findPosX when in rtl mode
-            //       (it returns as it was left aligned), needs to be fixed.
-            cal_box.style.left = findPosX(cal_link) - 180 + 'px';
-        }
-        cal_box.style.top = findPosY(cal_link) - 75 + 'px';
-    
-        cal_box.style.display = 'block';
-        addEvent(window, 'click', function() { DateTimeShortcuts.dismissCalendar(num); return true; });
-    },
-    dismissCalendar: function(num) {
-        document.getElementById(DateTimeShortcuts.calendarDivName1+num).style.display = 'none';
-    },
-    drawPrev: function(num) {
-        DateTimeShortcuts.calendars[num].drawPreviousMonth();
-    },
-    drawNext: function(num) {
-        DateTimeShortcuts.calendars[num].drawNextMonth();
-    },
-    handleCalendarCallback: function(num) {
-        return "function(y, m, d) { DateTimeShortcuts.calendarInputs["+num+"].value = y+'-'+(m<10?'0':'')+m+'-'+(d<10?'0':'')+d; document.getElementById(DateTimeShortcuts.calendarDivName1+"+num+").style.display='none';}";
-    },
-    handleCalendarQuickLink: function(num, offset) {
-       var d = new Date();
-       d.setDate(d.getDate() + offset)
-       DateTimeShortcuts.calendarInputs[num].value = d.getISODate();
-       DateTimeShortcuts.dismissCalendar(num);
-    },
-    cancelEventPropagation: function(e) {
-        if (!e) e = window.event;
-        e.cancelBubble = true;
-        if (e.stopPropagation) e.stopPropagation();
-    }
-}
-
-addEvent(window, 'load', DateTimeShortcuts.init);
-
-
-
-

grappelli_safe/static/grappelli/js/admin/RelatedObjectLookups.js

-// Handles related-objects functionality: lookup link for raw_id_fields
-// and Add Another links.
-
-function html_unescape(text) {
-    // Unescape a string that was escaped using django.utils.html.escape.
-    text = text.replace(/&lt;/g, '<');
-    text = text.replace(/&gt;/g, '>');
-    text = text.replace(/&quot;/g, '"');
-    text = text.replace(/&#39;/g, "'");
-    text = text.replace(/&amp;/g, '&');
-    return text;
-}
-
-function showRelatedObjectLookupPopup(triggeringLink) {
-    var name = triggeringLink.id.replace(/^lookup_/, '');
-    // IE doesn't like periods in the window name, so convert temporarily.
-    name = name.replace(/\./g, '___');
-    var href;
-    if (triggeringLink.href.search(/\?/) >= 0) {
-        href = triggeringLink.href + '&pop=1';
-    } else {
-        href = triggeringLink.href + '?pop=1';
-    }
-    var win = window.open(href, name, 'height=600,width=960,resizable=yes,scrollbars=yes');
-    win.focus();
-    return false;
-}
-
-function dismissRelatedLookupPopup(win, chosenId) {
-    var name = win.name.replace(/___/g, '.');
-    var elem = document.getElementById(name);
-    if (elem.className.indexOf('vManyToManyRawIdAdminField') != -1 && elem.value) {
-        elem.value += ',' + chosenId;
-        document.getElementById(name).focus();
-    } else {
-        document.getElementById(name).value = chosenId;
-        document.getElementById(name).focus();
-    }
-    win.close();
-}
-
-function showAddAnotherPopup(triggeringLink) {
-    var name = triggeringLink.id.replace(/^add_/, '');
-    name = name.replace(/\./g, '___');
-    href = triggeringLink.href
-    if (href.indexOf('?') == -1) {
-        href += '?_popup=1';
-    } else {
-        href  += '&_popup=1';
-    }
-    var win = window.open(href, name, 'height=600,width=960,resizable=yes,scrollbars=yes');
-    win.focus();
-    return false;
-}
-
-function dismissAddAnotherPopup(win, newId, newRepr) {
-    // newId and newRepr are expected to have previously been escaped by
-    // django.utils.html.escape.
-    newId = html_unescape(newId);
-    newRepr = html_unescape(newRepr);
-    var name = win.name.replace(/___/g, '.');
-    var elem = document.getElementById(name);
-    if (elem) {
-        if (elem.nodeName == 'SELECT') {
-            var o = new Option(newRepr, newId);
-            elem.options[elem.options.length] = o;
-            o.selected = true;
-        } else if (elem.nodeName == 'INPUT') {
-            elem.value = newId;
-        }
-    } else {
-        var toId = name + "_to";
-        elem = document.getElementById(toId);
-        var o = new Option(newRepr, newId);
-        SelectBox.add_to_cache(toId, o);
-        SelectBox.redisplay(toId);
-    }
-    win.close();
-}
-
-var CHAR_MAX_LENGTH = 30;
-
-function RelatedLookup(obj) {
-    var link = obj.next();
-    var text = obj.next().next();
-    var app_label = link.attr('href').split('/')[2];
-    var model_name= link.attr('href').split('/')[3];
-    
-    text.text('loading ...');
-    
-    // get object
-    $.get('/grappelli/related_lookup/', {object_id: obj.val(), app_label: app_label, model_name: model_name}, function(data) {
-        var item = data;
-        text.text('');
-        if (item) {
-            if (item.length > CHAR_MAX_LENGTH) {
-                text.text(decodeURI(item.substr(0, CHAR_MAX_LENGTH) + " ..."));
-            } else {
-                text.text(decodeURI(item));
-            }
-        }
-    });
-}
-
-function M2MLookup(obj) {
-    var link = obj.next();
-    var text = obj.next().next();
-    var app_label = link.attr('href').split('/')[2];
-    var model_name= link.attr('href').split('/')[3];
-
-    if (text.length == 0) {
-        obj.next().after('&nbsp;<strong>&nbsp;</strong>');
-        text = obj.next().next()
-    }
-        
-    text.text('loading ...');
-    
-    // get object
-    $.get('/grappelli/m2m_lookup/', {object_id: obj.val(), app_label: app_label, model_name: model_name}, function(data) {
-        var item = data;
-        text.text('');
-        if (item) {
-            if (item.length > CHAR_MAX_LENGTH) {
-                text.text(decodeURI(item.substr(0, CHAR_MAX_LENGTH) + " ..."));
-            } else {
-                text.text(decodeURI(item));
-            }
-        }
-    });
-}
-
-function GenericLookup(obj) {
-    var link = obj.next();
-    var text = obj.next().next();
-    var app_label = link.attr('href').split('/')[2];
-    var model_name= link.attr('href').split('/')[3];
-    
-    text.text('loading ...');
-    
-    // get object
-    $.get('/grappelli/related_lookup/', {object_id: obj.val(), app_label: app_label, model_name: model_name}, function(data) {
-        var item = data;
-        text.text('');
-        if (item) {
-            if (item.length > CHAR_MAX_LENGTH) {
-                text.text(decodeURI(item.substr(0, CHAR_MAX_LENGTH) + " ..."));
-            } else {
-                text.text(decodeURI(item));
-            }
-        }
-    });
-}
-
-function RelatedHandler(obj) {
-    // related lookup handler
-    obj.bind("change", function() {
-        RelatedLookup($(this));
-    });
-    obj.bind("focus", function() {
-        RelatedLookup($(this));
-    });
-}
-
-function M2MHandler(obj) {
-    // related lookup handler
-    obj.bind("change", function() {
-        M2MLookup($(this));
-    });
-    obj.bind("focus", function() {
-        M2MLookup($(this));
-    });
-}
-
-function InitObjectID(obj) {
-    obj.each(function() {
-        var ct = $(this).closest('div[class*="object_id"]').prev().find(':input[name*="content_type"]').val();
-        if (ct) {
-            var lookupLink = $('<a class="related-lookup">&nbsp;&nbsp;</a>');
-            lookupLink.attr('id', 'lookup_'+this.id);
-            lookupLink.attr('href', ADMIN_URL + MODEL_URL_ARRAY[ct] + '/?t=id');
-            lookupLink.attr('onClick', 'return showRelatedObjectLookupPopup(this);');
-            var lookupText = '<strong>&nbsp;</strong>';
-            $(this).after(lookupText).after(lookupLink);
-            if ($(this).val() != "") {
-                var lookupText = GenericLookup($(this));
-            }
-        }
-    });
-}
-
-function InitContentType(obj) {
-    obj.bind("change", function() {
-        if ($(this).val()) {
-            var href = ADMIN_URL + MODEL_URL_ARRAY[$(this).val()] + "/?t=id";
-            var lookupLink = $(this).closest('div[class*="content_type"]').next().find('a.related-lookup');
-            var obj_id = $(this).closest('div[class*="content_type"]').next().find('input[name*="object_id"]');
-            if (lookupLink.attr('href')) {
-                lookupLink.attr('href', href);
-            } else {
-                var lookupLink = $('<a class="related-lookup">&nbsp;&nbsp;</a>');
-                lookupLink.attr('id', 'lookup_'+obj_id.attr('id'));
-                lookupLink.attr('href', ADMIN_URL + MODEL_URL_ARRAY[$(this).val()] + '/?t=id');
-                lookupLink.attr('onClick', 'return showRelatedObjectLookupPopup(this);');
-                var lookupText = '<strong>&nbsp;</strong>';
-                $(this).closest('div[class*="content_type"]').next().find('input[name*="object_id"]').after(lookupText).after(lookupLink);
-            }
-        } else {
-            $(this).closest('div[class*="content_type"]').next().find('input[name*="object_id"]').val('');
-            $(this).closest('div[class*="content_type"]').next().find('a.related-lookup').remove();
-            $(this).closest('div[class*="content_type"]').next().find('strong').remove();
-        }
-    });
-}
-
-function GenericHandler(obj) {
-    // related lookup handler
-    obj.bind("change", function() {
-        GenericLookup($(this));
-    });
-    obj.bind("focus", function() {
-        GenericLookup($(this));
-    });
-}
-
-$(document).ready(function(){
-    
-    // change related-lookups in order to get the right URL.
-    $('a.related-lookup').each(function() {
-       href = $(this).attr('href').replace('../../../', ADMIN_URL);
-       $(this).attr('href', href);
-    });
-    
-    // related lookup setup
-    $("input.vForeignKeyRawIdAdminField").each(function() {
-        // insert empty text-elements after all empty foreignkeys
-        if ($(this).val() == "") {
-            $(this).next().after('&nbsp;<strong></strong>');
-        }
-    });
-    
-    // m2m lookup setup
-    $("input.vManyToManyRawIdAdminField").each(function() {
-        // insert empty text-elements after all empty foreignkeys
-        if ($(this).val() == "") {
-            $(this).next().after('&nbsp;<strong>&nbsp;</strong>');
-        }
-    });
-    
-    RelatedHandler($("input.vForeignKeyRawIdAdminField"));
-    M2MHandler($("input.vManyToManyRawIdAdminField"));
-    
-    InitObjectID($('input[name*="object_id"]'));
-    InitContentType($(':input[name*="content_type"]'));
-    GenericHandler($('input[name*="object_id"]'));
-    
-});
-
-

grappelli_safe/static/grappelli/js/admin/ordering.js

-addEvent(window, 'load', reorder_init);
-
-var lis;
-var top = 0;
-var left = 0;
-var height = 30;
-
-function reorder_init() {
-    lis = document.getElementsBySelector('ul#orderthese li');
-    var input = document.getElementsBySelector('input[name=order_]')[0];
-    setOrder(input.value.split(','));
-    input.disabled = true;
-    draw();
-    // Now initialise the dragging behaviour
-    var limit = (lis.length - 1) * height;
-    for (var i = 0; i < lis.length; i++) {
-        var li = lis[i];
-        var img = document.getElementById('handle'+li.id);
-        li.style.zIndex = 1;
-        Drag.init(img, li, left + 10, left + 10, top + 10, top + 10 + limit);
-        li.onDragStart = startDrag;
-        li.onDragEnd = endDrag;
-        img.style.cursor = 'move';
-    }
-}
-
-function submitOrderForm() {
-    var inputOrder = document.getElementsBySelector('input[name=order_]')[0];
-    inputOrder.value = getOrder();
-    inputOrder.disabled=false;
-}
-
-function startDrag() {
-    this.style.zIndex = '10';
-    this.className = 'dragging';
-}
-
-function endDrag(x, y) {
-    this.style.zIndex = '1';
-    this.className = '';
-    // Work out how far along it has been dropped, using x co-ordinate
-    var oldIndex = this.index;
-    var newIndex = Math.round((y - 10 - top) / height);
-    // 'Snap' to the correct position
-    this.style.top = (10 + top + newIndex * height) + 'px';
-    this.index = newIndex;
-    moveItem(oldIndex, newIndex);
-}
-
-function moveItem(oldIndex, newIndex) {
-    // Swaps two items, adjusts the index and left co-ord for all others
-    if (oldIndex == newIndex) {
-        return; // Nothing to swap;
-    }
-    var direction, lo, hi;
-    if (newIndex > oldIndex) {
-        lo = oldIndex;
-        hi = newIndex;
-        direction = -1;
-    } else {
-        direction = 1;
-        hi = oldIndex;
-        lo = newIndex;
-    }
-    var lis2 = new Array(); // We will build the new order in this array
-    for (var i = 0; i < lis.length; i++) {
-        if (i < lo || i > hi) {
-            // Position of items not between the indexes is unaffected
-            lis2[i] = lis[i];
-            continue;
-        } else if (i == newIndex) {
-            lis2[i] = lis[oldIndex];
-            continue;
-        } else {
-            // Item is between the two indexes - move it along 1
-            lis2[i] = lis[i - direction];
-        }
-    }
-    // Re-index everything
-    reIndex(lis2);
-    lis = lis2;
-    draw();
-//    document.getElementById('hiddenOrder').value = getOrder();
-    document.getElementsBySelector('input[name=order_]')[0].value = getOrder();
-}
-
-function reIndex(lis) {
-    for (var i = 0; i < lis.length; i++) {
-        lis[i].index = i;
-    }
-}
-
-function draw() {
-    for (var i = 0; i < lis.length; i++) {
-        var li = lis[i];
-        li.index = i;
-        li.style.position = 'absolute';
-        li.style.left = (10 + left) + 'px';
-        li.style.top = (10 + top + (i * height)) + 'px';
-    }
-}
-
-function getOrder() {
-    var order = new Array(lis.length);
-    for (var i = 0; i < lis.length; i++) {
-        order[i] = lis[i].id.substring(1, 100);
-    }
-    return order.join(',');
-}
-
-function setOrder(id_list) {
-    /* Set the current order to match the lsit of IDs */
-    var temp_lis = new Array();
-    for (var i = 0; i < id_list.length; i++) {
-        var id = 'p' + id_list[i];
-        temp_lis[temp_lis.length] = document.getElementById(id);
-    }
-    reIndex(temp_lis);
-    lis = temp_lis;
-    draw();
-}
-
-function addEvent(elm, evType, fn, useCapture)
-// addEvent and removeEvent
-// cross-browser event handling for IE5+,  NS6 and Mozilla
-// By Scott Andrew
-{
-  if (elm.addEventListener){
-    elm.addEventListener(evType, fn, useCapture);
-    return true;
-  } else if (elm.attachEvent){
-    var r = elm.attachEvent("on"+evType, fn);
-    return r;
-  } else {
-    elm['on'+evType] = fn;
-  }
-}

grappelli_safe/static/grappelli/js/calendar.js

-/*
-calendar.js - Calendar functions by Adrian Holovaty
-*/
-
-function removeChildren(a) { // "a" is reference to an object
-    while (a.hasChildNodes()) a.removeChild(a.lastChild);
-}
-
-// quickElement(tagType, parentReference, textInChildNode, [, attribute, attributeValue ...]);
-function quickElement() {
-    var obj = document.createElement(arguments[0]);
-    if (arguments[2] != '' && arguments[2] != null) {
-        var textNode = document.createTextNode(arguments[2]);
-        obj.appendChild(textNode);
-    }
-    var len = arguments.length;
-    for (var i = 3; i < len; i += 2) {
-        obj.setAttribute(arguments[i], arguments[i+1]);
-    }
-    arguments[1].appendChild(obj);
-    return obj;
-}
-
-// CalendarNamespace -- Provides a collection of HTML calendar-related helper functions
-var CalendarNamespace = {
-    monthsOfYear: gettext('January February March April May June July August September October November December').split(' '),
-    daysOfWeek: gettext('S M T W T F S').split(' '),
-    isLeapYear: function(year) {
-        return (((year % 4)==0) && ((year % 100)!=0) || ((year % 400)==0));
-    },
-    getDaysInMonth: function(month,year) {
-        var days;
-        if (month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12) {
-            days = 31;
-        }
-        else if (month==4 || month==6 || month==9 || month==11) {
-            days = 30;
-        }
-        else if (month==2 && CalendarNamespace.isLeapYear(year)) {
-            days = 29;
-        }
-        else {
-            days = 28;
-        }
-        return days;
-    },
-    draw: function(month, year, div_id, callback) { // month = 1-12, year = 1-9999
-        month = parseInt(month);
-        year = parseInt(year);
-        var calDiv = document.getElementById(div_id);
-        removeChildren(calDiv);
-        var calTable = document.createElement('table');
-        quickElement('caption', calTable, CalendarNamespace.monthsOfYear[month-1] + ' ' + year);
-        var tableBody = quickElement('tbody', calTable);
-
-        // Draw days-of-week header
-        var tableRow = quickElement('tr', tableBody);
-        for (var i = 0; i < 7; i++) {
-            quickElement('th', tableRow, CalendarNamespace.daysOfWeek[i]);
-        }
-
-        var startingPos = new Date(year, month-1, 1).getDay();
-        var days = CalendarNamespace.getDaysInMonth(month, year);
-
-        // Draw blanks before first of month
-        tableRow = quickElement('tr', tableBody);
-        for (var i = 0; i < startingPos; i++) {
-            var _cell = quickElement('td', tableRow, ' ');
-            _cell.style.backgroundColor = '#f3f3f3';
-        }
-
-        // Draw days of month
-        var currentDay = 1;
-        for (var i = startingPos; currentDay <= days; i++) {
-            if (i%7 == 0 && currentDay != 1) {
-                tableRow = quickElement('tr', tableBody);
-            }
-            var cell = quickElement('td', tableRow, '');
-            quickElement('a', cell, currentDay, 'href', 'javascript:void(' + callback + '('+year+','+month+','+currentDay+'));');
-            currentDay++;
-        }
-
-        // Draw blanks after end of month (optional, but makes for valid code)
-        while (tableRow.childNodes.length < 7) {
-            var _cell = quickElement('td', tableRow, ' ');
-            _cell.style.backgroundColor = '#f3f3f3';
-        }
-
-        calDiv.appendChild(calTable);
-    }
-}
-
-// Calendar -- A calendar instance
-function Calendar(div_id, callback) {
-    // div_id (string) is the ID of the element in which the calendar will
-    //     be displayed
-    // callback (string) is the name of a JavaScript function that will be
-    //     called with the parameters (year, month, day) when a day in the
-    //     calendar is clicked
-    this.div_id = div_id;
-    this.callback = callback;
-    this.today = new Date();
-    this.currentMonth = this.today.getMonth() + 1;
-    this.currentYear = this.today.getFullYear();
-}
-Calendar.prototype = {
-    drawCurrent: function() {
-        CalendarNamespace.draw(this.currentMonth, this.currentYear, this.div_id, this.callback);
-    },
-    drawDate: function(month, year) {
-        this.currentMonth = month;
-        this.currentYear = year;
-        this.drawCurrent();
-    },
-    drawPreviousMonth: function() {
-        if (this.currentMonth == 1) {
-            this.currentMonth = 12;
-            this.currentYear--;
-        }
-        else {
-            this.currentMonth--;
-        }
-        this.drawCurrent();
-    },
-    drawNextMonth: function() {
-        if (this.currentMonth == 12) {
-            this.currentMonth = 1;
-            this.currentYear++;
-        }
-        else {
-            this.currentMonth++;
-        }
-        this.drawCurrent();
-    },
-    drawPreviousYear: function() {
-        this.currentYear--;
-        this.drawCurrent();
-    },
-    drawNextYear: function() {
-        this.currentYear++;
-        this.drawCurrent();
-    }
-}

grappelli_safe/static/grappelli/js/collapse.js

-(function($) {
-	$(document).ready(function() {
-		// Add anchor tag for Show/Hide link
-		$("fieldset.collapse").each(function(i, elem) {
-			// Don't hide if fields in this fieldset have errors
-			if ( $(elem).find("div.errors").length == 0 ) {
-				$(elem).addClass("collapsed");
-				$(elem).find("h2").first().append(' (<a id="fieldsetcollapser' +
-					i +'" class="collapse-toggle" href="#">' + gettext("Show") +
-					'</a>)');
-			}
-		});
-		// Add toggle to anchor tag
-		$("fieldset.collapse a.collapse-toggle").toggle(
-			function() { // Show
-				$(this).text(gettext("Hide"));
-				$(this).closest("fieldset").removeClass("collapsed");
-				return false;
-			},
-			function() { // Hide
-				$(this).text(gettext("Show"));
-				$(this).closest("fieldset").addClass("collapsed");
-				return false;
-			}
-		);
-	});
-})(django.jQuery);

grappelli_safe/static/grappelli/js/collapse.min.js

-(function(a){a(document).ready(function(){a("fieldset.collapse").each(function(c,b){if(a(b).find("div.errors").length==0){a(b).addClass("collapsed");a(b).find("h2").first().append(' (<a id="fieldsetcollapser'+c+'" class="collapse-toggle" href="#">'+gettext("Show")+"</a>)")}});a("fieldset.collapse a.collapse-toggle").toggle(function(){a(this).text(gettext("Hide"));a(this).closest("fieldset").removeClass("collapsed");return false},function(){a(this).text(gettext("Show"));a(this).closest("fieldset").addClass("collapsed");
-return false})})})(django.jQuery);

grappelli_safe/static/grappelli/js/core.js

-// Core javascript helper functions
-
-// basic browser identification & version
-var isOpera = (navigator.userAgent.indexOf("Opera")>=0) && parseFloat(navigator.appVersion);
-var isIE = ((document.all) && (!isOpera)) && parseFloat(navigator.appVersion.split("MSIE ")[1].split(";")[0]);
-
-// Cross-browser event handlers.
-function addEvent(obj, evType, fn) {
-    if (obj.addEventListener) {
-        obj.addEventListener(evType, fn, false);
-        return true;
-    } else if (obj.attachEvent) {
-        var r = obj.attachEvent("on" + evType, fn);
-        return r;
-    } else {
-        return false;
-    }
-}
-
-function removeEvent(obj, evType, fn) {
-    if (obj.removeEventListener) {
-        obj.removeEventListener(evType, fn, false);
-        return true;
-    } else if (obj.detachEvent) {
-        obj.detachEvent("on" + evType, fn);
-        return true;
-    } else {
-        return false;
-    }
-}
-
-// quickElement(tagType, parentReference, textInChildNode, [, attribute, attributeValue ...]);
-function quickElement() {
-    var obj = document.createElement(arguments[0]);
-    if (arguments[2] != '' && arguments[2] != null) {
-        var textNode = document.createTextNode(arguments[2]);
-        obj.appendChild(textNode);
-    }
-    var len = arguments.length;
-    for (var i = 3; i < len; i += 2) {
-        obj.setAttribute(arguments[i], arguments[i+1]);
-    }
-    arguments[1].appendChild(obj);
-    return obj;
-}
-
-// ----------------------------------------------------------------------------
-// Cross-browser xmlhttp object
-// from http://jibbering.com/2002/4/httprequest.html
-// ----------------------------------------------------------------------------
-var xmlhttp;
-/*@cc_on @*/
-/*@if (@_jscript_version >= 5)
-    try {
-        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
-    } catch (e) {
-        try {
-            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
-        } catch (E) {
-            xmlhttp = false;
-        }
-    }
-@else
-    xmlhttp = false;
-@end @*/
-if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
-  xmlhttp = new XMLHttpRequest();
-}
-
-// ----------------------------------------------------------------------------
-// Find-position functions by PPK
-// See http://www.quirksmode.org/js/findpos.html
-// ----------------------------------------------------------------------------
-function findPosX(obj) {
-    var curleft = 0;
-    if (obj.offsetParent) {
-        while (obj.offsetParent) {
-            curleft += obj.offsetLeft - ((isOpera) ? 0 : obj.scrollLeft);
-            obj = obj.offsetParent;
-        }
-        // IE offsetParent does not include the top-level 
-        if (isIE && obj.parentElement){
-            curleft += obj.offsetLeft - obj.scrollLeft;
-        }
-    } else if (obj.x) {
-        curleft += obj.x;
-    }
-    return curleft;
-}
-
-function findPosY(obj) {
-    var curtop = 0;
-    if (obj.offsetParent) {
-        while (obj.offsetParent) {
-            curtop += obj.offsetTop - ((isOpera) ? 0 : obj.scrollTop);
-            obj = obj.offsetParent;
-        }
-        // IE offsetParent does not include the top-level 
-        if (isIE && obj.parentElement){
-            curtop += obj.offsetTop - obj.scrollTop;
-        }
-    } else if (obj.y) {
-        curtop += obj.y;
-    }
-    return curtop;
-}
-
-//-----------------------------------------------------------------------------
-// Date object extensions
-// ----------------------------------------------------------------------------
-Date.prototype.getCorrectYear = function() {
-    // Date.getYear() is unreliable --
-    // see http://www.quirksmode.org/js/introdate.html#year
-    var y = this.getYear() % 100;
-    return (y < 38) ? y + 2000 : y + 1900;
-}
-
-Date.prototype.getTwoDigitMonth = function() {
-    return (this.getMonth() < 9) ? '0' + (this.getMonth()+1) : (this.getMonth()+1);
-}
-
-Date.prototype.getTwoDigitDate = function() {
-    return (this.getDate() < 10) ? '0' + this.getDate() : this.getDate();
-}
-
-Date.prototype.getTwoDigitHour = function() {
-    return (this.getHours() < 10) ? '0' + this.getHours() : this.getHours();
-}
-
-Date.prototype.getTwoDigitMinute = function() {
-    return (this.getMinutes() < 10) ? '0' + this.getMinutes() : this.getMinutes();
-}
-
-Date.prototype.getTwoDigitSecond = function() {
-    return (this.getSeconds() < 10) ? '0' + this.getSeconds() : this.getSeconds();
-}
-
-Date.prototype.getISODate = function() {
-    return this.getCorrectYear() + '-' + this.getTwoDigitMonth() + '-' + this.getTwoDigitDate();
-}
-
-Date.prototype.getHourMinute = function() {
-    return this.getTwoDigitHour() + ':' + this.getTwoDigitMinute();
-}
-
-Date.prototype.getHourMinuteSecond = function() {
-    return this.getTwoDigitHour() + ':' + this.getTwoDigitMinute() + ':' + this.getTwoDigitSecond();
-}
-
-// ----------------------------------------------------------------------------
-// String object extensions
-// ----------------------------------------------------------------------------
-String.prototype.pad_left = function(pad_length, pad_string) {
-    var new_string = this;
-    for (var i = 0; new_string.length < pad_length; i++) {
-        new_string = pad_string + new_string;
-    }
-    return new_string;
-}
-
-// ----------------------------------------------------------------------------
-// Get the computed style for and element
-// ----------------------------------------------------------------------------
-function getStyle(oElm, strCssRule){
-    var strValue = "";
-    if(document.defaultView && document.defaultView.getComputedStyle){
-        strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
-    }
-    else if(oElm.currentStyle){
-        strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
-            return p1.toUpperCase();
-        });
-        strValue = oElm.currentStyle[strCssRule];
-    }
-    return strValue;
-}

grappelli_safe/static/grappelli/js/dateparse.js

-/* 'Magic' date parsing, by Simon Willison (6th October 2003)
-   http://simon.incutio.com/archive/2003/10/06/betterDateInput
-   Adapted for 6newslawrence.com, 28th January 2004
-*/
-
-/* Finds the index of the first occurence of item in the array, or -1 if not found */
-if (typeof Array.prototype.indexOf == 'undefined') {
-    Array.prototype.indexOf = function(item) {
-        var len = this.length;
-        for (var i = 0; i < len; i++) {
-            if (this[i] == item) {
-                return i;
-            }
-        }
-        return -1;
-    };
-}
-/* Returns an array of items judged 'true' by the passed in test function */
-if (typeof Array.prototype.filter == 'undefined') {
-    Array.prototype.filter = function(test) {
-        var matches = [];
-        var len = this.length;
-        for (var i = 0; i < len; i++) {
-            if (test(this[i])) {
-                matches[matches.length] = this[i];
-            }
-        }
-        return matches;
-    };
-}
-
-var monthNames = gettext("January February March April May June July August September October November December").split(" ");
-var weekdayNames = gettext("Sunday Monday Tuesday Wednesday Thursday Friday Saturday").split(" ");
-
-/* Takes a string, returns the index of the month matching that string, throws
-   an error if 0 or more than 1 matches
-*/
-function parseMonth(month) {
-    var matches = monthNames.filter(function(item) { 
-        return new RegExp("^" + month, "i").test(item);
-    });
-    if (matches.length == 0) {
-        throw new Error("Invalid month string");
-    }
-    if (matches.length > 1) {
-        throw new Error("Ambiguous month");
-    }
-    return monthNames.indexOf(matches[0]);
-}
-/* Same as parseMonth but for days of the week */
-function parseWeekday(weekday) {
-    var matches = weekdayNames.filter(function(item) {
-        return new RegExp("^" + weekday, "i").test(item);
-    });
-    if (matches.length == 0) {
-        throw new Error("Invalid day string");
-    }
-    if (matches.length > 1) {
-        throw new Error("Ambiguous weekday");
-    }
-    return weekdayNames.indexOf(matches[0]);
-}
-
-/* Array of objects, each has 're', a regular expression and 'handler', a 
-   function for creating a date from something that matches the regular 
-   expression. Handlers may throw errors if string is unparseable. 
-*/
-var dateParsePatterns = [
-    // Today
-    {   re: /^tod/i,
-        handler: function() { 
-            return new Date();
-        } 
-    },
-    // Tomorrow
-    {   re: /^tom/i,
-        handler: function() {
-            var d = new Date(); 
-            d.setDate(d.getDate() + 1); 
-            return d;
-        }
-    },
-    // Yesterday
-    {   re: /^yes/i,
-        handler: function() {
-            var d = new Date();
-            d.setDate(d.getDate() - 1);
-            return d;
-        }
-    },
-    // 4th
-    {   re: /^(\d{1,2})(st|nd|rd|th)?$/i, 
-        handler: function(bits) {
-            var d = new Date();
-            d.setDate(parseInt(bits[1], 10));
-            return d;
-        }
-    },
-    // 4th Jan
-    {   re: /^(\d{1,2})(?:st|nd|rd|th)? (\w+)$/i, 
-        handler: function(bits) {
-            var d = new Date();
-            d.setDate(parseInt(bits[1], 10));
-            d.setMonth(parseMonth(bits[2]));
-            return d;
-        }
-    },
-    // 4th Jan 2003
-    {   re: /^(\d{1,2})(?:st|nd|rd|th)? (\w+),? (\d{4})$/i,
-        handler: function(bits) {
-            var d = new Date();
-            d.setDate(parseInt(bits[1], 10));
-            d.setMonth(parseMonth(bits[2]));
-            d.setYear(bits[3]);
-            return d;
-        }
-    },
-    // Jan 4th
-    {   re: /^(\w+) (\d{1,2})(?:st|nd|rd|th)?$/i, 
-        handler: function(bits) {
-            var d = new Date();
-            d.setDate(parseInt(bits[2], 10));
-            d.setMonth(parseMonth(bits[1]));
-            return d;
-        }
-    },
-    // Jan 4th 2003
-    {   re: /^(\w+) (\d{1,2})(?:st|nd|rd|th)?,? (\d{4})$/i,
-        handler: function(bits) {
-            var d = new Date();
-            d.setDate(parseInt(bits[2], 10));
-            d.setMonth(parseMonth(bits[1]));
-            d.setYear(bits[3]);
-            return d;
-        }
-    },
-    // next Tuesday - this is suspect due to weird meaning of "next"
-    {   re: /^next (\w+)$/i,
-        handler: function(bits) {
-            var d = new Date();
-            var day = d.getDay();
-            var newDay = parseWeekday(bits[1]);
-            var addDays = newDay - day;
-            if (newDay <= day) {
-                addDays += 7;
-            }
-            d.setDate(d.getDate() + addDays);
-            return d;
-        }
-    },
-    // last Tuesday
-    {   re: /^last (\w+)$/i,
-        handler: function(bits) {
-            throw new Error("Not yet implemented");
-        }
-    },
-    // mm/dd/yyyy (American style)
-    {   re: /(\d{1,2})\/(\d{1,2})\/(\d{4})/,
-        handler: function(bits) {
-            var d = new Date();
-            d.setYear(bits[3]);
-            d.setDate(parseInt(bits[2], 10));
-            d.setMonth(parseInt(bits[1], 10) - 1); // Because months indexed from 0
-            return d;
-        }
-    },
-    // yyyy-mm-dd (ISO style)
-    {   re: /(\d{4})-(\d{1,2})-(\d{1,2})/,
-        handler: function(bits) {
-            var d = new Date();
-            d.setYear(parseInt(bits[1]));
-            d.setMonth(parseInt(bits[2], 10) - 1);
-            d.setDate(parseInt(bits[3], 10));
-            return d;
-        }
-    },
-];
-
-function parseDateString(s) {
-    for (var i = 0; i < dateParsePatterns.length; i++) {
-        var re = dateParsePatterns[i].re;
-        var handler = dateParsePatterns[i].handler;
-        var bits = re.exec(s);
-        if (bits) {
-            return handler(bits);
-        }
-    }
-    throw new Error("Invalid date string");
-}
-
-function fmt00(x) {
-    // fmt00: Tags leading zero onto numbers 0 - 9.
-    // Particularly useful for displaying results from Date methods.
-    //
-    if (Math.abs(parseInt(x)) < 10){
-        x = "0"+ Math.abs(x);
-    }
-    return x;
-}
-
-function parseDateStringISO(s) {
-    try {
-        var d = parseDateString(s);
-        return d.getFullYear() + '-' + (fmt00(d.getMonth() + 1)) + '-' + fmt00(d.getDate())
-    }
-    catch (e) { return s; }
-}
-function magicDate(input) {
-    var messagespan = input.id + 'Msg';
-    try {
-        var d = parseDateString(input.value);
-        input.value = d.getFullYear() + '-' + (fmt00(d.getMonth() + 1)) + '-' + 
-            fmt00(d.getDate());
-        input.className = '';
-        // Human readable date
-        if (document.getElementById(messagespan)) {
-            document.getElementById(messagespan).firstChild.nodeValue = d.toDateString();
-            document.getElementById(messagespan).className = 'normal';
-        }
-    }
-    catch (e) {
-        input.className = 'error';
-        var message = e.message;
-        // Fix for IE6 bug
-        if (message.indexOf('is null or not an object') > -1) {
-            message = 'Invalid date string';
-        }
-        if (document.getElementById(messagespan)) {
-            document.getElementById(messagespan).firstChild.nodeValue = message;
-            document.getElementById(messagespan).className = 'error';
-        }
-    }
-}

grappelli_safe/static/grappelli/js/getElementsBySelector.js

-/* document.getElementsBySelector(selector)
-   - returns an array of element objects from the current document
-     matching the CSS selector. Selectors can contain element names, 
-     class names and ids and can be nested. For example:
-     
-       elements = document.getElementsBySelect('div#main p a.external')
-     
-     Will return an array of all 'a' elements with 'external' in their 
-     class attribute that are contained inside 'p' elements that are 
-     contained inside the 'div' element which has id="main"
-
-   New in version 0.4: Support for CSS2 and CSS3 attribute selectors:
-   See http://www.w3.org/TR/css3-selectors/#attribute-selectors
-
-   Version 0.4 - Simon Willison, March 25th 2003
-   --