diff options
-rw-r--r-- | media/admin_media/css/base.css | 4 | ||||
-rw-r--r-- | media/admin_media/css/forms.css | 36 | ||||
-rw-r--r-- | media/admin_media/css/global.css | 15 | ||||
-rw-r--r-- | media/admin_media/css/null.css | 1 | ||||
-rw-r--r-- | media/admin_media/css/rtl.css | 12 | ||||
-rw-r--r-- | media/admin_media/css/widgets.css | 3 | ||||
-rw-r--r-- | media/admin_media/img/admin/changelist-bg_rtl.gif | bin | 0 -> 75 bytes | |||
-rw-r--r-- | media/admin_media/img/gis/move_vertex_off.png | bin | 0 -> 711 bytes | |||
-rw-r--r-- | media/admin_media/img/gis/move_vertex_on.png | bin | 0 -> 506 bytes | |||
-rw-r--r-- | media/admin_media/js/SelectBox.js | 12 | ||||
-rw-r--r-- | media/admin_media/js/SelectFilter2.js | 2 | ||||
-rw-r--r-- | media/admin_media/js/admin/CollapsedFieldsets.js | 2 | ||||
-rw-r--r-- | media/admin_media/js/admin/DateTimeShortcuts.js | 15 | ||||
-rw-r--r-- | media/admin_media/js/admin/RelatedObjectLookups.js | 51 | ||||
-rw-r--r-- | media/admin_media/js/core.js | 16 | ||||
-rw-r--r-- | media/admin_media/js/urlify.js | 125 |
16 files changed, 258 insertions, 36 deletions
diff --git a/media/admin_media/css/base.css b/media/admin_media/css/base.css index 88f7d9a..9760d67 100644 --- a/media/admin_media/css/base.css +++ b/media/admin_media/css/base.css @@ -4,11 +4,11 @@ */ /* Block IE 5 */ -@import "null?\"\{"; +@import "null.css?\"\{"; /* Import other styles */ @import url('global.css'); @import url('layout.css'); /* Import patch for IE 6 Windows */ -/*\*/ @import "patch-iewin.css"; /**/
\ No newline at end of file +/*\*/ @import "patch-iewin.css"; /**/ diff --git a/media/admin_media/css/forms.css b/media/admin_media/css/forms.css index 0cfe2ff..d55aa11 100644 --- a/media/admin_media/css/forms.css +++ b/media/admin_media/css/forms.css @@ -9,7 +9,6 @@ form .form-row p { padding-left:0; font-size:11px; } /* FORM LABELS */ form h4 { margin:0 !important; padding:0 !important; border:none !important; } label { font-weight:normal !important; color:#666; font-size:12px; } -label.inline { margin-left:20px; } .required label, label.required { font-weight:bold !important; color:#333 !important; } /* RADIO BUTTONS */ @@ -19,15 +18,15 @@ form ul.inline { margin-left:0; padding:0; } form ul.inline li { float:left; padding-right:7px; } /* ALIGNED FIELDSETS */ -.aligned label { display:block; padding:0 1em 3px 0; float:left; width:8em; } -.aligned label.inline { display:inline; float:none; } +.aligned label { display:block; padding:3px 10px 0 0; float:left; width:8em; } .colMS .aligned .vLargeTextField, .colMS .aligned .vXMLLargeTextField { width:350px; } form .aligned p, form .aligned ul { margin-left:7em; padding-left:30px; } form .aligned table p { margin-left:0; padding-left:0; } form .aligned p.help { padding-left:38px; } .aligned .vCheckboxLabel { float:none !important; display:inline; padding-left:4px; } -.colM .aligned .vLargeTextField, colM .aligned .vXMLLargeTextField { width:610px; } +.colM .aligned .vLargeTextField, .colM .aligned .vXMLLargeTextField { width:610px; } .checkbox-row p.help { margin-left:0; padding-left:0 !important; } +fieldset .field-box { float:left; margin-right: 20px; } /* WIDE FIELDSETS */ .wide label { width:15em !important; } @@ -45,9 +44,10 @@ fieldset.collapsed .collapse-toggle { padding:3px 5px !important; background:tra fieldset.monospace textarea { font-family:"Bitstream Vera Sans Mono",Monaco,"Courier New",Courier,monospace; } /* SUBMIT ROW */ -.submit-row { padding:5px 7px; text-align:right; background:white url(../img/admin/nav-bg.gif) 0 100% repeat-x; border:1px solid #ccc; margin:5px 0; } +.submit-row { padding:5px 7px; text-align:right; background:white url(../img/admin/nav-bg.gif) 0 100% repeat-x; border:1px solid #ccc; margin:5px 0; overflow:hidden; } .submit-row input { margin:0 0 0 5px; } -.submit-row p { margin-top:0.3em; } +.submit-row p { margin:0.3em; } +.submit-row p.deletelink-box { float: left; } .submit-row .deletelink { background:url(../img/admin/icon_deletelink.gif) 0 50% no-repeat; padding-left:14px; } /* CUSTOM FORM FIELDS */ @@ -58,3 +58,27 @@ fieldset.monospace textarea { font-family:"Bitstream Vera Sans Mono",Monaco,"Cou .vLargeTextField, .vXMLLargeTextField { width:48em; } .flatpages-flatpage #id_content { height:40.2em; } .module table .vPositiveSmallIntegerField { width:2.2em; } +.vTextField { width:20em; } +.vIntegerField { width:5em; } +.vForeignKeyRawIdAdminField { width: 5em; } + +/* INLINES */ +.inline-group {padding:0; border:1px solid #ccc; margin:10px 0;} +.inline-group .aligned label { width: 8em; } + +.inline-related {position:relative;} +.inline-related h3 {margin: 0; color:#666; padding:3px 5px; font-size:11px; background:#e1e1e1 url(../img/admin/nav-bg.gif) top left repeat-x; border-bottom:1px solid #ddd;} +.inline-related h3 span.delete {padding-left:20px; position:absolute; top:2px; right:10px;} +.inline-related h3 span.delete label {margin-left:2px; font-size: 11px;} +.inline-related fieldset {margin: 0; background:#fff; border: none; } +.inline-related fieldset.module h3 { margin:0; padding:2px 5px 3px 5px; font-size:11px; text-align:left; font-weight:bold; background:#bcd; color:#fff; } +.inline-related.tabular fieldset.module table {width:100%;} +.last-related fieldset {border: none;} + +.inline-group .tabular tr.has_original td {padding-top:2em;} +.inline-group .tabular tr td.original { padding:2px 0 0 0; width:0; _position:relative; } +.inline-group .tabular th.original {width:0px; padding:0;} +.inline-group .tabular td.original p {position:absolute; left:0; height:1.1em; padding:2px 7px; overflow:hidden; font-size:9px; font-weight:bold; color:#666; _width:700px; } +.inline-group ul.tools {padding:0; margin: 0; list-style:none;} +.inline-group ul.tools li {display:inline; padding:0 5px;} +.inline-group ul.tools a.add {background:url(../img/admin/icon_addlink.gif) 0 50% no-repeat; padding-left:14px;} diff --git a/media/admin_media/css/global.css b/media/admin_media/css/global.css index d50601b..7b1a013 100644 --- a/media/admin_media/css/global.css +++ b/media/admin_media/css/global.css @@ -4,6 +4,7 @@ body { margin:0; padding:0; font-size:12px; font-family:"Lucida Grande","DejaVu a:link, a:visited { color: #5b80b2; text-decoration:none; } a:hover { color: #036; } a img { border:none; } +a.section:link, a.section:visited { color: white; text-decoration:none; } /* GLOBAL DEFAULTS */ p, ol, ul, dl { margin:.2em 0 .8em 0; } @@ -86,10 +87,10 @@ textarea { vertical-align:top !important; } input[type=text], input[type=password], textarea, select, .vTextField { border:1px solid #ccc; } /* FORM BUTTONS */ -input[type=submit], input[type=button], .submit-row input { background:white url(../img/admin/nav-bg.gif) bottom repeat-x; padding:3px; color:black; border:1px solid #bbb; border-color:#ddd #aaa #aaa #ddd; } -input[type=submit]:active, input[type=button]:active { background-image:url(../img/admin/nav-bg-reverse.gif); background-position:top; } -input[type=submit].default, .submit-row input.default { border:2px solid #5b80b2; background:#7CA0C7 url(../img/admin/default-bg.gif) bottom repeat-x; font-weight:bold; color:white; } -input[type=submit].default:active { background-image:url(../img/admin/default-bg-reverse.gif); background-position:top; } +.button, input[type=submit], input[type=button], .submit-row input { background:white url(../img/admin/nav-bg.gif) bottom repeat-x; padding:3px; color:black; border:1px solid #bbb; border-color:#ddd #aaa #aaa #ddd; } +.button:active, input[type=submit]:active, input[type=button]:active { background-image:url(../img/admin/nav-bg-reverse.gif); background-position:top; } +.button.default, input[type=submit].default, .submit-row input.default { border:2px solid #5b80b2; background:#7CA0C7 url(../img/admin/default-bg.gif) bottom repeat-x; font-weight:bold; color:white; float:right; } +.button.default:active, input[type=submit].default:active { background-image:url(../img/admin/default-bg-reverse.gif); background-position:top; } /* MODULES */ .module { border:1px solid #ccc; margin-bottom:5px; background:white; } @@ -97,7 +98,7 @@ input[type=submit].default:active { background-image:url(../img/admin/default-bg .module blockquote { margin-left:12px; } .module ul, .module ol { margin-left:1.5em; } .module h3 { margin-top:.6em; } -.module h2, .module caption { margin:0; padding:2px 5px 3px 5px; font-size:11px; text-align:left; font-weight:bold; background:#7CA0C7 url(../img/admin/default-bg.gif) top left repeat-x; color:white; } +.module h2, .module caption, .inline-group h2 { margin:0; padding:2px 5px 3px 5px; font-size:11px; text-align:left; font-weight:bold; background:#7CA0C7 url(../img/admin/default-bg.gif) top left repeat-x; color:white; } .module table { border-collapse: collapse; } /* MESSAGES & ERRORS */ @@ -108,8 +109,8 @@ ul.errorlist { margin:0 !important; padding:0 !important; } .errorlist li { font-size:12px !important; display:block; padding:4px 5px 4px 25px; margin:0 0 3px 0; border:1px solid red; color:white; background:red url(../img/admin/icon_alert.gif) 5px .3em no-repeat; } td ul.errorlist { margin:0 !important; padding:0 !important; } td ul.errorlist li { margin:0 !important; } -.error { background:#ffc; } -.error input, .error select { border:1px solid red; } +.errors { background:#ffc; } +.errors input, .errors select { border:1px solid red; } div.system-message { background: #ffc; margin: 10px; padding: 6px 8px; font-size: .8em; } div.system-message p.system-message-title { padding:4px 5px 4px 25px; margin:0; color:red; background:#ffc url(../img/admin/icon_error.gif) 5px .3em no-repeat; } .description { font-size:12px; padding:5px 0 0 12px; } diff --git a/media/admin_media/css/null.css b/media/admin_media/css/null.css new file mode 100644 index 0000000..1a93f22 --- /dev/null +++ b/media/admin_media/css/null.css @@ -0,0 +1 @@ +/* Nothing to see here. Dummy file to feed to the high pass filter which hides CSS from IE5/win. Details: http://tantek.com/CSS/Examples/highpass.html */
\ No newline at end of file diff --git a/media/admin_media/css/rtl.css b/media/admin_media/css/rtl.css index 1974e7c..9d6c077 100644 --- a/media/admin_media/css/rtl.css +++ b/media/admin_media/css/rtl.css @@ -32,10 +32,17 @@ div.breadcrumbs { text-align:right; } .change-list .filtered table, .change-list .filtered .paginator, .filtered #toolbar, .filtered div.xfull { margin-right:0px !important; margin-left:160px !important; } #changelist-filter li.selected { border-left:0px none; padding-left:0px; margin-left:0; border-right:5px solid #ccc; padding-right:5px;margin-right:-10px; } -/* fomrs styles */ +/* form styles */ .aligned label { padding:0 0 3px 1em; float:right; } .submit-row { text-align: left } +.submit-row p.deletelink-box { float: right;} +.submit-row .deletelink { background:url(../img/admin/icon_deletelink.gif) 0 50% no-repeat; padding-right:14px; } .vDateField, .vTimeField { margin-left:2px; } +form ul.inline li { float:right; padding-right:0; padding-left:7px; } +input[type=submit].default, .submit-row input.default { float:left; } +fieldset .field-box { float:right; margin-left: 20px; } +.errorlist li {background-position: 100% .3em; padding: 4px 25px 4px 5px; } +.errornote {background-position: 100% .3em; padding: 4px 25px 4px 5px; /* widget styles */ .calendarnav-previous { top:0; left:auto; right:0; } @@ -44,3 +51,6 @@ div.breadcrumbs { text-align:right; } .selector { float: right;} .selector .selector-filter { text-align: right;} + +/* x unsorted */ +.inline-related h2 { text-align:right } diff --git a/media/admin_media/css/widgets.css b/media/admin_media/css/widgets.css index bf526bf..3686d1b 100644 --- a/media/admin_media/css/widgets.css +++ b/media/admin_media/css/widgets.css @@ -33,7 +33,6 @@ a.selector-clearall { background:url(../img/admin/selector-removeall.gif) left c /* DATE AND TIME */ p.datetime { line-height:20px; margin:0; padding:0; color:#666; font-size:11px; font-weight:bold; } .datetime span { font-size:11px; color:#ccc; font-weight:normal; white-space:nowrap; } -.vDateField { margin-left:4px; } table p.datetime { font-size:10px; margin-left:0; padding-left:0; } /* FILE UPLOADS */ @@ -43,7 +42,7 @@ p.file-upload { line-height:20px; margin:0; padding:0; color:#666; font-size:11p /* CALENDARS & CLOCKS */ .calendarbox, .clockbox { margin:5px auto; font-size:11px; width:16em; text-align:center; background:white; position:relative; } -.clockbox { width:9em; } +.clockbox { width:auto; } .calendar { margin:0; padding: 0; } .calendar table { margin:0; padding:0; border-collapse:collapse; background:white; width:99%; } .calendar caption, .calendarbox h2 { margin: 0; font-size:11px; text-align:center; border-top:none; } diff --git a/media/admin_media/img/admin/changelist-bg_rtl.gif b/media/admin_media/img/admin/changelist-bg_rtl.gif Binary files differnew file mode 100644 index 0000000..2379712 --- /dev/null +++ b/media/admin_media/img/admin/changelist-bg_rtl.gif diff --git a/media/admin_media/img/gis/move_vertex_off.png b/media/admin_media/img/gis/move_vertex_off.png Binary files differnew file mode 100644 index 0000000..296b2e2 --- /dev/null +++ b/media/admin_media/img/gis/move_vertex_off.png diff --git a/media/admin_media/img/gis/move_vertex_on.png b/media/admin_media/img/gis/move_vertex_on.png Binary files differnew file mode 100644 index 0000000..21f4758 --- /dev/null +++ b/media/admin_media/img/gis/move_vertex_on.png diff --git a/media/admin_media/js/SelectBox.js b/media/admin_media/js/SelectBox.js index af8de20..f28c861 100644 --- a/media/admin_media/js/SelectBox.js +++ b/media/admin_media/js/SelectBox.js @@ -6,7 +6,7 @@ var SelectBox = { 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 }); + cache.push({value: node.value, text: node.text, displayed: 1}); } }, redisplay: function(id) { @@ -50,7 +50,7 @@ var SelectBox = { SelectBox.cache[id].length--; }, add_to_cache: function(id, option) { - SelectBox.cache[id].push({ value: option.value, text: option.text, displayed: 1 }); + 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 @@ -68,7 +68,7 @@ var SelectBox = { 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.add_to_cache(to, {value: option.value, text: option.text, displayed: 1}); SelectBox.delete_from_cache(from, option.value); } } @@ -80,8 +80,10 @@ var SelectBox = { var to_box = document.getElementById(to); var option; for (var i = 0; (option = from_box.options[i]); i++) { - SelectBox.add_to_cache(to, { value: option.value, text: option.text, displayed: 1 }); - SelectBox.delete_from_cache(from, option.value); + 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); diff --git a/media/admin_media/js/SelectFilter2.js b/media/admin_media/js/SelectFilter2.js index 8f6079e..db946a6 100644 --- a/media/admin_media/js/SelectFilter2.js +++ b/media/admin_media/js/SelectFilter2.js @@ -58,7 +58,7 @@ var SelectFilter = { quickElement('h2', selector_chosen, interpolate(gettext('Chosen %s'), [field_name])); 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 + 'img/admin/selector-add.gif', 'alt', 'Add'); + 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");})()'); diff --git a/media/admin_media/js/admin/CollapsedFieldsets.js b/media/admin_media/js/admin/CollapsedFieldsets.js index c8426db..d66bec0 100644 --- a/media/admin_media/js/admin/CollapsedFieldsets.js +++ b/media/admin_media/js/admin/CollapsedFieldsets.js @@ -47,7 +47,7 @@ var CollapsedFieldsets = { // Returns true if any fields in the fieldset have validation errors. var divs = fs.getElementsByTagName('div'); for (var i=0; i<divs.length; i++) { - if (divs[i].className.match(/\berror\b/)) { + if (divs[i].className.match(/\berrors\b/)) { return true; } } diff --git a/media/admin_media/js/admin/DateTimeShortcuts.js b/media/admin_media/js/admin/DateTimeShortcuts.js index b1504fc..f57f97e 100644 --- a/media/admin_media/js/admin/DateTimeShortcuts.js +++ b/media/admin_media/js/admin/DateTimeShortcuts.js @@ -195,6 +195,19 @@ var DateTimeShortcuts = { 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 ? @@ -223,7 +236,7 @@ var DateTimeShortcuts = { DateTimeShortcuts.calendars[num].drawNextMonth(); }, handleCalendarCallback: function(num) { - return "function(y, m, d) { DateTimeShortcuts.calendarInputs["+num+"].value = y+'-'+m+'-'+d; document.getElementById(DateTimeShortcuts.calendarDivName1+"+num+").style.display='none';}"; + 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(); diff --git a/media/admin_media/js/admin/RelatedObjectLookups.js b/media/admin_media/js/admin/RelatedObjectLookups.js index db4ed1a..d201f39 100644 --- a/media/admin_media/js/admin/RelatedObjectLookups.js +++ b/media/admin_media/js/admin/RelatedObjectLookups.js @@ -1,10 +1,35 @@ -// Handles related-objects functionality: lookup link for raw_id_admin=True +// 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(/</g, '<'); + text = text.replace(/>/g, '>'); + text = text.replace(/"/g, '"'); + text = text.replace(/'/g, "'"); + text = text.replace(/&/g, '&'); + return text; +} + +// IE doesn't accept periods or dashes in the window name, but the element IDs +// we use to generate popup window names may contain them, therefore we map them +// to allowed characters in a reversible way so that we can locate the correct +// element when the popup window is dismissed. +function id_to_windowname(text) { + text = text.replace(/\./g, '__dot__'); + text = text.replace(/\-/g, '__dash__'); + return text; +} + +function windowname_to_id(text) { + text = text.replace(/__dot__/g, '.'); + text = text.replace(/__dash__/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, '___'); + name = id_to_windowname(name); var href; if (triggeringLink.href.search(/\?/) >= 0) { href = triggeringLink.href + '&pop=1'; @@ -17,9 +42,9 @@ function showRelatedObjectLookupPopup(triggeringLink) { } function dismissRelatedLookupPopup(win, chosenId) { - var name = win.name.replace(/___/g, '.'); + var name = windowname_to_id(win.name); var elem = document.getElementById(name); - if (elem.className.indexOf('vRawIdAdminField') != -1 && elem.value) { + if (elem.className.indexOf('vManyToManyRawIdAdminField') != -1 && elem.value) { elem.value += ',' + chosenId; } else { document.getElementById(name).value = chosenId; @@ -29,14 +54,24 @@ function dismissRelatedLookupPopup(win, chosenId) { function showAddAnotherPopup(triggeringLink) { var name = triggeringLink.id.replace(/^add_/, ''); - name = name.replace(/\./g, '___'); - var win = window.open(triggeringLink.href + '?_popup=1', name, 'height=500,width=800,resizable=yes,scrollbars=yes'); + name = id_to_windowname(name); + href = triggeringLink.href + if (href.indexOf('?') == -1) { + href += '?_popup=1'; + } else { + href += '&_popup=1'; + } + var win = window.open(href, name, 'height=500,width=800,resizable=yes,scrollbars=yes'); win.focus(); return false; } function dismissAddAnotherPopup(win, newId, newRepr) { - var name = win.name.replace(/___/g, '.'); + // 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 = windowname_to_id(win.name); var elem = document.getElementById(name); if (elem) { if (elem.nodeName == 'SELECT') { diff --git a/media/admin_media/js/core.js b/media/admin_media/js/core.js index a17ac8a..c8d0db6 100644 --- a/media/admin_media/js/core.js +++ b/media/admin_media/js/core.js @@ -1,5 +1,9 @@ // 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) { @@ -71,9 +75,13 @@ function findPosX(obj) { var curleft = 0; if (obj.offsetParent) { while (obj.offsetParent) { - curleft += obj.offsetLeft; + 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; } @@ -84,9 +92,13 @@ function findPosY(obj) { var curtop = 0; if (obj.offsetParent) { while (obj.offsetParent) { - curtop += obj.offsetTop; + 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; } diff --git a/media/admin_media/js/urlify.js b/media/admin_media/js/urlify.js index 9b87113..d8f2549 100644 --- a/media/admin_media/js/urlify.js +++ b/media/admin_media/js/urlify.js @@ -1,15 +1,140 @@ +var LATIN_MAP = { + 'À': 'A', 'Á': 'A', 'Â': 'A', 'Ã': 'A', 'Ä': 'A', 'Å': 'A', 'Æ': 'AE', 'Ç': + 'C', 'È': 'E', 'É': 'E', 'Ê': 'E', 'Ë': 'E', 'Ì': 'I', 'Í': 'I', 'Î': 'I', + 'Ï': 'I', 'Ð': 'D', 'Ñ': 'N', 'Ò': 'O', 'Ó': 'O', 'Ô': 'O', 'Õ': 'O', 'Ö': + 'O', 'Ő': 'O', 'Ø': 'O', 'Ù': 'U', 'Ú': 'U', 'Û': 'U', 'Ü': 'U', 'Ű': 'U', + 'Ý': 'Y', 'Þ': 'TH', 'ß': 'ss', 'à':'a', 'á':'a', 'â': 'a', 'ã': 'a', 'ä': + 'a', 'å': 'a', 'æ': 'ae', 'ç': 'c', 'è': 'e', 'é': 'e', 'ê': 'e', 'ë': 'e', + 'ì': 'i', 'í': 'i', 'î': 'i', 'ï': 'i', 'ð': 'd', 'ñ': 'n', 'ò': 'o', 'ó': + 'o', 'ô': 'o', 'õ': 'o', 'ö': 'o', 'ő': 'o', 'ø': 'o', 'ù': 'u', 'ú': 'u', + 'û': 'u', 'ü': 'u', 'ű': 'u', 'ý': 'y', 'þ': 'th', 'ÿ': 'y' +} +var LATIN_SYMBOLS_MAP = { + '©':'(c)' +} +var GREEK_MAP = { + 'α':'a', 'β':'b', 'γ':'g', 'δ':'d', 'ε':'e', 'ζ':'z', 'η':'h', 'θ':'8', + 'ι':'i', 'κ':'k', 'λ':'l', 'μ':'m', 'ν':'n', 'ξ':'3', 'ο':'o', 'π':'p', + 'ρ':'r', 'σ':'s', 'τ':'t', 'υ':'y', 'φ':'f', 'χ':'x', 'ψ':'ps', 'ω':'w', + 'ά':'a', 'έ':'e', 'ί':'i', 'ό':'o', 'ύ':'y', 'ή':'h', 'ώ':'w', 'ς':'s', + 'ϊ':'i', 'ΰ':'y', 'ϋ':'y', 'ΐ':'i', + 'Α':'A', 'Β':'B', 'Γ':'G', 'Δ':'D', 'Ε':'E', 'Ζ':'Z', 'Η':'H', 'Θ':'8', + 'Ι':'I', 'Κ':'K', 'Λ':'L', 'Μ':'M', 'Ν':'N', 'Ξ':'3', 'Ο':'O', 'Π':'P', + 'Ρ':'R', 'Σ':'S', 'Τ':'T', 'Υ':'Y', 'Φ':'F', 'Χ':'X', 'Ψ':'PS', 'Ω':'W', + 'Ά':'A', 'Έ':'E', 'Ί':'I', 'Ό':'O', 'Ύ':'Y', 'Ή':'H', 'Ώ':'W', 'Ϊ':'I', + 'Ϋ':'Y' +} +var TURKISH_MAP = { + 'ş':'s', 'Ş':'S', 'ı':'i', 'İ':'I', 'ç':'c', 'Ç':'C', 'ü':'u', 'Ü':'U', + 'ö':'o', 'Ö':'O', 'ğ':'g', 'Ğ':'G' +} +var RUSSIAN_MAP = { + 'а':'a', 'б':'b', 'в':'v', 'г':'g', 'д':'d', 'е':'e', 'ё':'yo', 'ж':'zh', + 'з':'z', 'и':'i', 'й':'j', 'к':'k', 'л':'l', 'м':'m', 'н':'n', 'о':'o', + 'п':'p', 'р':'r', 'с':'s', 'т':'t', 'у':'u', 'ф':'f', 'х':'h', 'ц':'c', + 'ч':'ch', 'ш':'sh', 'щ':'sh', 'ъ':'', 'ы':'y', 'ь':'', 'э':'e', 'ю':'yu', + 'я':'ya', + 'А':'A', 'Б':'B', 'В':'V', 'Г':'G', 'Д':'D', 'Е':'E', 'Ё':'Yo', 'Ж':'Zh', + 'З':'Z', 'И':'I', 'Й':'J', 'К':'K', 'Л':'L', 'М':'M', 'Н':'N', 'О':'O', + 'П':'P', 'Р':'R', 'С':'S', 'Т':'T', 'У':'U', 'Ф':'F', 'Х':'H', 'Ц':'C', + 'Ч':'Ch', 'Ш':'Sh', 'Щ':'Sh', 'Ъ':'', 'Ы':'Y', 'Ь':'', 'Э':'E', 'Ю':'Yu', + 'Я':'Ya' +} +var UKRAINIAN_MAP = { + 'Є':'Ye', 'І':'I', 'Ї':'Yi', 'Ґ':'G', 'є':'ye', 'і':'i', 'ї':'yi', 'ґ':'g' +} +var CZECH_MAP = { + 'č':'c', 'ď':'d', 'ě':'e', 'ň': 'n', 'ř':'r', 'š':'s', 'ť':'t', 'ů':'u', + 'ž':'z', 'Č':'C', 'Ď':'D', 'Ě':'E', 'Ň': 'N', 'Ř':'R', 'Š':'S', 'Ť':'T', + 'Ů':'U', 'Ž':'Z' +} + +var POLISH_MAP = { + 'ą':'a', 'ć':'c', 'ę':'e', 'ł':'l', 'ń':'n', 'ó':'o', 'ś':'s', 'ź':'z', + 'ż':'z', 'Ą':'A', 'Ć':'C', 'Ę':'e', 'Ł':'L', 'Ń':'N', 'Ó':'o', 'Ś':'S', + 'Ź':'Z', 'Ż':'Z' +} + +var LATVIAN_MAP = { + 'ā':'a', 'č':'c', 'ē':'e', 'ģ':'g', 'ī':'i', 'ķ':'k', 'ļ':'l', 'ņ':'n', + 'š':'s', 'ū':'u', 'ž':'z', 'Ā':'A', 'Č':'C', 'Ē':'E', 'Ģ':'G', 'Ī':'i', + 'Ķ':'k', 'Ļ':'L', 'Ņ':'N', 'Š':'S', 'Ū':'u', 'Ž':'Z' +} + +var ALL_DOWNCODE_MAPS=new Array() +ALL_DOWNCODE_MAPS[0]=LATIN_MAP +ALL_DOWNCODE_MAPS[1]=LATIN_SYMBOLS_MAP +ALL_DOWNCODE_MAPS[2]=GREEK_MAP +ALL_DOWNCODE_MAPS[3]=TURKISH_MAP +ALL_DOWNCODE_MAPS[4]=RUSSIAN_MAP +ALL_DOWNCODE_MAPS[5]=UKRAINIAN_MAP +ALL_DOWNCODE_MAPS[6]=CZECH_MAP +ALL_DOWNCODE_MAPS[7]=POLISH_MAP +ALL_DOWNCODE_MAPS[8]=LATVIAN_MAP + +var Downcoder = new Object(); +Downcoder.Initialize = function() +{ + if (Downcoder.map) // already made + return ; + Downcoder.map ={} + Downcoder.chars = '' ; + for(var i in ALL_DOWNCODE_MAPS) + { + var lookup = ALL_DOWNCODE_MAPS[i] + for (var c in lookup) + { + Downcoder.map[c] = lookup[c] ; + Downcoder.chars += c ; + } + } + Downcoder.regex = new RegExp('[' + Downcoder.chars + ']|[^' + Downcoder.chars + ']+','g') ; +} + +downcode= function( slug ) +{ + Downcoder.Initialize() ; + var downcoded ="" + var pieces = slug.match(Downcoder.regex); + if(pieces) + { + for (var i = 0 ; i < pieces.length ; i++) + { + if (pieces[i].length == 1) + { + var mapped = Downcoder.map[pieces[i]] ; + if (mapped != null) + { + downcoded+=mapped; + continue ; + } + } + downcoded+=pieces[i]; + } + } + else + { + downcoded = slug; + } + return downcoded; +} + + function URLify(s, num_chars) { // changes, e.g., "Petty theft" to "petty_theft" // remove all these words from the string before urlifying + s = downcode(s); removelist = ["a", "an", "as", "at", "before", "but", "by", "for", "from", "is", "in", "into", "like", "of", "off", "on", "onto", "per", "since", "than", "the", "this", "that", "to", "up", "via", "with"]; r = new RegExp('\\b(' + removelist.join('|') + ')\\b', 'gi'); s = s.replace(r, ''); + // if downcode doesn't hit, the char will be stripped here s = s.replace(/[^-\w\s]/g, ''); // remove unneeded chars s = s.replace(/^\s+|\s+$/g, ''); // trim leading/trailing spaces s = s.replace(/[-\s]+/g, '-'); // convert spaces to hyphens s = s.toLowerCase(); // convert to lowercase return s.substring(0, num_chars);// trim to first num_chars chars } + |