Ticket #1613: django-dojo.2.diff
File django-dojo.2.diff, 201.9 KB (added by , 19 years ago) |
---|
-
media/css/widgets.css
42 42 .file-upload .deletelink { margin-left:5px; } 43 43 44 44 /* CALENDARS & CLOCKS */ 45 .calendarbox, .clockbox { margin:5px auto; width: 10em; text-align: center; background:white; position:relative; }45 .calendarbox, .clockbox { margin:5px auto; font-size: 11px; width: 16em; text-align: center; background:white; position:relative; } 46 46 .clockbox { width:6em; } 47 47 .calendar { margin:0; padding: 0; } 48 .calendar table { margin: 0; padding:0; border-collapse:collapse; background:white; width:99%; }48 .calendar table { margin:0; padding:0; border-collapse:collapse; background:white; width:99%; } 49 49 .calendar caption, .calendarbox h2 { margin: 0; font-size:11px; text-align:center; border-top:none; } 50 50 .calendar th { font-size:10px; color:#666; padding:2px 3px; text-align:center; background:#e1e1e1 url(../img/admin/nav-bg.gif) 0 50% repeat-x; border-bottom:1px solid #ddd; } 51 51 .calendar td { font-size:11px; text-align: center; padding: 0; border-top:1px solid #eee; border-bottom:none; } -
media/js/SelectFilter.js
1 /*2 SelectFilter - Turns a multiple-select box into a filter interface.3 4 Requires SelectBox.js and addevent.js.5 */6 7 function findForm(node) {8 // returns the node of the form containing the given node9 if (node.tagName.toLowerCase() != 'form') {10 return findForm(node.parentNode);11 }12 return node;13 }14 15 var SelectFilter = {16 init: function(field_id) {17 var from_box = document.getElementById(field_id);18 from_box.id += '_from'; // change its ID19 // Create the INPUT input box20 var input_box = document.createElement('input');21 input_box.id = field_id + '_input';22 input_box.setAttribute('type', 'text');23 from_box.parentNode.insertBefore(input_box, from_box);24 from_box.parentNode.insertBefore(document.createElement('br'), input_box.nextSibling);25 // Create the TO box26 var to_box = document.createElement('select');27 to_box.id = field_id + '_to';28 to_box.setAttribute('multiple', 'multiple');29 to_box.setAttribute('size', from_box.size);30 from_box.parentNode.insertBefore(to_box, from_box.nextSibling);31 to_box.setAttribute('name', from_box.getAttribute('name'));32 from_box.setAttribute('name', from_box.getAttribute('name') + '_old');33 // Give the filters a CSS hook34 from_box.setAttribute('class', 'filtered');35 to_box.setAttribute('class', 'filtered');36 // Set up the JavaScript event handlers for the select box filter interface37 addEvent(input_box, 'keyup', function(e) { SelectFilter.filter_key_up(e, field_id); });38 addEvent(input_box, 'keydown', function(e) { SelectFilter.filter_key_down(e, field_id); });39 addEvent(from_box, 'dblclick', function() { SelectBox.move(field_id + '_from', field_id + '_to'); });40 addEvent(from_box, 'focus', function() { input_box.focus(); });41 addEvent(to_box, 'dblclick', function() { SelectBox.move(field_id + '_to', field_id + '_from'); });42 addEvent(findForm(from_box), 'submit', function() { SelectBox.select_all(field_id + '_to'); });43 SelectBox.init(field_id + '_from');44 SelectBox.init(field_id + '_to');45 // Move selected from_box options to to_box46 SelectBox.move(field_id + '_from', field_id + '_to');47 },48 filter_key_up: function(event, field_id) {49 from = document.getElementById(field_id + '_from');50 // don't submit form if user pressed Enter51 if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)) {52 from.selectedIndex = 0;53 SelectBox.move(field_id + '_from', field_id + '_to');54 from.selectedIndex = 0;55 return false;56 }57 var temp = from.selectedIndex;58 SelectBox.filter(field_id + '_from', document.getElementById(field_id + '_input').value);59 from.selectedIndex = temp;60 return true;61 },62 filter_key_down: function(event, field_id) {63 from = document.getElementById(field_id + '_from');64 // right arrow -- move across65 if ((event.which && event.which == 39) || (event.keyCode && event.keyCode == 39)) {66 var old_index = from.selectedIndex;67 SelectBox.move(field_id + '_from', field_id + '_to');68 from.selectedIndex = (old_index == from.length) ? from.length - 1 : old_index;69 return false;70 }71 // down arrow -- wrap around72 if ((event.which && event.which == 40) || (event.keyCode && event.keyCode == 40)) {73 from.selectedIndex = (from.length == from.selectedIndex + 1) ? 0 : from.selectedIndex + 1;74 }75 // up arrow -- wrap around76 if ((event.which && event.which == 38) || (event.keyCode && event.keyCode == 38)) {77 from.selectedIndex = (from.selectedIndex == 0) ? from.length - 1 : from.selectedIndex - 1;78 }79 return true;80 }81 } -
media/js/SelectFilter2.js
1 /*2 SelectFilter2 - Turns a multiple-select box into a filter interface.3 4 Different than SelectFilter because this is coupled to the admin framework.5 6 Requires core.js, SelectBox.js and addevent.js.7 */8 9 function findForm(node) {10 // returns the node of the form containing the given node11 if (node.tagName.toLowerCase() != 'form') {12 return findForm(node.parentNode);13 }14 return node;15 }16 17 var SelectFilter = {18 init: function(field_id, field_name, is_stacked, admin_media_prefix) {19 var from_box = document.getElementById(field_id);20 from_box.id += '_from'; // change its ID21 from_box.className = 'filtered';22 23 // Remove <p class="info">, because it just gets in the way.24 var ps = from_box.parentNode.getElementsByTagName('p');25 for (var i=0; i<ps.length; i++) {26 from_box.parentNode.removeChild(ps[i]);27 }28 29 // <div class="selector"> or <div class="selector stacked">30 var selector_div = quickElement('div', from_box.parentNode);31 selector_div.className = is_stacked ? 'selector stacked' : 'selector';32 33 // <div class="selector-available">34 var selector_available = quickElement('div', selector_div, '');35 selector_available.className = 'selector-available';36 quickElement('h2', selector_available, interpolate(gettext('Available %s'), [field_name]));37 var filter_p = quickElement('p', selector_available, '');38 filter_p.className = 'selector-filter';39 quickElement('img', filter_p, '', 'src', admin_media_prefix + 'img/admin/selector-search.gif');40 filter_p.appendChild(document.createTextNode(' '));41 var filter_input = quickElement('input', filter_p, '', 'type', 'text');42 filter_input.id = field_id + '_input';43 selector_available.appendChild(from_box);44 var choose_all = quickElement('a', selector_available, gettext('Choose all'), 'href', 'javascript: (function(){ SelectBox.move_all("' + field_id + '_from", "' + field_id + '_to"); })()');45 choose_all.className = 'selector-chooseall';46 47 // <ul class="selector-chooser">48 var selector_chooser = quickElement('ul', selector_div, '');49 selector_chooser.className = 'selector-chooser';50 var add_link = quickElement('a', quickElement('li', selector_chooser, ''), gettext('Add'), 'href', 'javascript: (function(){ SelectBox.move("' + field_id + '_from","' + field_id + '_to");})()');51 add_link.className = 'selector-add';52 var remove_link = quickElement('a', quickElement('li', selector_chooser, ''), gettext('Remove'), 'href', 'javascript: (function(){ SelectBox.move("' + field_id + '_to","' + field_id + '_from");})()');53 remove_link.className = 'selector-remove';54 55 // <div class="selector-chosen">56 var selector_chosen = quickElement('div', selector_div, '');57 selector_chosen.className = 'selector-chosen';58 quickElement('h2', selector_chosen, interpolate(gettext('Chosen %s'), [field_name]));59 var selector_filter = quickElement('p', selector_chosen, gettext('Select your choice(s) and click '));60 selector_filter.className = 'selector-filter';61 quickElement('img', selector_filter, '', 'src', admin_media_prefix + 'img/admin/selector-add.gif', 'alt', 'Add');62 var to_box = quickElement('select', selector_chosen, '', 'id', field_id + '_to', 'multiple', 'multiple', 'size', from_box.size, 'name', from_box.getAttribute('name'));63 to_box.className = 'filtered';64 var clear_all = quickElement('a', selector_chosen, gettext('Clear all'), 'href', 'javascript: (function() { SelectBox.move_all("' + field_id + '_to", "' + field_id + '_from");})()');65 clear_all.className = 'selector-clearall';66 67 from_box.setAttribute('name', from_box.getAttribute('name') + '_old');68 69 // Set up the JavaScript event handlers for the select box filter interface70 addEvent(filter_input, 'keyup', function(e) { SelectFilter.filter_key_up(e, field_id); });71 addEvent(filter_input, 'keydown', function(e) { SelectFilter.filter_key_down(e, field_id); });72 addEvent(from_box, 'dblclick', function() { SelectBox.move(field_id + '_from', field_id + '_to'); });73 addEvent(to_box, 'dblclick', function() { SelectBox.move(field_id + '_to', field_id + '_from'); });74 addEvent(findForm(from_box), 'submit', function() { SelectBox.select_all(field_id + '_to'); });75 SelectBox.init(field_id + '_from');76 SelectBox.init(field_id + '_to');77 // Move selected from_box options to to_box78 SelectBox.move(field_id + '_from', field_id + '_to');79 },80 filter_key_up: function(event, field_id) {81 from = document.getElementById(field_id + '_from');82 // don't submit form if user pressed Enter83 if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)) {84 from.selectedIndex = 0;85 SelectBox.move(field_id + '_from', field_id + '_to');86 from.selectedIndex = 0;87 return false;88 }89 var temp = from.selectedIndex;90 SelectBox.filter(field_id + '_from', document.getElementById(field_id + '_input').value);91 from.selectedIndex = temp;92 return true;93 },94 filter_key_down: function(event, field_id) {95 from = document.getElementById(field_id + '_from');96 // right arrow -- move across97 if ((event.which && event.which == 39) || (event.keyCode && event.keyCode == 39)) {98 var old_index = from.selectedIndex;99 SelectBox.move(field_id + '_from', field_id + '_to');100 from.selectedIndex = (old_index == from.length) ? from.length - 1 : old_index;101 return false;102 }103 // down arrow -- wrap around104 if ((event.which && event.which == 40) || (event.keyCode && event.keyCode == 40)) {105 from.selectedIndex = (from.length == from.selectedIndex + 1) ? 0 : from.selectedIndex + 1;106 }107 // up arrow -- wrap around108 if ((event.which && event.which == 38) || (event.keyCode && event.keyCode == 38)) {109 from.selectedIndex = (from.selectedIndex == 0) ? from.length - 1 : from.selectedIndex - 1;110 }111 return true;112 }113 } -
media/js/django/string.js
1 dojo.provide('django.string'); 2 3 django.string = { 4 pad_left: function(str, pad_length, pad_string) { 5 var new_string = str; 6 for (var i = 0; new_string.length < pad_length; i++) { 7 new_string = pad_string + new_string; 8 } 9 return new_string; 10 } 11 }; 12 No newline at end of file -
media/js/django/admin.js
1 dojo.provide('django.admin'); 2 dojo.require('django.util'); 3 4 django.admin = { 5 init: function() { 6 if(typeof(auto_populate_array) != 'undefined') { 7 // dojo.require('django.admin.AutoPopulate'); 8 django.admin.AutoPopulate.init(auto_populate_array); 9 } 10 11 if(typeof(select_filter_array) != 'undefined') { 12 dojo.require('django.widget.SelectFilter'); 13 django.admin.initFilterWidgets(select_filter_array, admin_media_prefix); 14 } 15 16 if(typeof(date_time_fields) != 'undefined') { 17 dojo.require('django.widget.DateTime'); 18 } 19 20 if(typeof(first_form_field_id) != 'undefined') { 21 document.getElementById(first_form_field_id).focus(); 22 } 23 24 dojo.require('django.admin.RelatedLookups'); 25 django.admin.RelatedLookups.init(); 26 dojo.require('django.admin.CollapsedFieldsets'); 27 }, 28 29 initFilterWidgets: function(filterElementArray) { 30 for(var field in filterElementArray) { 31 django.widget.SelectFilter.init(field, filterElementArray[field][0], filterElementArray[field][1], filterElementArray[field][2]); 32 } 33 } 34 }; 35 36 dojo.addOnLoad(django.admin.init); 37 No newline at end of file -
media/js/django/widget/SelectFilter.js
1 dojo.provide('django.widget.SelectFilter'); 2 dojo.require('django.util'); 3 dojo.require('django.widget.SelectBox'); 4 5 django.widget.SelectFilter = { 6 init: function(field_id, field_name, is_stacked, admin_media_prefix) { 7 var from_box = document.getElementById(field_id); 8 from_box.id += '_from'; // change its ID 9 from_box.className = 'filtered'; 10 11 // Remove <p class="info">, because it just gets in the way. 12 var ps = from_box.parentNode.getElementsByTagName('p'); 13 for (var i=0; i<ps.length; i++) { 14 from_box.parentNode.removeChild(ps[i]); 15 } 16 17 // <div class="selector"> or <div class="selector stacked"> 18 var selector_div = django.util.quickElement('div', from_box.parentNode); 19 selector_div.className = is_stacked ? 'selector stacked' : 'selector'; 20 21 // <div class="selector-available"> 22 var selector_available = django.util.quickElement('div', selector_div, ''); 23 selector_available.className = 'selector-available'; 24 django.util.quickElement('h2', selector_available, interpolate(gettext('Available %s'), [field_name])); 25 var filter_p = django.util.quickElement('p', selector_available, ''); 26 filter_p.className = 'selector-filter'; 27 django.util.quickElement('img', filter_p, '', 'src', admin_media_prefix + 'img/admin/selector-search.gif'); 28 filter_p.appendChild(document.createTextNode(' ')); 29 var filter_input = django.util.quickElement('input', filter_p, '', 'type', 'text'); 30 filter_input.id = field_id + '_input'; 31 selector_available.appendChild(from_box); 32 var choose_all = django.util.quickElement('a', selector_available, gettext('Choose all'), 'href', 'javascript: (function(){ django.widget.SelectBox.move_all("' + field_id + '_from", "' + field_id + '_to"); })()'); 33 choose_all.className = 'selector-chooseall'; 34 35 // <ul class="selector-chooser"> 36 var selector_chooser = django.util.quickElement('ul', selector_div, ''); 37 selector_chooser.className = 'selector-chooser'; 38 var add_link = django.util.quickElement('a', django.util.quickElement('li', selector_chooser, ''), gettext('Add'), 'href', 'javascript: (function(){ django.widget.SelectBox.move("' + field_id + '_from","' + field_id + '_to");})()'); 39 add_link.className = 'selector-add'; 40 var remove_link = django.util.quickElement('a', django.util.quickElement('li', selector_chooser, ''), gettext('Remove'), 'href', 'javascript: (function(){ django.widget.SelectBox.move("' + field_id + '_to","' + field_id + '_from");})()'); 41 remove_link.className = 'selector-remove'; 42 43 // <div class="selector-chosen"> 44 var selector_chosen = django.util.quickElement('div', selector_div, ''); 45 selector_chosen.className = 'selector-chosen'; 46 django.util.quickElement('h2', selector_chosen, interpolate(gettext('Chosen %s'), [field_name])); 47 var selector_filter = django.util.quickElement('p', selector_chosen, gettext('Select your choice(s) and click ')); 48 selector_filter.className = 'selector-filter'; 49 django.util.quickElement('img', selector_filter, '', 'src', admin_media_prefix + 'img/admin/selector-add.gif', 'alt', 'Add'); 50 var to_box = django.util.quickElement('select', selector_chosen, '', 'id', field_id + '_to', 'multiple', 'multiple', 'size', from_box.size, 'name', from_box.getAttribute('name')); 51 to_box.className = 'filtered'; 52 var clear_all = django.util.quickElement('a', selector_chosen, gettext('Clear all'), 'href', 'javascript: (function() { django.widget.SelectBox.move_all("' + field_id + '_to", "' + field_id + '_from");})()'); 53 clear_all.className = 'selector-clearall'; 54 55 from_box.setAttribute('name', from_box.getAttribute('name') + '_old'); 56 57 // Set up the JavaScript event handlers for the select box filter interface 58 django.util.addEvent(filter_input, 'keyup', function(e) { SelectFilter.filter_key_up(e, field_id); }); 59 django.util.addEvent(filter_input, 'keydown', function(e) { SelectFilter.filter_key_down(e, field_id); }); 60 django.util.addEvent(from_box, 'dblclick', function() { django.widget.SelectBox.move(field_id + '_from', field_id + '_to'); }); 61 django.util.addEvent(to_box, 'dblclick', function() { django.widget.SelectBox.move(field_id + '_to', field_id + '_from'); }); 62 django.util.addEvent(django.util.findForm(from_box), 'submit', function() { django.widget.SelectBox.select_all(field_id + '_to'); }); 63 django.widget.SelectBox.init(field_id + '_from'); 64 django.widget.SelectBox.init(field_id + '_to'); 65 // Move selected from_box options to to_box 66 django.widget.SelectBox.move(field_id + '_from', field_id + '_to'); 67 }, 68 filter_key_up: function(event, field_id) { 69 from = document.getElementById(field_id + '_from'); 70 // don't submit form if user pressed Enter 71 if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)) { 72 from.selectedIndex = 0; 73 django.widget.SelectBox.move(field_id + '_from', field_id + '_to'); 74 from.selectedIndex = 0; 75 return false; 76 } 77 var temp = from.selectedIndex; 78 django.widget.SelectBox.filter(field_id + '_from', document.getElementById(field_id + '_input').value); 79 from.selectedIndex = temp; 80 return true; 81 }, 82 filter_key_down: function(event, field_id) { 83 from = document.getElementById(field_id + '_from'); 84 // right arrow -- move across 85 if ((event.which && event.which == 39) || (event.keyCode && event.keyCode == 39)) { 86 var old_index = from.selectedIndex; 87 django.widget.SelectBox.move(field_id + '_from', field_id + '_to'); 88 from.selectedIndex = (old_index == from.length) ? from.length - 1 : old_index; 89 return false; 90 } 91 // down arrow -- wrap around 92 if ((event.which && event.which == 40) || (event.keyCode && event.keyCode == 40)) { 93 from.selectedIndex = (from.length == from.selectedIndex + 1) ? 0 : from.selectedIndex + 1; 94 } 95 // up arrow -- wrap around 96 if ((event.which && event.which == 38) || (event.keyCode && event.keyCode == 38)) { 97 from.selectedIndex = (from.selectedIndex === 0) ? from.length - 1 : from.selectedIndex - 1; 98 } 99 return true; 100 } 101 }; 102 No newline at end of file -
media/js/django/widget/SelectBox.js
1 dojo.provide('django.widget.SelectBox'); 2 3 django.widget.SelectBox = { 4 cache: new Object(), 5 init: function(id) { 6 var box = document.getElementById(id); 7 var node; 8 django.widget.SelectBox.cache[id] = new Array(); 9 var cache = django.widget.SelectBox.cache[id]; 10 for (var i = 0; (node = box.options[i]); i++) { 11 cache.push({ value: node.value, text: node.text, displayed: 1 }); 12 } 13 }, 14 redisplay: function(id) { 15 // Repopulate HTML select box from cache 16 var box = document.getElementById(id); 17 box.options.length = 0; // clear all options 18 for (var i = 0, j = django.widget.SelectBox.cache[id].length; i < j; i++) { 19 var node = django.widget.SelectBox.cache[id][i]; 20 if (node.displayed) { 21 box.options[box.options.length] = new Option(node.text, node.value, false, false); 22 } 23 } 24 }, 25 filter: function(id, text) { 26 // Redisplay the HTML select box, displaying only the choices containing ALL 27 // the words in text. (It's an AND search.) 28 var tokens = text.toLowerCase().split(/\s+/); 29 var node, token; 30 for (var i = 0; (node = django.widget.SelectBox.cache[id][i]); i++) { 31 node.displayed = 1; 32 for (var j = 0; (token = tokens[j]); j++) { 33 if (node.text.toLowerCase().indexOf(token) == -1) { 34 node.displayed = 0; 35 } 36 } 37 } 38 django.widget.SelectBox.redisplay(id); 39 }, 40 delete_from_cache: function(id, value) { 41 var node, delete_index = null; 42 for (var i = 0; (node = django.widget.SelectBox.cache[id][i]); i++) { 43 if (node.value == value) { 44 delete_index = i; 45 break; 46 } 47 } 48 var j = django.widget.SelectBox.cache[id].length - 1; 49 for (var i = delete_index; i < j; i++) { 50 django.widget.SelectBox.cache[id][i] = django.widget.SelectBox.cache[id][i+1]; 51 } 52 django.widget.SelectBox.cache[id].length--; 53 }, 54 add_to_cache: function(id, option) { 55 django.widget.SelectBox.cache[id].push({ value: option.value, text: option.text, displayed: 1 }); 56 }, 57 cache_contains: function(id, value) { 58 // Check if an item is contained in the cache 59 var node; 60 for (var i = 0; (node = django.widget.SelectBox.cache[id][i]); i++) { 61 if (node.value == value) { 62 return true; 63 } 64 } 65 return false; 66 }, 67 move: function(from, to) { 68 var from_box = document.getElementById(from); 69 var to_box = document.getElementById(to); 70 var option; 71 for (var i = 0; (option = from_box.options[i]); i++) { 72 if (option.selected && django.widget.SelectBox.cache_contains(from, option.value)) { 73 django.widget.SelectBox.add_to_cache(to, { value: option.value, text: option.text, displayed: 1 }); 74 django.widget.SelectBox.delete_from_cache(from, option.value); 75 } 76 } 77 django.widget.SelectBox.redisplay(from); 78 django.widget.SelectBox.redisplay(to); 79 }, 80 move_all: function(from, to) { 81 var from_box = document.getElementById(from); 82 var to_box = document.getElementById(to); 83 var option; 84 for (var i = 0; (option = from_box.options[i]); i++) { 85 django.widget.SelectBox.add_to_cache(to, { value: option.value, text: option.text, displayed: 1 }); 86 django.widget.SelectBox.delete_from_cache(from, option.value); 87 } 88 django.widget.SelectBox.redisplay(from); 89 django.widget.SelectBox.redisplay(to); 90 }, 91 sort: function(id) { 92 django.widget.SelectBox.cache[id].sort( function(a, b) { 93 a = a.text.toLowerCase(); 94 b = b.text.toLowerCase(); 95 try { 96 if (a > b) return 1; 97 if (a < b) return -1; 98 } 99 catch (e) { 100 // silently fail on IE 'unknown' exception 101 } 102 return 0; 103 }); 104 }, 105 select_all: function(id) { 106 var box = document.getElementById(id); 107 for (var i = 0; i < box.options.length; i++) { 108 box.options[i].selected = 'selected'; 109 } 110 } 111 }; 112 No newline at end of file -
media/js/django/widget/DateTime.js
1 dojo.provide('django.widget.DateTime'); 2 dojo.require('django.datetime.*'); 3 4 // Inserts shortcut buttons after all of the following: 5 // <input type="text" class="vDateField"> 6 // <input type="text" class="vTimeField"> 7 8 django.widget.DateTime = { 9 widgetType: 'DjangoDateTime', 10 calendars: [], 11 calendarInputs: [], 12 clockInputs: [], 13 calendarDivName1: 'calendarbox', // name of calendar <div> that gets toggled 14 calendarDivName2: 'calendarin', // name of <div> that contains calendar 15 clockDivName: 'clockbox', // name of clock <div> that gets toggled 16 admin_media_prefix: '', 17 init: function() { 18 django.widget.DateTime.admin_media_prefix = admin_media_prefix; 19 20 var inputs = document.getElementsByTagName('input'); 21 for (i=0; i<inputs.length; i++) { 22 var inp = inputs[i]; 23 if (inp.getAttribute('type') == 'text' && inp.className.match(/vTimeField/)) { 24 django.widget.DateTime.addClock(inp); 25 } 26 else if (inp.getAttribute('type') == 'text' && inp.className.match(/vDateField/)) { 27 django.widget.DateTime.addCalendar(inp); 28 } 29 } 30 }, 31 // Add clock widget to a given field 32 addClock: function(inp) { 33 var num = django.widget.DateTime.clockInputs.length; 34 django.widget.DateTime.clockInputs[num] = inp; 35 36 // Shortcut links (clock icon and "Now" link) 37 var shortcuts_span = document.createElement('span'); 38 inp.parentNode.insertBefore(shortcuts_span, inp.nextSibling); 39 var now_link = document.createElement('a'); 40 now_link.setAttribute('href', "javascript:django.widget.DateTime.handleClockQuicklink(" + num + ", django.datetime.getHourMinute(new Date()));"); 41 now_link.appendChild(document.createTextNode(gettext('Now'))); 42 var clock_link = document.createElement('a'); 43 clock_link.setAttribute('href', 'javascript:django.widget.DateTime.openClock(' + num + ');'); 44 django.util.quickElement('img', clock_link, '', 'src', django.widget.DateTime.admin_media_prefix + 'img/admin/icon_clock.gif', 'alt', gettext('Clock')); 45 shortcuts_span.appendChild(document.createTextNode('\240')); 46 shortcuts_span.appendChild(now_link); 47 shortcuts_span.appendChild(document.createTextNode('\240|\240')); 48 shortcuts_span.appendChild(clock_link); 49 50 // Create clock link div 51 // 52 // Markup looks like: 53 // <div id="clockbox1" class="clockbox module"> 54 // <h2>Choose a time</h2> 55 // <ul class="timelist"> 56 // <li><a href="#">Now</a></li> 57 // <li><a href="#">Midnight</a></li> 58 // <li><a href="#">6 a.m.</a></li> 59 // <li><a href="#">Noon</a></li> 60 // </ul> 61 // <p class="calendar-cancel"><a href="#">Cancel</a></p> 62 // </div> 63 64 var clock_box = document.createElement('div'); 65 clock_box.style.display = 'none'; 66 clock_box.style.position = 'absolute'; 67 clock_box.style.left = django.util.findPosX(clock_link) + 17 + 'px'; 68 clock_box.style.top = django.util.findPosY(clock_link) - 30 + 'px'; 69 clock_box.className = 'clockbox module'; 70 clock_box.setAttribute('id', django.widget.DateTime.clockDivName + num); 71 document.body.appendChild(clock_box); 72 django.util.addEvent(clock_box, 'click', django.widget.DateTime.cancelEventPropagation); 73 74 django.util.quickElement('h2', clock_box, gettext('Choose a time')); 75 time_list = django.util.quickElement('ul', clock_box, ''); 76 time_list.className = 'timelist'; 77 django.util.quickElement("a", django.util.quickElement("li", time_list, ""), gettext("Now"), "href", "javascript:django.widget.DateTime.handleClockQuicklink(" + num + ", django.datetime.getHourMinute(new Date()));") 78 django.util.quickElement("a", django.util.quickElement("li", time_list, ""), gettext("Midnight"), "href", "javascript:django.widget.DateTime.handleClockQuicklink(" + num + ", '00:00');") 79 django.util.quickElement("a", django.util.quickElement("li", time_list, ""), gettext("6 a.m."), "href", "javascript:django.widget.DateTime.handleClockQuicklink(" + num + ", '06:00');") 80 django.util.quickElement("a", django.util.quickElement("li", time_list, ""), gettext("Noon"), "href", "javascript:django.widget.DateTime.handleClockQuicklink(" + num + ", '12:00');") 81 82 cancel_p = django.util.quickElement('p', clock_box, ''); 83 cancel_p.className = 'calendar-cancel'; 84 django.util.quickElement('a', cancel_p, gettext('Cancel'), 'href', 'javascript:django.widget.DateTime.dismissClock(' + num + ');'); 85 }, 86 openClock: function(num) { 87 document.getElementById(django.widget.DateTime.clockDivName + num).style.display = 'block'; 88 django.util.addEvent(window, 'click', function() { django.widget.DateTime.dismissClock(num); return true; }); 89 }, 90 dismissClock: function(num) { 91 document.getElementById(django.widget.DateTime.clockDivName + num).style.display = 'none'; 92 window.onclick = null; 93 }, 94 handleClockQuicklink: function(num, val) { 95 django.widget.DateTime.clockInputs[num].value = val; 96 django.widget.DateTime.dismissClock(num); 97 }, 98 // Add calendar widget to a given field. 99 addCalendar: function(inp) { 100 var num = django.widget.DateTime.calendars.length; 101 102 django.widget.DateTime.calendarInputs[num] = inp; 103 104 // Shortcut links (calendar icon and "Today" link) 105 var shortcuts_span = document.createElement('span'); 106 inp.parentNode.insertBefore(shortcuts_span, inp.nextSibling); 107 var today_link = document.createElement('a'); 108 today_link.setAttribute('href', 'javascript:django.widget.DateTime.handleCalendarQuickLink(' + num + ', 0);'); 109 today_link.appendChild(document.createTextNode(gettext('Today'))); 110 var cal_link = document.createElement('a'); 111 cal_link.setAttribute('href', 'javascript:django.widget.DateTime.openCalendar(' + num + ');'); 112 django.util.quickElement('img', cal_link, '', 'src', django.widget.DateTime.admin_media_prefix + 'img/admin/icon_calendar.gif', 'alt', gettext('Calendar')); 113 shortcuts_span.appendChild(document.createTextNode('\240')); 114 shortcuts_span.appendChild(today_link); 115 shortcuts_span.appendChild(document.createTextNode('\240|\240')); 116 shortcuts_span.appendChild(cal_link); 117 118 // Create calendarbox div. 119 // 120 // Markup looks like: 121 // 122 // <div id="calendarbox3" class="calendarbox module"> 123 // <h2> 124 // <a href="#" class="link-previous">‹</a> 125 // <a href="#" class="link-next">›</a> February 2003 126 // </h2> 127 // <div class="calendar" id="calendarin3"> 128 // <!-- (cal) --> 129 // </div> 130 // <div class="calendar-shortcuts"> 131 // <a href="#">Yesterday</a> | <a href="#">Today</a> | <a href="#">Tomorrow</a> 132 // </div> 133 // <p class="calendar-cancel"><a href="#">Cancel</a></p> 134 // </div> 135 var cal_box = document.createElement('div'); 136 cal_box.style.display = 'none'; 137 cal_box.style.position = 'absolute'; 138 cal_box.style.left = django.util.findPosX(cal_link) + 17 + 'px'; 139 cal_box.style.top = django.util.findPosY(cal_link) - 75 + 'px'; 140 cal_box.className = 'calendarbox module'; 141 cal_box.setAttribute('id', django.widget.DateTime.calendarDivName1 + num); 142 document.body.appendChild(cal_box); 143 django.util.addEvent(cal_box, 'click', django.widget.DateTime.cancelEventPropagation); 144 145 // next-prev links 146 var cal_nav = django.util.quickElement('div', cal_box, ''); 147 var cal_nav_prev = django.util.quickElement('a', cal_nav, '<', 'href', 'javascript:django.widget.DateTime.drawPrev('+num+');'); 148 cal_nav_prev.className = 'calendarnav-previous'; 149 var cal_nav_next = django.util.quickElement('a', cal_nav, '>', 'href', 'javascript:django.widget.DateTime.drawNext('+num+');'); 150 cal_nav_next.className = 'calendarnav-next'; 151 cal_box.appendChild(cal_nav); 152 153 // main box 154 var cal_main = django.util.quickElement('div', cal_box, '', 'id', django.widget.DateTime.calendarDivName2 + num); 155 cal_main.className = 'calendar'; 156 django.widget.DateTime.calendars[num] = new django.datetime.calendar.Calendar(django.widget.DateTime.calendarDivName2 + num, django.widget.DateTime.handleCalendarCallback(num)); 157 django.widget.DateTime.calendars[num].drawCurrent(); 158 159 // calendar shortcuts 160 var shortcuts = django.util.quickElement('div', cal_box, ''); 161 shortcuts.className = 'calendar-shortcuts'; 162 django.util.quickElement('a', shortcuts, gettext('Yesterday'), 'href', 'javascript:django.widget.DateTime.handleCalendarQuickLink(' + num + ', -1);'); 163 shortcuts.appendChild(document.createTextNode('\240|\240')); 164 django.util.quickElement('a', shortcuts, gettext('Today'), 'href', 'javascript:django.widget.DateTime.handleCalendarQuickLink(' + num + ', 0);'); 165 shortcuts.appendChild(document.createTextNode('\240|\240')); 166 django.util.quickElement('a', shortcuts, gettext('Tomorrow'), 'href', 'javascript:django.widget.DateTime.handleCalendarQuickLink(' + num + ', +1);'); 167 168 // cancel bar 169 var cancel_p = django.util.quickElement('p', cal_box, ''); 170 cancel_p.className = 'calendar-cancel'; 171 django.util.quickElement('a', cancel_p, gettext('Cancel'), 'href', 'javascript:django.widget.DateTime.dismissCalendar(' + num + ');'); 172 }, 173 openCalendar: function(num) { 174 document.getElementById(django.widget.DateTime.calendarDivName1+num).style.display = 'block'; 175 django.util.addEvent(window, 'click', function() { django.widget.DateTime.dismissCalendar(num); return true; }); 176 }, 177 dismissCalendar: function(num) { 178 document.getElementById(django.widget.DateTime.calendarDivName1+num).style.display = 'none'; 179 }, 180 drawPrev: function(num) { 181 django.widget.DateTime.calendars[num].drawPreviousMonth(); 182 }, 183 drawNext: function(num) { 184 django.widget.DateTime.calendars[num].drawNextMonth(); 185 }, 186 handleCalendarCallback: function(num) { 187 return "function(y, m, d) { django.widget.DateTime.calendarInputs["+num+"].value = y+'-'+m+'-'+d; document.getElementById(django.widget.DateTime.calendarDivName1+"+num+").style.display='none';}"; 188 }, 189 handleCalendarQuickLink: function(num, offset) { 190 var d = new Date(); 191 d.setDate(d.getDate() + offset) 192 django.widget.DateTime.calendarInputs[num].value = django.datetime.getISODate(d); 193 django.widget.DateTime.dismissCalendar(num); 194 }, 195 cancelEventPropagation: function(e) { 196 if (!e) var e = window.event; 197 e.cancelBubble = true; 198 if (e.stopPropagation) e.stopPropagation(); 199 } 200 }; 201 202 dojo.addOnLoad(django.widget.DateTime.init); 203 No newline at end of file -
media/js/django/datetime.js
1 dojo.provide('django.datetime'); 2 3 django.datetime = { 4 getCorrectYear: function(date) { 5 // Date.getYear() is unreliable -- 6 // see http://www.quirksmode.org/js/introdate.html#year 7 var y = date.getYear() % 100; 8 return (y < 38) ? y + 2000 : y + 1900; 9 }, 10 11 getTwoDigitMonth: function(date) { 12 return (date.getMonth() < 9) ? '0' + (date.getMonth()+1) : (date.getMonth()+1); 13 }, 14 15 getTwoDigitDate: function(date) { 16 return (date.getDate() < 10) ? '0' + date.getDate() : date.getDate(); 17 }, 18 19 getTwoDigitMinute: function(date) { 20 return (date.getMinutes() < 10) ? '0' + date.getMinutes() : date.getMinutes(); 21 }, 22 23 getTwoDigitHour: function(date) { 24 return (date.getHours() < 10) ? '0' + date.getHours() : date.getHours(); 25 }, 26 27 getISODate: function(date) { 28 return django.datetime.getCorrectYear(date) + '-' + django.datetime.getTwoDigitMonth(date) + '-' + django.datetime.getTwoDigitDate(date); 29 }, 30 31 getHourMinute: function(date) { 32 return django.datetime.getTwoDigitHour(date) + ':' + django.datetime.getTwoDigitMinute(date); 33 }, 34 35 monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], 36 37 weekdayNames: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'], 38 39 weekdayInitials: ['S', 'M', 'T', 'W', 'T', 'F', 'S'], 40 41 parseToNum: function(english) { 42 var dateTypeInfo = (english.match(/day$/)) ? {'array': django.datetime.weekdayNames, 'type': 'weekday'} : {'array': django.datetime.monthNames, 'type': 'weekday'}; 43 44 var matches = dateTypeInfo['array'].filter(function(item) { 45 return new RegExp("^" + english, "i").test(item); 46 }) 47 48 if(matches.length == 0) { 49 var errString = 'Invalid ' + dateTypeInfo['type'] + ' string'; 50 throw new Error(errString); 51 } 52 53 if(matches.length > 1) { 54 var errString = 'Ambiguous ' + dateTypeInfo['type']; 55 throw new Error(errString); 56 } 57 58 return dateTypeInfo['array'].indexOf(matches[0]); 59 }, 60 61 dateParsePatterns: [ 62 // Today 63 { re: /^tod/i, 64 handler: function() { 65 return new Date(); 66 } 67 }, 68 // Tomorrow 69 { re: /^tom/i, 70 handler: function() { 71 var d = new Date(); 72 d.setDate(d.getDate() + 1); 73 return d; 74 } 75 }, 76 // Yesterday 77 { re: /^yes/i, 78 handler: function() { 79 var d = new Date(); 80 d.setDate(d.getDate() - 1); 81 return d; 82 } 83 }, 84 // 4th 85 { re: /^(\d{1,2})(st|nd|rd|th)?$/i, 86 handler: function(bits) { 87 var d = new Date(); 88 d.setDate(parseInt(bits[1], 10)); 89 return d; 90 } 91 }, 92 // 4th Jan 93 { re: /^(\d{1,2})(?:st|nd|rd|th)? (\w+)$/i, 94 handler: function(bits) { 95 var d = new Date(); 96 d.setDate(parseInt(bits[1], 10)); 97 d.setMonth(parseToNum(bits[2])); 98 return d; 99 } 100 }, 101 // 4th Jan 2003 102 { re: /^(\d{1,2})(?:st|nd|rd|th)? (\w+),? (\d{4})$/i, 103 handler: function(bits) { 104 var d = new Date(); 105 d.setDate(parseInt(bits[1], 10)); 106 d.setMonth(parseToNum(bits[2])); 107 d.setYear(bits[3]); 108 return d; 109 } 110 }, 111 // Jan 4th 112 { re: /^(\w+) (\d{1,2})(?:st|nd|rd|th)?$/i, 113 handler: function(bits) { 114 var d = new Date(); 115 d.setDate(parseInt(bits[2], 10)); 116 d.setMonth(parseToNum(bits[1])); 117 return d; 118 } 119 }, 120 // Jan 4th 2003 121 { re: /^(\d{1,2})(?:st|nd|rd|th)? (?:of )?(\w+),? (\d{4})$/i, 122 handler: function(bits) { 123 var d = new Date(); 124 d.setDate(parseInt(bits[2], 10)); 125 d.setMonth(parseToNum(bits[1])); 126 d.setYear(bits[3]); 127 return d; 128 } 129 }, 130 // next Tuesday - this is suspect due to weird meaning of "next" 131 { re: /^next (\w+)$/i, 132 handler: function(bits) { 133 var d = new Date(); 134 var day = d.getDay(); 135 var newDay = parseToNum(bits[1]); 136 var addDays = newDay - day; 137 if (newDay <= day) { 138 addDays += 7; 139 } 140 d.setDate(d.getDate() + addDays); 141 return d; 142 } 143 }, 144 // last Tuesday 145 { re: /^last (\w+)$/i, 146 handler: function(bits) { 147 throw new Error("Not yet implemented"); 148 } 149 }, 150 // mm/dd/yyyy (American style) 151 { re: /(\d{1,2})\/(\d{1,2})\/(\d{4})/, 152 handler: function(bits) { 153 var d = new Date(); 154 d.setYear(bits[3]); 155 d.setDate(parseInt(bits[2], 10)); 156 d.setMonth(parseInt(bits[1], 10) - 1); // Because months indexed from 0 157 return d; 158 } 159 }, 160 // yyyy-mm-dd (ISO style) 161 { re: /(\d{4})-(\d{1,2})-(\d{1,2})/, 162 handler: function(bits) { 163 var d = new Date(); 164 d.setYear(parseInt(bits[1])); 165 d.setDate(parseInt(bits[3], 10)); 166 d.setMonth(parseInt(bits[2], 10) - 1); 167 return d; 168 } 169 }, 170 ], 171 172 parseDateString: function(s) { 173 for (var i = 0; i < django.datetime.dateParsePatterns.length; i++) { 174 var re = django.datetime.dateParsePatterns[i].re; 175 var handler = django.datetime.dateParsePatterns[i].handler; 176 var bits = re.exec(s); 177 if (bits) { 178 return handler(bits); 179 } 180 } 181 throw new Error("Invalid date string"); 182 }, 183 184 fmt00: function(x) { 185 // fmt00: Tags leading zero onto numbers 0 - 9. 186 // Particularly useful for displaying results from Date methods. 187 // 188 if (Math.abs(parseInt(x)) < 10){ 189 x = "0"+ Math.abs(x); 190 } 191 return x; 192 }, 193 194 parseDateStringISO: function(s) { 195 try { 196 var d = django.datetime.parseDateString(s); 197 return d.getFullYear() + '-' + (django.datetime.fmt00(d.getMonth() + 1)) + '-' + django.datetime.fmt00(d.getDate()) 198 } 199 catch (e) { return s; } 200 }, 201 202 magicDate: function(input) { 203 var messagespan = input.id + 'Msg'; 204 try { 205 var d = django.datetime.parseDateString(input.value); 206 input.value = d.getFullYear() + '-' + (django.datetime.fmt00(d.getMonth() + 1)) + '-' + 207 django.datetime.fmt00(d.getDate()); 208 input.className = ''; 209 // Human readable date 210 if (document.getElementById(messagespan)) { 211 document.getElementById(messagespan).firstChild.nodeValue = d.toDateString(); 212 document.getElementById(messagespan).className = 'normal'; 213 } 214 } 215 catch (e) { 216 input.className = 'error'; 217 var message = e.message; 218 // Fix for IE6 bug 219 if (message.indexOf('is null or not an object') > -1) { 220 message = 'Invalid date string'; 221 } 222 if (document.getElementById(messagespan)) { 223 document.getElementById(messagespan).firstChild.nodeValue = message; 224 document.getElementById(messagespan).className = 'error'; 225 } 226 } 227 }, 228 229 timeParsePatterns: [ 230 // 9 231 { re: /^\d{1,2}$/i, 232 handler: function(bits) { 233 if (bits[0].length == 1) { 234 return '0' + bits[0] + ':00'; 235 } else { 236 return bits[0] + ':00'; 237 } 238 } 239 }, 240 // 13:00 241 { re: /^\d{2}[:.]\d{2}$/i, 242 handler: function(bits) { 243 return bits[0].replace('.', ':'); 244 } 245 }, 246 // 9:00 247 { re: /^\d[:.]\d{2}$/i, 248 handler: function(bits) { 249 return '0' + bits[0].replace('.', ':'); 250 } 251 }, 252 // 3 am / 3 a.m. / 3am 253 { re: /^(\d+)\s*([ap])(?:.?m.?)?$/i, 254 handler: function(bits) { 255 var hour = parseInt(bits[1]); 256 if (hour == 12) { 257 hour = 0; 258 } 259 if (bits[2].toLowerCase() == 'p') { 260 if (hour == 12) { 261 hour = 0; 262 } 263 return (hour + 12) + ':00'; 264 } else { 265 if (hour < 10) { 266 return '0' + hour + ':00'; 267 } else { 268 return hour + ':00'; 269 } 270 } 271 } 272 }, 273 // 3.30 am / 3:15 a.m. / 3.00am 274 { re: /^(\d+)[.:](\d{2})\s*([ap]).?m.?$/i, 275 handler: function(bits) { 276 var hour = parseInt(bits[1]); 277 var mins = parseInt(bits[2]); 278 if (mins < 10) { 279 mins = '0' + mins; 280 } 281 if (hour == 12) { 282 hour = 0; 283 } 284 if (bits[3].toLowerCase() == 'p') { 285 if (hour == 12) { 286 hour = 0; 287 } 288 return (hour + 12) + ':' + mins; 289 } else { 290 if (hour < 10) { 291 return '0' + hour + ':' + mins; 292 } else { 293 return hour + ':' + mins; 294 } 295 } 296 } 297 }, 298 // noon 299 { re: /^no/i, 300 handler: function(bits) { 301 return '12:00'; 302 } 303 }, 304 // midnight 305 { re: /^mid/i, 306 handler: function(bits) { 307 return '00:00'; 308 } 309 } 310 ], 311 312 parseTimeString: function(s) { 313 for (var i = 0; i < timeParsePatterns.length; i++) { 314 var re = timeParsePatterns[i].re; 315 var handler = timeParsePatterns[i].handler; 316 var bits = re.exec(s); 317 if (bits) { 318 return handler(bits); 319 } 320 } 321 return s; 322 } 323 }; 324 No newline at end of file -
media/js/django/util.js
1 dojo.provide('django.util'); 2 3 django.util = { 4 URLify: function(s, num_chars) { 5 // changes, e.g., "Petty theft" to "petty_theft" 6 // remove all these words from the string before urlifying 7 removelist = ["a", "an", "as", "at", "before", "but", "by", "for", "from", 8 "is", "in", "into", "like", "of", "off", "on", "onto", "per", 9 "since", "than", "the", "this", "that", "to", "up", "via", 10 "with"]; 11 r = new RegExp('\\b(' + removelist.join('|') + ')\\b', 'gi'); 12 s = s.replace(r, ''); 13 s = s.replace(/[^-A-Z0-9\s]/gi, ''); // remove unneeded chars 14 s = s.replace(/^\s+|\s+$/g, ''); // trim leading/trailing spaces 15 s = s.replace(/\s+/g, '-'); // convert spaces to hyphens 16 s = s.toLowerCase(); // convert to lowercase 17 return s.substring(0, num_chars);// trim to first num_chars chars 18 }, 19 20 findForm: function(node) { 21 // returns the node of the form containing the given node 22 if (node.tagName.toLowerCase() != 'form') { 23 return django.util.findForm(node.parentNode); 24 } 25 return node; 26 }, 27 28 quickElement: function() { 29 var obj = document.createElement(arguments[0]); 30 if (arguments[2] != '' && arguments[2] != null) { 31 var textNode = document.createTextNode(arguments[2]); 32 obj.appendChild(textNode); 33 } 34 var len = arguments.length; 35 for (var i = 3; i < len; i += 2) { 36 obj.setAttribute(arguments[i], arguments[i+1]); 37 } 38 arguments[1].appendChild(obj); 39 return obj; 40 }, 41 42 removeChildren: function(a) { // "a" is reference to an object 43 while (a.hasChildNodes()) a.removeChild(a.lastChild); 44 }, 45 46 findPosX: function(obj) { 47 var curleft = 0; 48 if (obj.offsetParent) { 49 while (obj.offsetParent) { 50 curleft += obj.offsetLeft; 51 obj = obj.offsetParent; 52 } 53 } else if (obj.x) { 54 curleft += obj.x; 55 } 56 return curleft; 57 }, 58 59 findPosY: function(obj) { 60 var curtop = 0; 61 if (obj.offsetParent) { 62 while (obj.offsetParent) { 63 curtop += obj.offsetTop; 64 obj = obj.offsetParent; 65 } 66 } else if (obj.y) { 67 curtop += obj.y; 68 } 69 return curtop; 70 }, 71 72 addEvent: function(obj, type, fn) { 73 /* John Resig's addEvent, with modifications by Peter-Paul Koch. 74 * See http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html 75 */ 76 if (obj.addEventListener) { 77 obj.addEventListener( type, fn, false ); 78 } 79 else if (obj.attachEvent) { 80 obj["e"+type+fn] = fn; 81 obj[type+fn] = function() { obj["e"+type+fn]( window.event ); } 82 obj.attachEvent("on"+type, obj[type+fn]); 83 } 84 }, 85 86 removeEvent: function(obj, evType, fn) { 87 if (obj.removeEventListener) { 88 obj.removeEventListener(evType, fn, false); 89 return true; 90 } else if (obj.detachEvent) { 91 obj.detachEvent("on" + evType, fn); 92 } else { 93 return false; 94 } 95 } 96 }; 97 No newline at end of file -
media/js/django/admin/__package__.js
1 dojo.hostenv.conditionalLoadModule({ 2 common: [ 3 "django.admin", 4 "django.admin.CollapsedFieldsets", 5 "django.admin.AutoPopulate", 6 "django.admin.RelatedLookups" 7 ] 8 }); 9 dojo.hostenv.moduleLoaded("django.admin.*"); -
media/js/django/admin/CollapsedFieldsets.js
1 dojo.provide('django.admin.CollapsedFieldsets'); 2 dojo.require('dojo.event'); 3 dojo.require('django.util'); 4 5 // Finds all fieldsets with class="collapse", collapses them, and gives each 6 // one a "Show" link that uncollapses it. The "Show" link becomes a "Hide" 7 // link when the fieldset is visible. 8 9 10 django.admin.CollapsedFieldsets = { 11 collapse_re: /\bcollapse\b/, // Class of fieldsets that should be dealt with. 12 collapsed_re: /\bcollapsed\b/, // Class that fieldsets get when they're hidden. 13 collapsed_class: 'collapsed', 14 init: function() { 15 var fieldsets = document.getElementsByTagName('fieldset'); 16 var collapsed_seen = false; 17 for (var i=0; i<fieldsets.length; i++) { 18 // Collapse this fieldset if it has the correct class, and if it 19 // doesn't have any errors. (Collapsing shouldn't apply in the case 20 // of error messages.) 21 var fs = fieldsets[i]; 22 if (fs.className.match(django.admin.CollapsedFieldsets.collapse_re) && !django.admin.CollapsedFieldsets.fieldset_has_errors(fs)) { 23 collapsed_seen = true; 24 // Give it an additional class, used by CSS to hide it. 25 fs.className += ' ' + django.admin.CollapsedFieldsets.collapsed_class; 26 // (<a id="fieldsetcollapser3" class="collapse-toggle" href="#">Show</a>) 27 var collapse_link = document.createElement('a'); 28 collapse_link.className = 'collapse-toggle'; 29 collapse_link.id = 'fieldsetcollapser' + i; 30 collapse_link.onclick = new Function('django.admin.CollapsedFieldsets.show('+i+'); return false;'); 31 collapse_link.href = '#'; 32 collapse_link.innerHTML = 'Show'; 33 var h2 = fs.getElementsByTagName('h2')[0]; 34 h2.appendChild(document.createTextNode(' (')); 35 h2.appendChild(collapse_link); 36 h2.appendChild(document.createTextNode(')')); 37 } 38 if (collapsed_seen) { 39 // Expand all collapsed fieldsets when form is submitted. 40 dojo.event.connect(django.util.findForm(document.getElementsByTagName('fieldset')[0]), 'onsubmit', function() { django.admin.CollapsedFieldsets.uncollapse_all(); }); 41 } 42 } 43 }, 44 45 fieldset_has_errors: function(fs) { 46 // Returns true if any fields in the fieldset have validation errors. 47 var divs = fs.getElementsByTagName('div'); 48 for (var i=0; i<divs.length; i++) { 49 if (divs[i].className.match(/\berror\b/)) { 50 return true; 51 } 52 } 53 return false; 54 }, 55 56 show: function(fieldset_index) { 57 var fs = document.getElementsByTagName('fieldset')[fieldset_index]; 58 // Remove the class name that causes the "display: none". 59 fs.className = fs.className.replace(django.admin.CollapsedFieldsets.collapsed_re, ''); 60 // Toggle the "Show" link to a "Hide" link 61 var collapse_link = document.getElementById('fieldsetcollapser' + fieldset_index); 62 collapse_link.onclick = new Function('django.admin.CollapsedFieldsets.hide('+fieldset_index+'); return false;'); 63 collapse_link.innerHTML = 'Hide'; 64 }, 65 66 hide: function(fieldset_index) { 67 var fs = document.getElementsByTagName('fieldset')[fieldset_index]; 68 // Add the class name that causes the "display: none". 69 fs.className += ' ' + django.admin.CollapsedFieldsets.collapsed_class; 70 // Toggle the "Hide" link to a "Show" link 71 var collapse_link = document.getElementById('fieldsetcollapser' + fieldset_index); 72 collapse_link.onclick = new Function('django.admin.CollapsedFieldsets.show('+fieldset_index+'); return false;'); 73 collapse_link.innerHTML = 'Show'; 74 }, 75 76 uncollapse_all: function() { 77 var fieldsets = document.getElementsByTagName('fieldset'); 78 for (var i=0; i<fieldsets.length; i++) { 79 if (fieldsets[i].className.match(django.admin.CollapsedFieldsets.collapsed_re)) { 80 django.admin.CollapsedFieldsets.show(i); 81 } 82 } 83 } 84 }; 85 86 87 dojo.addOnLoad(django.admin.CollapsedFieldsets.init); -
media/js/django/admin/RelatedLookups.js
1 dojo.provide('django.admin.RelatedLookups'); 2 dojo.require('dojo.event.*'); 3 4 django.admin.RelatedLookups = { 5 relatedPopups: {}, 6 addPopups: {}, 7 8 createRelatedHandler: function(elem) { 9 return function(evt) { 10 var href = django.admin.RelatedLookups.relatedPopups[elem.id]; 11 var name = elem.id.replace(/^lookup_/, '').replace(/\./g, '___'); 12 win = window.open(href + '?_popup=1', name, 'height=500,width=800,resizable=yes,scrollbars=yes'); 13 win.focus(); 14 } 15 }, 16 17 createAddHandler: function(elem) { 18 return function(evt) { 19 var href = django.admin.RelatedLookups.addPopups[elem.id]; 20 var name = elem.id.replace(/^add_/, '').replace(/\./g, '___'); 21 win = window.open(href + '?_popup=1', name, 'height=500,width=800,resizable=yes,scrollbars=yes'); 22 win.focus(); 23 } 24 }, 25 26 init: function() { 27 var links = document.getElementsByTagName('a'); 28 var num_links = links.length; 29 for(var i=0; i<num_links; i++) { 30 if(links[i].className.indexOf('related-lookup') != -1) { 31 django.admin.RelatedLookups.relatedPopups[links[i].id] = links[i].href; 32 links[i].href = 'javascript:void(0)'; //This is easier than trying to make preventDefault work in Safari. 33 dojo.event.connect(links[i], 'onclick', django.admin.RelatedLookups.createRelatedHandler(links[i])); 34 } else if(links[i].className.indexOf('add-another') != -1) { 35 django.admin.RelatedLookups.addPopups[links[i].id] = links[i].href; 36 links[i].href = 'javascript:void(0)'; 37 dojo.event.connect(links[i], 'onclick', django.admin.RelatedLookups.createAddHandler(links[i])); 38 } 39 } 40 }, 41 42 dismissRelatedLookupPopup: function(win, chosenId) { 43 var elem = document.getElementById(win.name); 44 if (elem.className.indexOf('vRawIdAdminField') != -1 && elem.value) { 45 elem.value += ',' + chosenId; 46 } else { 47 document.getElementById(win.name).value = chosenId; 48 } 49 win.close(); 50 }, 51 52 dismissAddAnotherPopup: function(win, newId, newRepr) { 53 var name = win.name.replace(/___/g, '.'); 54 var elem = document.getElementById(name); 55 if (elem) { 56 if (elem.nodeName == 'SELECT') { 57 var o = new Option(newRepr, newId); 58 elem.options[elem.options.length] = o; 59 elem.selectedIndex = elem.length - 1; 60 } else if (elem.nodeName == 'INPUT') { 61 elem.value = newId; 62 } 63 } else { 64 var toId = name + "_to"; 65 elem = document.getElementById(toId); 66 var o = new Option(newRepr, newId); 67 django.widget.SelectBox.add_to_cache(toId, o); 68 django.widget.SelectBox.redisplay(toId); 69 } 70 win.close(); 71 } 72 } 73 No newline at end of file -
media/js/django/admin/AutoPopulate.js
1 dojo.provide('django.admin.AutoPopulate'); 2 dojo.require('dojo.event.*'); 3 4 django.admin.AutoPopulate = { 5 createHandler: function(elem) { 6 return function(evt) { 7 var destFields = django.admin.AutoPopulate.sourceIndexedArray[elem.id]; 8 var num_dests = destFields.length; 9 for(var i=0; i<num_dests; i++) { 10 var destField = document.getElementById(destFields[i]); 11 if(!destField.className.indexOf('changed') != 1) { 12 var sources = django.admin.AutoPopulate.destIndexedArray[destFields[i]]; 13 var num_sources = sources.length; 14 var newValues = ''; 15 for(var j=0; j<num_sources; j++) { 16 newValues += document.getElementById(sources[j]).value + " "; 17 } 18 destField.value = django.util.URLify(newValues, 250); 19 } 20 } 21 } 22 }, 23 24 init: function(auto_populate_array) { 25 django.admin.AutoPopulate.sourceIndexedArray = {}; 26 django.admin.AutoPopulate.destIndexedArray = auto_populate_array; 27 var num_dests = django.admin.AutoPopulate.destIndexedArray.length; 28 for(var destField in django.admin.AutoPopulate.destIndexedArray) { 29 dojo.event.connect(document.getElementById(destField), "onchange", function(evt) { 30 document.getElementById(destField).className += " changed"; 31 }); 32 var sources = django.admin.AutoPopulate.destIndexedArray[destField]; 33 var num_sources = sources.length; 34 for(var i=0; i<num_sources; i++) { 35 var sourceField = document.getElementById(sources[i]); 36 if(typeof(django.admin.AutoPopulate.sourceIndexedArray[sources[i]] == 'undefined')) { 37 django.admin.AutoPopulate.sourceIndexedArray[sources[i]] = [destField]; 38 } else { 39 django.admin.AutoPopulate.sourceIndexedArray[sources[i]].push(destField); 40 } 41 var handler = django.admin.AutoPopulate.createHandler(document.getElementById(sources[i])); 42 dojo.event.connect(sourceField, "onkeyup", handler); 43 } 44 } 45 } 46 } 47 No newline at end of file -
media/js/django/datetime/__package__.js
1 dojo.hostenv.conditionalLoadModule({ 2 common: [ 3 "django.datetime", 4 "django.datetime.calendar" 5 ] 6 }); 7 dojo.hostenv.moduleLoaded("django.calendar.*"); -
media/js/django/datetime/calendar.js
1 dojo.provide('django.datetime.calendar'); 2 dojo.require('django.datetime'); 3 dojo.require('django.util'); 4 5 django.datetime.calendar = { 6 /* 7 calendar.js - Calendar functions by Adrian Holovaty 8 */ 9 10 // CalendarNamespace -- Provides a collection of HTML calendar-related helper functions 11 CalendarNamespace: { 12 isLeapYear: function(year) { 13 return (((year % 4)==0) && ((year % 100)!=0) || ((year % 400)==0)); 14 }, 15 16 getDaysInMonth: function(month, year) { 17 var days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; 18 if (month == 1 && django.datetime.calendar.CalendarNamespace.isLeapYear(year)) { return 29; } 19 else { return days[month]; } 20 }, 21 22 draw: function(month, year, div_id, callback) { // month = 1-12, year = 1-9999 23 month = parseInt(month); 24 year = parseInt(year); 25 var calDiv = document.getElementById(div_id); 26 django.util.removeChildren(calDiv); 27 var calTable = document.createElement('table'); 28 django.util.quickElement('caption', calTable, django.datetime.monthNames[month-1] + ' ' + year); 29 var tableBody = django.util.quickElement('tbody', calTable); 30 31 // Draw days-of-week header 32 var tableRow = django.util.quickElement('tr', tableBody); 33 for (var i = 0; i < 7; i++) { 34 django.util.quickElement('th', tableRow, django.datetime.weekdayInitials[i]); 35 } 36 37 var startingPos = new Date(year, month, 1).getDay(); 38 var days = django.datetime.calendar.CalendarNamespace.getDaysInMonth(month - 1, year); 39 40 // Draw blanks before first of month 41 tableRow = django.util.quickElement('tr', tableBody); 42 for (var i = 0; i < startingPos; i++) { 43 var _cell = django.util.quickElement('td', tableRow, ' '); 44 _cell.style.backgroundColor = '#f3f3f3'; 45 } 46 47 // Draw days of month 48 var currentDay = 1; 49 for (var i = startingPos; currentDay <= days; i++) { 50 if (i%7 == 0 && currentDay != 1) { 51 tableRow = django.util.quickElement('tr', tableBody); 52 } 53 var cell = django.util.quickElement('td', tableRow, ''); 54 django.util.quickElement('a', cell, currentDay, 'href', 'javascript:void(' + callback + '('+year+','+month+','+currentDay+'));'); 55 currentDay++; 56 } 57 58 // Draw blanks after end of month (optional, but makes for valid code) 59 while (tableRow.childNodes.length < 7) { 60 var _cell = django.util.quickElement('td', tableRow, ' '); 61 _cell.style.backgroundColor = '#f3f3f3'; 62 } 63 64 calDiv.appendChild(calTable); 65 } 66 }, 67 68 // Calendar -- A calendar instance 69 Calendar: function(div_id, callback) { 70 // div_id (string) is the ID of the element in which the calendar will 71 // be displayed 72 // callback (string) is the name of a JavaScript function that will be 73 // called with the parameters (year, month, day) when a day in the 74 // calendar is clicked 75 this.div_id = div_id; 76 this.callback = callback; 77 this.today = new Date(); 78 this.currentMonth = this.today.getMonth() + 1; 79 this.currentYear = this.today.getFullYear(); 80 } 81 82 }; 83 84 django.datetime.calendar.Calendar.prototype = { 85 drawCurrent: function() { 86 django.datetime.calendar.CalendarNamespace.draw(this.currentMonth, this.currentYear, this.div_id, this.callback); 87 }, 88 drawDate: function(month, year) { 89 this.currentMonth = month; 90 this.currentYear = year; 91 this.drawCurrent(); 92 }, 93 drawPreviousMonth: function() { 94 if (this.currentMonth == 1) { 95 this.currentMonth = 12; 96 this.currentYear--; 97 } 98 else { 99 this.currentMonth--; 100 } 101 this.drawCurrent(); 102 }, 103 drawNextMonth: function() { 104 if (this.currentMonth == 12) { 105 this.currentMonth = 1; 106 this.currentYear++; 107 } 108 else { 109 this.currentMonth++; 110 } 111 this.drawCurrent(); 112 }, 113 drawPreviousYear: function() { 114 this.currentYear--; 115 this.drawCurrent(); 116 }, 117 drawNextYear: function() { 118 this.currentYear++; 119 this.drawCurrent(); 120 } 121 } -
media/js/SelectBox.js
1 var SelectBox = {2 cache: new Object(),3 init: function(id) {4 var box = document.getElementById(id);5 var node;6 SelectBox.cache[id] = new Array();7 var cache = SelectBox.cache[id];8 for (var i = 0; (node = box.options[i]); i++) {9 cache.push({ value: node.value, text: node.text, displayed: 1 });10 }11 },12 redisplay: function(id) {13 // Repopulate HTML select box from cache14 var box = document.getElementById(id);15 box.options.length = 0; // clear all options16 for (var i = 0, j = SelectBox.cache[id].length; i < j; i++) {17 var node = SelectBox.cache[id][i];18 if (node.displayed) {19 box.options[box.options.length] = new Option(node.text, node.value, false, false);20 }21 }22 },23 filter: function(id, text) {24 // Redisplay the HTML select box, displaying only the choices containing ALL25 // the words in text. (It's an AND search.)26 var tokens = text.toLowerCase().split(/\s+/);27 var node, token;28 for (var i = 0; (node = SelectBox.cache[id][i]); i++) {29 node.displayed = 1;30 for (var j = 0; (token = tokens[j]); j++) {31 if (node.text.toLowerCase().indexOf(token) == -1) {32 node.displayed = 0;33 }34 }35 }36 SelectBox.redisplay(id);37 },38 delete_from_cache: function(id, value) {39 var node, delete_index = null;40 for (var i = 0; (node = SelectBox.cache[id][i]); i++) {41 if (node.value == value) {42 delete_index = i;43 break;44 }45 }46 var j = SelectBox.cache[id].length - 1;47 for (var i = delete_index; i < j; i++) {48 SelectBox.cache[id][i] = SelectBox.cache[id][i+1];49 }50 SelectBox.cache[id].length--;51 },52 add_to_cache: function(id, option) {53 SelectBox.cache[id].push({ value: option.value, text: option.text, displayed: 1 });54 },55 cache_contains: function(id, value) {56 // Check if an item is contained in the cache57 var node;58 for (var i = 0; (node = SelectBox.cache[id][i]); i++) {59 if (node.value == value) {60 return true;61 }62 }63 return false;64 },65 move: function(from, to) {66 var from_box = document.getElementById(from);67 var to_box = document.getElementById(to);68 var option;69 for (var i = 0; (option = from_box.options[i]); i++) {70 if (option.selected && SelectBox.cache_contains(from, option.value)) {71 SelectBox.add_to_cache(to, { value: option.value, text: option.text, displayed: 1 });72 SelectBox.delete_from_cache(from, option.value);73 }74 }75 SelectBox.redisplay(from);76 SelectBox.redisplay(to);77 },78 move_all: function(from, to) {79 var from_box = document.getElementById(from);80 var to_box = document.getElementById(to);81 var option;82 for (var i = 0; (option = from_box.options[i]); i++) {83 SelectBox.add_to_cache(to, { value: option.value, text: option.text, displayed: 1 });84 SelectBox.delete_from_cache(from, option.value);85 }86 SelectBox.redisplay(from);87 SelectBox.redisplay(to);88 },89 sort: function(id) {90 SelectBox.cache[id].sort( function(a, b) {91 a = a.text.toLowerCase();92 b = b.text.toLowerCase();93 try {94 if (a > b) return 1;95 if (a < b) return -1;96 }97 catch (e) {98 // silently fail on IE 'unknown' exception99 }100 return 0;101 } );102 },103 select_all: function(id) {104 var box = document.getElementById(id);105 for (var i = 0; i < box.options.length; i++) {106 box.options[i].selected = 'selected';107 }108 }109 } -
media/js/core.js
1 // Core javascript helper functions2 3 // Cross-browser event handlers.4 function addEvent(obj, evType, fn) {5 if (obj.addEventListener) {6 obj.addEventListener(evType, fn, false);7 return true;8 } else if (obj.attachEvent) {9 var r = obj.attachEvent("on" + evType, fn);10 return r;11 } else {12 return false;13 }14 }15 16 function removeEvent(obj, evType, fn) {17 if (obj.removeEventListener) {18 obj.removeEventListener(evType, fn, false);19 return true;20 } else if (obj.detachEvent) {21 obj.detachEvent("on" + evType, fn);22 } else {23 return false;24 }25 }26 27 // quickElement(tagType, parentReference, textInChildNode, [, attribute, attributeValue ...]);28 function quickElement() {29 var obj = document.createElement(arguments[0]);30 if (arguments[2] != '' && arguments[2] != null) {31 var textNode = document.createTextNode(arguments[2]);32 obj.appendChild(textNode);33 }34 var len = arguments.length;35 for (var i = 3; i < len; i += 2) {36 obj.setAttribute(arguments[i], arguments[i+1]);37 }38 arguments[1].appendChild(obj);39 return obj;40 }41 42 // ----------------------------------------------------------------------------43 // Cross-browser xmlhttp object44 // from http://jibbering.com/2002/4/httprequest.html45 // ----------------------------------------------------------------------------46 var xmlhttp;47 /*@cc_on @*/48 /*@if (@_jscript_version >= 5)49 try {50 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");51 } catch (e) {52 try {53 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");54 } catch (E) {55 xmlhttp = false;56 }57 }58 @else59 xmlhttp = false;60 @end @*/61 if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {62 xmlhttp = new XMLHttpRequest();63 }64 65 // ----------------------------------------------------------------------------66 // Find-position functions by PPK67 // See http://www.quirksmode.org/js/findpos.html68 // ----------------------------------------------------------------------------69 function findPosX(obj) {70 var curleft = 0;71 if (obj.offsetParent) {72 while (obj.offsetParent) {73 curleft += obj.offsetLeft;74 obj = obj.offsetParent;75 }76 } else if (obj.x) {77 curleft += obj.x;78 }79 return curleft;80 }81 82 function findPosY(obj) {83 var curtop = 0;84 if (obj.offsetParent) {85 while (obj.offsetParent) {86 curtop += obj.offsetTop;87 obj = obj.offsetParent;88 }89 } else if (obj.y) {90 curtop += obj.y;91 }92 return curtop;93 }94 95 //-----------------------------------------------------------------------------96 // Date object extensions97 // ----------------------------------------------------------------------------98 Date.prototype.getCorrectYear = function() {99 // Date.getYear() is unreliable --100 // see http://www.quirksmode.org/js/introdate.html#year101 var y = this.getYear() % 100;102 return (y < 38) ? y + 2000 : y + 1900;103 }104 105 Date.prototype.getTwoDigitMonth = function() {106 return (this.getMonth() < 9) ? '0' + (this.getMonth()+1) : (this.getMonth()+1);107 }108 109 Date.prototype.getTwoDigitDate = function() {110 return (this.getDate() < 10) ? '0' + this.getDate() : this.getDate();111 }112 113 Date.prototype.getTwoDigitHour = function() {114 return (this.getHours() < 10) ? '0' + this.getHours() : this.getHours();115 }116 117 Date.prototype.getTwoDigitMinute = function() {118 return (this.getMinutes() < 10) ? '0' + this.getMinutes() : this.getMinutes();119 }120 121 Date.prototype.getISODate = function() {122 return this.getCorrectYear() + '-' + this.getTwoDigitMonth() + '-' + this.getTwoDigitDate();123 }124 125 Date.prototype.getHourMinute = function() {126 return this.getTwoDigitHour() + ':' + this.getTwoDigitMinute();127 }128 129 // ----------------------------------------------------------------------------130 // String object extensions131 // ----------------------------------------------------------------------------132 String.prototype.pad_left = function(pad_length, pad_string) {133 var new_string = this;134 for (var i = 0; new_string.length < pad_length; i++) {135 new_string = pad_string + new_string;136 }137 return new_string;138 }139 No newline at end of file -
media/js/dateparse.js
1 /* 'Magic' date parsing, by Simon Willison (6th October 2003)2 http://simon.incutio.com/archive/2003/10/06/betterDateInput3 Adapted for 6newslawrence.com, 28th January 20044 */5 6 /* Finds the index of the first occurence of item in the array, or -1 if not found */7 if (typeof Array.prototype.indexOf == 'undefined') {8 Array.prototype.indexOf = function(item) {9 var len = this.length;10 for (var i = 0; i < len; i++) {11 if (this[i] == item) {12 return i;13 }14 }15 return -1;16 };17 }18 /* Returns an array of items judged 'true' by the passed in test function */19 if (typeof Array.prototype.filter == 'undefined') {20 Array.prototype.filter = function(test) {21 var matches = [];22 var len = this.length;23 for (var i = 0; i < len; i++) {24 if (test(this[i])) {25 matches[matches.length] = this[i];26 }27 }28 return matches;29 };30 }31 32 var monthNames = gettext("January February March April May June July August September October November December").split(" ");33 var weekdayNames = gettext("Sunday Monday Tuesday Wednesday Thursday Friday Saturday").split(" ");34 35 /* Takes a string, returns the index of the month matching that string, throws36 an error if 0 or more than 1 matches37 */38 function parseMonth(month) {39 var matches = monthNames.filter(function(item) {40 return new RegExp("^" + month, "i").test(item);41 });42 if (matches.length == 0) {43 throw new Error("Invalid month string");44 }45 if (matches.length > 1) {46 throw new Error("Ambiguous month");47 }48 return monthNames.indexOf(matches[0]);49 }50 /* Same as parseMonth but for days of the week */51 function parseWeekday(weekday) {52 var matches = weekdayNames.filter(function(item) {53 return new RegExp("^" + weekday, "i").test(item);54 });55 if (matches.length == 0) {56 throw new Error("Invalid day string");57 }58 if (matches.length > 1) {59 throw new Error("Ambiguous weekday");60 }61 return weekdayNames.indexOf(matches[0]);62 }63 64 /* Array of objects, each has 're', a regular expression and 'handler', a65 function for creating a date from something that matches the regular66 expression. Handlers may throw errors if string is unparseable.67 */68 var dateParsePatterns = [69 // Today70 { re: /^tod/i,71 handler: function() {72 return new Date();73 }74 },75 // Tomorrow76 { re: /^tom/i,77 handler: function() {78 var d = new Date();79 d.setDate(d.getDate() + 1);80 return d;81 }82 },83 // Yesterday84 { re: /^yes/i,85 handler: function() {86 var d = new Date();87 d.setDate(d.getDate() - 1);88 return d;89 }90 },91 // 4th92 { re: /^(\d{1,2})(st|nd|rd|th)?$/i,93 handler: function(bits) {94 var d = new Date();95 d.setDate(parseInt(bits[1], 10));96 return d;97 }98 },99 // 4th Jan100 { re: /^(\d{1,2})(?:st|nd|rd|th)? (\w+)$/i,101 handler: function(bits) {102 var d = new Date();103 d.setDate(parseInt(bits[1], 10));104 d.setMonth(parseMonth(bits[2]));105 return d;106 }107 },108 // 4th Jan 2003109 { re: /^(\d{1,2})(?:st|nd|rd|th)? (\w+),? (\d{4})$/i,110 handler: function(bits) {111 var d = new Date();112 d.setDate(parseInt(bits[1], 10));113 d.setMonth(parseMonth(bits[2]));114 d.setYear(bits[3]);115 return d;116 }117 },118 // Jan 4th119 { re: /^(\w+) (\d{1,2})(?:st|nd|rd|th)?$/i,120 handler: function(bits) {121 var d = new Date();122 d.setDate(parseInt(bits[2], 10));123 d.setMonth(parseMonth(bits[1]));124 return d;125 }126 },127 // Jan 4th 2003128 { re: /^(\w+) (\d{1,2})(?:st|nd|rd|th)?,? (\d{4})$/i,129 handler: function(bits) {130 var d = new Date();131 d.setDate(parseInt(bits[2], 10));132 d.setMonth(parseMonth(bits[1]));133 d.setYear(bits[3]);134 return d;135 }136 },137 // next Tuesday - this is suspect due to weird meaning of "next"138 { re: /^next (\w+)$/i,139 handler: function(bits) {140 var d = new Date();141 var day = d.getDay();142 var newDay = parseWeekday(bits[1]);143 var addDays = newDay - day;144 if (newDay <= day) {145 addDays += 7;146 }147 d.setDate(d.getDate() + addDays);148 return d;149 }150 },151 // last Tuesday152 { re: /^last (\w+)$/i,153 handler: function(bits) {154 throw new Error("Not yet implemented");155 }156 },157 // mm/dd/yyyy (American style)158 { re: /(\d{1,2})\/(\d{1,2})\/(\d{4})/,159 handler: function(bits) {160 var d = new Date();161 d.setYear(bits[3]);162 d.setDate(parseInt(bits[2], 10));163 d.setMonth(parseInt(bits[1], 10) - 1); // Because months indexed from 0164 return d;165 }166 },167 // yyyy-mm-dd (ISO style)168 { re: /(\d{4})-(\d{1,2})-(\d{1,2})/,169 handler: function(bits) {170 var d = new Date();171 d.setYear(parseInt(bits[1]));172 d.setDate(parseInt(bits[3], 10));173 d.setMonth(parseInt(bits[2], 10) - 1);174 return d;175 }176 },177 ];178 179 function parseDateString(s) {180 for (var i = 0; i < dateParsePatterns.length; i++) {181 var re = dateParsePatterns[i].re;182 var handler = dateParsePatterns[i].handler;183 var bits = re.exec(s);184 if (bits) {185 return handler(bits);186 }187 }188 throw new Error("Invalid date string");189 }190 191 function fmt00(x) {192 // fmt00: Tags leading zero onto numbers 0 - 9.193 // Particularly useful for displaying results from Date methods.194 //195 if (Math.abs(parseInt(x)) < 10){196 x = "0"+ Math.abs(x);197 }198 return x;199 }200 201 function parseDateStringISO(s) {202 try {203 var d = parseDateString(s);204 return d.getFullYear() + '-' + (fmt00(d.getMonth() + 1)) + '-' + fmt00(d.getDate())205 }206 catch (e) { return s; }207 }208 function magicDate(input) {209 var messagespan = input.id + 'Msg';210 try {211 var d = parseDateString(input.value);212 input.value = d.getFullYear() + '-' + (fmt00(d.getMonth() + 1)) + '-' +213 fmt00(d.getDate());214 input.className = '';215 // Human readable date216 if (document.getElementById(messagespan)) {217 document.getElementById(messagespan).firstChild.nodeValue = d.toDateString();218 document.getElementById(messagespan).className = 'normal';219 }220 }221 catch (e) {222 input.className = 'error';223 var message = e.message;224 // Fix for IE6 bug225 if (message.indexOf('is null or not an object') > -1) {226 message = 'Invalid date string';227 }228 if (document.getElementById(messagespan)) {229 document.getElementById(messagespan).firstChild.nodeValue = message;230 document.getElementById(messagespan).className = 'error';231 }232 }233 } -
media/js/getElementsBySelector.js
1 /* document.getElementsBySelector(selector)2 - returns an array of element objects from the current document3 matching the CSS selector. Selectors can contain element names,4 class names and ids and can be nested. For example:5 6 elements = document.getElementsBySelect('div#main p a.external')7 8 Will return an array of all 'a' elements with 'external' in their9 class attribute that are contained inside 'p' elements that are10 contained inside the 'div' element which has id="main"11 12 New in version 0.4: Support for CSS2 and CSS3 attribute selectors:13 See http://www.w3.org/TR/css3-selectors/#attribute-selectors14 15 Version 0.4 - Simon Willison, March 25th 200316 -- Works in Phoenix 0.5, Mozilla 1.3, Opera 7, Internet Explorer 6, Internet Explorer 5 on Windows17 -- Opera 7 fails18 */19 20 function getAllChildren(e) {21 // Returns all children of element. Workaround required for IE5/Windows. Ugh.22 return e.all ? e.all : e.getElementsByTagName('*');23 }24 25 document.getElementsBySelector = function(selector) {26 // Attempt to fail gracefully in lesser browsers27 if (!document.getElementsByTagName) {28 return new Array();29 }30 // Split selector in to tokens31 var tokens = selector.split(' ');32 var currentContext = new Array(document);33 for (var i = 0; i < tokens.length; i++) {34 token = tokens[i].replace(/^\s+/,'').replace(/\s+$/,'');;35 if (token.indexOf('#') > -1) {36 // Token is an ID selector37 var bits = token.split('#');38 var tagName = bits[0];39 var id = bits[1];40 var element = document.getElementById(id);41 if (tagName && element.nodeName.toLowerCase() != tagName) {42 // tag with that ID not found, return false43 return new Array();44 }45 // Set currentContext to contain just this element46 currentContext = new Array(element);47 continue; // Skip to next token48 }49 if (token.indexOf('.') > -1) {50 // Token contains a class selector51 var bits = token.split('.');52 var tagName = bits[0];53 var className = bits[1];54 if (!tagName) {55 tagName = '*';56 }57 // Get elements matching tag, filter them for class selector58 var found = new Array;59 var foundCount = 0;60 for (var h = 0; h < currentContext.length; h++) {61 var elements;62 if (tagName == '*') {63 elements = getAllChildren(currentContext[h]);64 } else {65 try {66 elements = currentContext[h].getElementsByTagName(tagName);67 }68 catch(e) {69 elements = [];70 }71 }72 for (var j = 0; j < elements.length; j++) {73 found[foundCount++] = elements[j];74 }75 }76 currentContext = new Array;77 var currentContextIndex = 0;78 for (var k = 0; k < found.length; k++) {79 if (found[k].className && found[k].className.match(new RegExp('\\b'+className+'\\b'))) {80 currentContext[currentContextIndex++] = found[k];81 }82 }83 continue; // Skip to next token84 }85 // Code to deal with attribute selectors86 if (token.match(/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/)) {87 var tagName = RegExp.$1;88 var attrName = RegExp.$2;89 var attrOperator = RegExp.$3;90 var attrValue = RegExp.$4;91 if (!tagName) {92 tagName = '*';93 }94 // Grab all of the tagName elements within current context95 var found = new Array;96 var foundCount = 0;97 for (var h = 0; h < currentContext.length; h++) {98 var elements;99 if (tagName == '*') {100 elements = getAllChildren(currentContext[h]);101 } else {102 elements = currentContext[h].getElementsByTagName(tagName);103 }104 for (var j = 0; j < elements.length; j++) {105 found[foundCount++] = elements[j];106 }107 }108 currentContext = new Array;109 var currentContextIndex = 0;110 var checkFunction; // This function will be used to filter the elements111 switch (attrOperator) {112 case '=': // Equality113 checkFunction = function(e) { return (e.getAttribute(attrName) == attrValue); };114 break;115 case '~': // Match one of space seperated words116 checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('\\b'+attrValue+'\\b'))); };117 break;118 case '|': // Match start with value followed by optional hyphen119 checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('^'+attrValue+'-?'))); };120 break;121 case '^': // Match starts with value122 checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) == 0); };123 break;124 case '$': // Match ends with value - fails with "Warning" in Opera 7125 checkFunction = function(e) { return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length); };126 break;127 case '*': // Match ends with value128 checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) > -1); };129 break;130 default :131 // Just test for existence of attribute132 checkFunction = function(e) { return e.getAttribute(attrName); };133 }134 currentContext = new Array;135 var currentContextIndex = 0;136 for (var k = 0; k < found.length; k++) {137 if (checkFunction(found[k])) {138 currentContext[currentContextIndex++] = found[k];139 }140 }141 // alert('Attribute Selector: '+tagName+' '+attrName+' '+attrOperator+' '+attrValue);142 continue; // Skip to next token143 }144 // If we get here, token is JUST an element (not a class or ID selector)145 tagName = token;146 var found = new Array;147 var foundCount = 0;148 for (var h = 0; h < currentContext.length; h++) {149 var elements = currentContext[h].getElementsByTagName(tagName);150 for (var j = 0; j < elements.length; j++) {151 found[foundCount++] = elements[j];152 }153 }154 currentContext = found;155 }156 return currentContext;157 }158 159 /* That revolting regular expression explained160 /^(\w+)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/161 \---/ \---/\-------------/ \-------/162 | | | |163 | | | The value164 | | ~,|,^,$,* or =165 | Attribute166 Tag167 */ -
media/js/calendar.js
1 /*2 calendar.js - Calendar functions by Adrian Holovaty3 */4 5 function removeChildren(a) { // "a" is reference to an object6 while (a.hasChildNodes()) a.removeChild(a.lastChild);7 }8 9 // quickElement(tagType, parentReference, textInChildNode, [, attribute, attributeValue ...]);10 function quickElement() {11 var obj = document.createElement(arguments[0]);12 if (arguments[2] != '' && arguments[2] != null) {13 var textNode = document.createTextNode(arguments[2]);14 obj.appendChild(textNode);15 }16 var len = arguments.length;17 for (var i = 3; i < len; i += 2) {18 obj.setAttribute(arguments[i], arguments[i+1]);19 }20 arguments[1].appendChild(obj);21 return obj;22 }23 24 // CalendarNamespace -- Provides a collection of HTML calendar-related helper functions25 var CalendarNamespace = {26 monthsOfYear: gettext('January February March April May June July August September October November December').split(' '),27 daysOfWeek: gettext('S M T W T F S').split(' '),28 isLeapYear: function(year) {29 return (((year % 4)==0) && ((year % 100)!=0) || ((year % 400)==0));30 },31 getDaysInMonth: function(month,year) {32 var days;33 if (month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12) {34 days = 31;35 }36 else if (month==4 || month==6 || month==9 || month==11) {37 days = 30;38 }39 else if (month==2 && CalendarNamespace.isLeapYear(year)) {40 days = 29;41 }42 else {43 days = 28;44 }45 return days;46 },47 draw: function(month, year, div_id, callback) { // month = 1-12, year = 1-999948 month = parseInt(month);49 year = parseInt(year);50 var calDiv = document.getElementById(div_id);51 removeChildren(calDiv);52 var calTable = document.createElement('table');53 quickElement('caption', calTable, CalendarNamespace.monthsOfYear[month-1] + ' ' + year);54 var tableBody = quickElement('tbody', calTable);55 56 // Draw days-of-week header57 var tableRow = quickElement('tr', tableBody);58 for (var i = 0; i < 7; i++) {59 quickElement('th', tableRow, CalendarNamespace.daysOfWeek[i]);60 }61 62 var startingPos = new Date(year, month-1, 1).getDay();63 var days = CalendarNamespace.getDaysInMonth(month, year);64 65 // Draw blanks before first of month66 tableRow = quickElement('tr', tableBody);67 for (var i = 0; i < startingPos; i++) {68 var _cell = quickElement('td', tableRow, ' ');69 _cell.style.backgroundColor = '#f3f3f3';70 }71 72 // Draw days of month73 var currentDay = 1;74 for (var i = startingPos; currentDay <= days; i++) {75 if (i%7 == 0 && currentDay != 1) {76 tableRow = quickElement('tr', tableBody);77 }78 var cell = quickElement('td', tableRow, '');79 quickElement('a', cell, currentDay, 'href', 'javascript:void(' + callback + '('+year+','+month+','+currentDay+'));');80 currentDay++;81 }82 83 // Draw blanks after end of month (optional, but makes for valid code)84 while (tableRow.childNodes.length < 7) {85 var _cell = quickElement('td', tableRow, ' ');86 _cell.style.backgroundColor = '#f3f3f3';87 }88 89 calDiv.appendChild(calTable);90 }91 }92 93 // Calendar -- A calendar instance94 function Calendar(div_id, callback) {95 // div_id (string) is the ID of the element in which the calendar will96 // be displayed97 // callback (string) is the name of a JavaScript function that will be98 // called with the parameters (year, month, day) when a day in the99 // calendar is clicked100 this.div_id = div_id;101 this.callback = callback;102 this.today = new Date();103 this.currentMonth = this.today.getMonth() + 1;104 this.currentYear = this.today.getFullYear();105 }106 Calendar.prototype = {107 drawCurrent: function() {108 CalendarNamespace.draw(this.currentMonth, this.currentYear, this.div_id, this.callback);109 },110 drawDate: function(month, year) {111 this.currentMonth = month;112 this.currentYear = year;113 this.drawCurrent();114 },115 drawPreviousMonth: function() {116 if (this.currentMonth == 1) {117 this.currentMonth = 12;118 this.currentYear--;119 }120 else {121 this.currentMonth--;122 }123 this.drawCurrent();124 },125 drawNextMonth: function() {126 if (this.currentMonth == 12) {127 this.currentMonth = 1;128 this.currentYear++;129 }130 else {131 this.currentMonth++;132 }133 this.drawCurrent();134 },135 drawPreviousYear: function() {136 this.currentYear--;137 this.drawCurrent();138 },139 drawNextYear: function() {140 this.currentYear++;141 this.drawCurrent();142 }143 } -
media/js/timeparse.js
1 var timeParsePatterns = [2 // 93 { re: /^\d{1,2}$/i,4 handler: function(bits) {5 if (bits[0].length == 1) {6 return '0' + bits[0] + ':00';7 } else {8 return bits[0] + ':00';9 }10 }11 },12 // 13:0013 { re: /^\d{2}[:.]\d{2}$/i,14 handler: function(bits) {15 return bits[0].replace('.', ':');16 }17 },18 // 9:0019 { re: /^\d[:.]\d{2}$/i,20 handler: function(bits) {21 return '0' + bits[0].replace('.', ':');22 }23 },24 // 3 am / 3 a.m. / 3am25 { re: /^(\d+)\s*([ap])(?:.?m.?)?$/i,26 handler: function(bits) {27 var hour = parseInt(bits[1]);28 if (hour == 12) {29 hour = 0;30 }31 if (bits[2].toLowerCase() == 'p') {32 if (hour == 12) {33 hour = 0;34 }35 return (hour + 12) + ':00';36 } else {37 if (hour < 10) {38 return '0' + hour + ':00';39 } else {40 return hour + ':00';41 }42 }43 }44 },45 // 3.30 am / 3:15 a.m. / 3.00am46 { re: /^(\d+)[.:](\d{2})\s*([ap]).?m.?$/i,47 handler: function(bits) {48 var hour = parseInt(bits[1]);49 var mins = parseInt(bits[2]);50 if (mins < 10) {51 mins = '0' + mins;52 }53 if (hour == 12) {54 hour = 0;55 }56 if (bits[3].toLowerCase() == 'p') {57 if (hour == 12) {58 hour = 0;59 }60 return (hour + 12) + ':' + mins;61 } else {62 if (hour < 10) {63 return '0' + hour + ':' + mins;64 } else {65 return hour + ':' + mins;66 }67 }68 }69 },70 // noon71 { re: /^no/i,72 handler: function(bits) {73 return '12:00';74 }75 },76 // midnight77 { re: /^mid/i,78 handler: function(bits) {79 return '00:00';80 }81 }82 ];83 84 function parseTimeString(s) {85 for (var i = 0; i < timeParsePatterns.length; i++) {86 var re = timeParsePatterns[i].re;87 var handler = timeParsePatterns[i].handler;88 var bits = re.exec(s);89 if (bits) {90 return handler(bits);91 }92 }93 return s;94 } -
media/js/urlify.js
1 function URLify(s, num_chars) {2 // changes, e.g., "Petty theft" to "petty_theft"3 // remove all these words from the string before urlifying4 removelist = ["a", "an", "as", "at", "before", "but", "by", "for", "from",5 "is", "in", "into", "like", "of", "off", "on", "onto", "per",6 "since", "than", "the", "this", "that", "to", "up", "via",7 "with"];8 r = new RegExp('\\b(' + removelist.join('|') + ')\\b', 'gi');9 s = s.replace(r, '');10 s = s.replace(/[^-A-Z0-9\s]/gi, ''); // remove unneeded chars11 s = s.replace(/^\s+|\s+$/g, ''); // trim leading/trailing spaces12 s = s.replace(/\s+/g, '-'); // convert spaces to hyphens13 s = s.toLowerCase(); // convert to lowercase14 return s.substring(0, num_chars);// trim to first num_chars chars15 }16 No newline at end of file -
media/js/admin/RelatedObjectLookups.js
1 // Handles related-objects functionality: lookup link for raw_id_admin=True2 // and Add Another links.3 4 function showRelatedObjectLookupPopup(triggeringLink) {5 var name = triggeringLink.id.replace(/^lookup_/, '');6 var href;7 if (triggeringLink.href.search(/\?/) >= 0) {8 href = triggeringLink.href + '&pop=1';9 } else {10 href = triggeringLink.href + '?pop=1';11 }12 var win = window.open(href, name, 'height=500,width=740,resizable=yes,scrollbars=yes');13 win.focus();14 return false;15 }16 17 function dismissRelatedLookupPopup(win, chosenId) {18 var elem = document.getElementById(win.name);19 if (elem.className.indexOf('vRawIdAdminField') != -1 && elem.value) {20 elem.value += ',' + chosenId;21 } else {22 document.getElementById(win.name).value = chosenId;23 }24 win.close();25 }26 27 function showAddAnotherPopup(triggeringLink) {28 var name = triggeringLink.id.replace(/^add_/, '');29 name = name.replace(/\./g, '___');30 var win = window.open(triggeringLink.href + '?_popup=1', name, 'height=500,width=800,resizable=yes,scrollbars=yes');31 win.focus();32 return false;33 }34 35 function dismissAddAnotherPopup(win, newId, newRepr) {36 var name = win.name.replace(/___/g, '.');37 var elem = document.getElementById(name);38 if (elem) {39 if (elem.nodeName == 'SELECT') {40 var o = new Option(newRepr, newId);41 elem.options[elem.options.length] = o;42 elem.selectedIndex = elem.length - 1;43 } else if (elem.nodeName == 'INPUT') {44 elem.value = newId;45 }46 } else {47 var toId = name + "_to";48 elem = document.getElementById(toId);49 var o = new Option(newRepr, newId);50 SelectBox.add_to_cache(toId, o);51 SelectBox.redisplay(toId);52 }53 win.close();54 } -
media/js/admin/CollapsedFieldsets.js
1 // Finds all fieldsets with class="collapse", collapses them, and gives each2 // one a "Show" link that uncollapses it. The "Show" link becomes a "Hide"3 // link when the fieldset is visible.4 5 function findForm(node) {6 // returns the node of the form containing the given node7 if (node.tagName.toLowerCase() != 'form') {8 return findForm(node.parentNode);9 }10 return node;11 }12 13 var CollapsedFieldsets = {14 collapse_re: /\bcollapse\b/, // Class of fieldsets that should be dealt with.15 collapsed_re: /\bcollapsed\b/, // Class that fieldsets get when they're hidden.16 collapsed_class: 'collapsed',17 init: function() {18 var fieldsets = document.getElementsByTagName('fieldset');19 var collapsed_seen = false;20 for (var i = 0, fs; fs = fieldsets[i]; i++) {21 // Collapse this fieldset if it has the correct class, and if it22 // doesn't have any errors. (Collapsing shouldn't apply in the case23 // of error messages.)24 if (fs.className.match(CollapsedFieldsets.collapse_re) && !CollapsedFieldsets.fieldset_has_errors(fs)) {25 collapsed_seen = true;26 // Give it an additional class, used by CSS to hide it.27 fs.className += ' ' + CollapsedFieldsets.collapsed_class;28 // (<a id="fieldsetcollapser3" class="collapse-toggle" href="#">Show</a>)29 var collapse_link = document.createElement('a');30 collapse_link.className = 'collapse-toggle';31 collapse_link.id = 'fieldsetcollapser' + i;32 collapse_link.onclick = new Function('CollapsedFieldsets.show('+i+'); return false;');33 collapse_link.href = '#';34 collapse_link.innerHTML = 'Show';35 var h2 = fs.getElementsByTagName('h2')[0];36 h2.appendChild(document.createTextNode(' ('));37 h2.appendChild(collapse_link);38 h2.appendChild(document.createTextNode(')'));39 }40 }41 if (collapsed_seen) {42 // Expand all collapsed fieldsets when form is submitted.43 addEvent(findForm(document.getElementsByTagName('fieldset')[0]), 'submit', function() { CollapsedFieldsets.uncollapse_all(); });44 }45 },46 fieldset_has_errors: function(fs) {47 // Returns true if any fields in the fieldset have validation errors.48 var divs = fs.getElementsByTagName('div');49 for (var i=0; i<divs.length; i++) {50 if (divs[i].className.match(/\berror\b/)) {51 return true;52 }53 }54 return false;55 },56 show: function(fieldset_index) {57 var fs = document.getElementsByTagName('fieldset')[fieldset_index];58 // Remove the class name that causes the "display: none".59 fs.className = fs.className.replace(CollapsedFieldsets.collapsed_re, '');60 // Toggle the "Show" link to a "Hide" link61 var collapse_link = document.getElementById('fieldsetcollapser' + fieldset_index);62 collapse_link.onclick = new Function('CollapsedFieldsets.hide('+fieldset_index+'); return false;');63 collapse_link.innerHTML = 'Hide';64 },65 hide: function(fieldset_index) {66 var fs = document.getElementsByTagName('fieldset')[fieldset_index];67 // Add the class name that causes the "display: none".68 fs.className += ' ' + CollapsedFieldsets.collapsed_class;69 // Toggle the "Hide" link to a "Show" link70 var collapse_link = document.getElementById('fieldsetcollapser' + fieldset_index);71 collapse_link.onclick = new Function('CollapsedFieldsets.show('+fieldset_index+'); return false;');72 collapse_link.innerHTML = 'Show';73 },74 75 uncollapse_all: function() {76 var fieldsets = document.getElementsByTagName('fieldset');77 for (var i=0; i<fieldsets.length; i++) {78 if (fieldsets[i].className.match(CollapsedFieldsets.collapsed_re)) {79 CollapsedFieldsets.show(i);80 }81 }82 }83 }84 85 addEvent(window, 'load', CollapsedFieldsets.init); -
media/js/admin/ordering.js
1 addEvent(window, 'load', reorder_init);2 3 var lis;4 var top = 0;5 var left = 0;6 var height = 30;7 8 function reorder_init() {9 lis = document.getElementsBySelector('ul#orderthese li');10 var input = document.getElementsBySelector('input[name=order_]')[0];11 setOrder(input.value.split(','));12 input.disabled = true;13 draw();14 // Now initialise the dragging behaviour15 var limit = (lis.length - 1) * height;16 for (var i = 0; i < lis.length; i++) {17 var li = lis[i];18 var img = document.getElementById('handle'+li.id);19 li.style.zIndex = 1;20 Drag.init(img, li, left + 10, left + 10, top + 10, top + 10 + limit);21 li.onDragStart = startDrag;22 li.onDragEnd = endDrag;23 img.style.cursor = 'move';24 }25 }26 27 function submitOrderForm() {28 var inputOrder = document.getElementsBySelector('input[name=order_]')[0];29 inputOrder.value = getOrder();30 inputOrder.disabled=false;31 }32 33 function startDrag() {34 this.style.zIndex = '10';35 this.className = 'dragging';36 }37 38 function endDrag(x, y) {39 this.style.zIndex = '1';40 this.className = '';41 // Work out how far along it has been dropped, using x co-ordinate42 var oldIndex = this.index;43 var newIndex = Math.round((y - 10 - top) / height);44 // 'Snap' to the correct position45 this.style.top = (10 + top + newIndex * height) + 'px';46 this.index = newIndex;47 moveItem(oldIndex, newIndex);48 }49 50 function moveItem(oldIndex, newIndex) {51 // Swaps two items, adjusts the index and left co-ord for all others52 if (oldIndex == newIndex) {53 return; // Nothing to swap;54 }55 var direction, lo, hi;56 if (newIndex > oldIndex) {57 lo = oldIndex;58 hi = newIndex;59 direction = -1;60 } else {61 direction = 1;62 hi = oldIndex;63 lo = newIndex;64 }65 var lis2 = new Array(); // We will build the new order in this array66 for (var i = 0; i < lis.length; i++) {67 if (i < lo || i > hi) {68 // Position of items not between the indexes is unaffected69 lis2[i] = lis[i];70 continue;71 } else if (i == newIndex) {72 lis2[i] = lis[oldIndex];73 continue;74 } else {75 // Item is between the two indexes - move it along 176 lis2[i] = lis[i - direction];77 }78 }79 // Re-index everything80 reIndex(lis2);81 lis = lis2;82 draw();83 // document.getElementById('hiddenOrder').value = getOrder();84 document.getElementsBySelector('input[name=order_]')[0].value = getOrder();85 }86 87 function reIndex(lis) {88 for (var i = 0; i < lis.length; i++) {89 lis[i].index = i;90 }91 }92 93 function draw() {94 for (var i = 0; i < lis.length; i++) {95 var li = lis[i];96 li.index = i;97 li.style.position = 'absolute';98 li.style.left = (10 + left) + 'px';99 li.style.top = (10 + top + (i * height)) + 'px';100 }101 }102 103 function getOrder() {104 var order = new Array(lis.length);105 for (var i = 0; i < lis.length; i++) {106 order[i] = lis[i].id.substring(1, 100);107 }108 return order.join(',');109 }110 111 function setOrder(id_list) {112 /* Set the current order to match the lsit of IDs */113 var temp_lis = new Array();114 for (var i = 0; i < id_list.length; i++) {115 var id = 'p' + id_list[i];116 temp_lis[temp_lis.length] = document.getElementById(id);117 }118 reIndex(temp_lis);119 lis = temp_lis;120 draw();121 }122 123 function addEvent(elm, evType, fn, useCapture)124 // addEvent and removeEvent125 // cross-browser event handling for IE5+, NS6 and Mozilla126 // By Scott Andrew127 {128 if (elm.addEventListener){129 elm.addEventListener(evType, fn, useCapture);130 return true;131 } else if (elm.attachEvent){132 var r = elm.attachEvent("on"+evType, fn);133 return r;134 } else {135 elm['on'+evType] = fn;136 }137 } -
media/js/admin/DateTimeShortcuts.js
1 // Inserts shortcut buttons after all of the following:2 // <input type="text" class="vDateField">3 // <input type="text" class="vTimeField">4 5 var DateTimeShortcuts = {6 calendars: [],7 calendarInputs: [],8 clockInputs: [],9 calendarDivName1: 'calendarbox', // name of calendar <div> that gets toggled10 calendarDivName2: 'calendarin', // name of <div> that contains calendar11 clockDivName: 'clockbox', // name of clock <div> that gets toggled12 admin_media_prefix: '',13 init: function() {14 // Deduce admin_media_prefix by looking at the <script>s in the15 // current document and finding the URL of *this* module.16 var scripts = document.getElementsByTagName('script');17 for (var i=0; i<scripts.length; i++) {18 if (scripts[i].src.match(/DateTimeShortcuts/)) {19 var idx = scripts[i].src.indexOf('js/admin/DateTimeShortcuts');20 DateTimeShortcuts.admin_media_prefix = scripts[i].src.substring(0, idx);21 break;22 }23 }24 25 var inputs = document.getElementsByTagName('input');26 for (i=0; i<inputs.length; i++) {27 var inp = inputs[i];28 if (inp.getAttribute('type') == 'text' && inp.className.match(/vTimeField/)) {29 DateTimeShortcuts.addClock(inp);30 }31 else if (inp.getAttribute('type') == 'text' && inp.className.match(/vDateField/)) {32 DateTimeShortcuts.addCalendar(inp);33 }34 }35 },36 // Add clock widget to a given field37 addClock: function(inp) {38 var num = DateTimeShortcuts.clockInputs.length;39 DateTimeShortcuts.clockInputs[num] = inp;40 41 // Shortcut links (clock icon and "Now" link)42 var shortcuts_span = document.createElement('span');43 inp.parentNode.insertBefore(shortcuts_span, inp.nextSibling);44 var now_link = document.createElement('a');45 now_link.setAttribute('href', "javascript:DateTimeShortcuts.handleClockQuicklink(" + num + ", new Date().getHourMinute());");46 now_link.appendChild(document.createTextNode(gettext('Now')));47 var clock_link = document.createElement('a');48 clock_link.setAttribute('href', 'javascript:DateTimeShortcuts.openClock(' + num + ');');49 quickElement('img', clock_link, '', 'src', DateTimeShortcuts.admin_media_prefix + 'img/admin/icon_clock.gif', 'alt', gettext('Clock'));50 shortcuts_span.appendChild(document.createTextNode('\240'));51 shortcuts_span.appendChild(now_link);52 shortcuts_span.appendChild(document.createTextNode('\240|\240'));53 shortcuts_span.appendChild(clock_link);54 55 // Create clock link div56 //57 // Markup looks like:58 // <div id="clockbox1" class="clockbox module">59 // <h2>Choose a time</h2>60 // <ul class="timelist">61 // <li><a href="#">Now</a></li>62 // <li><a href="#">Midnight</a></li>63 // <li><a href="#">6 a.m.</a></li>64 // <li><a href="#">Noon</a></li>65 // </ul>66 // <p class="calendar-cancel"><a href="#">Cancel</a></p>67 // </div>68 69 var clock_box = document.createElement('div');70 clock_box.style.display = 'none';71 clock_box.style.position = 'absolute';72 clock_box.style.left = findPosX(clock_link) + 17 + 'px';73 clock_box.style.top = findPosY(clock_link) - 30 + 'px';74 clock_box.className = 'clockbox module';75 clock_box.setAttribute('id', DateTimeShortcuts.clockDivName + num);76 document.body.appendChild(clock_box);77 addEvent(clock_box, 'click', DateTimeShortcuts.cancelEventPropagation);78 79 quickElement('h2', clock_box, gettext('Choose a time'));80 time_list = quickElement('ul', clock_box, '');81 time_list.className = 'timelist';82 quickElement("a", quickElement("li", time_list, ""), gettext("Now"), "href", "javascript:DateTimeShortcuts.handleClockQuicklink(" + num + ", new Date().getHourMinute());")83 quickElement("a", quickElement("li", time_list, ""), gettext("Midnight"), "href", "javascript:DateTimeShortcuts.handleClockQuicklink(" + num + ", '00:00');")84 quickElement("a", quickElement("li", time_list, ""), gettext("6 a.m."), "href", "javascript:DateTimeShortcuts.handleClockQuicklink(" + num + ", '06:00');")85 quickElement("a", quickElement("li", time_list, ""), gettext("Noon"), "href", "javascript:DateTimeShortcuts.handleClockQuicklink(" + num + ", '12:00');")86 87 cancel_p = quickElement('p', clock_box, '');88 cancel_p.className = 'calendar-cancel';89 quickElement('a', cancel_p, gettext('Cancel'), 'href', 'javascript:DateTimeShortcuts.dismissClock(' + num + ');');90 },91 openClock: function(num) {92 document.getElementById(DateTimeShortcuts.clockDivName + num).style.display = 'block';93 addEvent(window, 'click', function() { DateTimeShortcuts.dismissClock(num); return true; });94 },95 dismissClock: function(num) {96 document.getElementById(DateTimeShortcuts.clockDivName + num).style.display = 'none';97 window.onclick = null;98 },99 handleClockQuicklink: function(num, val) {100 DateTimeShortcuts.clockInputs[num].value = val;101 DateTimeShortcuts.dismissClock(num);102 },103 // Add calendar widget to a given field.104 addCalendar: function(inp) {105 var num = DateTimeShortcuts.calendars.length;106 107 DateTimeShortcuts.calendarInputs[num] = inp;108 109 // Shortcut links (calendar icon and "Today" link)110 var shortcuts_span = document.createElement('span');111 inp.parentNode.insertBefore(shortcuts_span, inp.nextSibling);112 var today_link = document.createElement('a');113 today_link.setAttribute('href', 'javascript:DateTimeShortcuts.handleCalendarQuickLink(' + num + ', 0);');114 today_link.appendChild(document.createTextNode(gettext('Today')));115 var cal_link = document.createElement('a');116 cal_link.setAttribute('href', 'javascript:DateTimeShortcuts.openCalendar(' + num + ');');117 quickElement('img', cal_link, '', 'src', DateTimeShortcuts.admin_media_prefix + 'img/admin/icon_calendar.gif', 'alt', gettext('Calendar'));118 shortcuts_span.appendChild(document.createTextNode('\240'));119 shortcuts_span.appendChild(today_link);120 shortcuts_span.appendChild(document.createTextNode('\240|\240'));121 shortcuts_span.appendChild(cal_link);122 123 // Create calendarbox div.124 //125 // Markup looks like:126 //127 // <div id="calendarbox3" class="calendarbox module">128 // <h2>129 // <a href="#" class="link-previous">‹</a>130 // <a href="#" class="link-next">›</a> February 2003131 // </h2>132 // <div class="calendar" id="calendarin3">133 // <!-- (cal) -->134 // </div>135 // <div class="calendar-shortcuts">136 // <a href="#">Yesterday</a> | <a href="#">Today</a> | <a href="#">Tomorrow</a>137 // </div>138 // <p class="calendar-cancel"><a href="#">Cancel</a></p>139 // </div>140 var cal_box = document.createElement('div');141 cal_box.style.display = 'none';142 cal_box.style.position = 'absolute';143 cal_box.style.left = findPosX(cal_link) + 17 + 'px';144 cal_box.style.top = findPosY(cal_link) - 75 + 'px';145 cal_box.className = 'calendarbox module';146 cal_box.setAttribute('id', DateTimeShortcuts.calendarDivName1 + num);147 document.body.appendChild(cal_box);148 addEvent(cal_box, 'click', DateTimeShortcuts.cancelEventPropagation);149 150 // next-prev links151 var cal_nav = quickElement('div', cal_box, '');152 var cal_nav_prev = quickElement('a', cal_nav, '<', 'href', 'javascript:DateTimeShortcuts.drawPrev('+num+');');153 cal_nav_prev.className = 'calendarnav-previous';154 var cal_nav_next = quickElement('a', cal_nav, '>', 'href', 'javascript:DateTimeShortcuts.drawNext('+num+');');155 cal_nav_next.className = 'calendarnav-next';156 cal_box.appendChild(cal_nav);157 158 // main box159 var cal_main = quickElement('div', cal_box, '', 'id', DateTimeShortcuts.calendarDivName2 + num);160 cal_main.className = 'calendar';161 DateTimeShortcuts.calendars[num] = new Calendar(DateTimeShortcuts.calendarDivName2 + num, DateTimeShortcuts.handleCalendarCallback(num));162 DateTimeShortcuts.calendars[num].drawCurrent();163 164 // calendar shortcuts165 var shortcuts = quickElement('div', cal_box, '');166 shortcuts.className = 'calendar-shortcuts';167 quickElement('a', shortcuts, gettext('Yesterday'), 'href', 'javascript:DateTimeShortcuts.handleCalendarQuickLink(' + num + ', -1);');168 shortcuts.appendChild(document.createTextNode('\240|\240'));169 quickElement('a', shortcuts, gettext('Today'), 'href', 'javascript:DateTimeShortcuts.handleCalendarQuickLink(' + num + ', 0);');170 shortcuts.appendChild(document.createTextNode('\240|\240'));171 quickElement('a', shortcuts, gettext('Tomorrow'), 'href', 'javascript:DateTimeShortcuts.handleCalendarQuickLink(' + num + ', +1);');172 173 // cancel bar174 var cancel_p = quickElement('p', cal_box, '');175 cancel_p.className = 'calendar-cancel';176 quickElement('a', cancel_p, gettext('Cancel'), 'href', 'javascript:DateTimeShortcuts.dismissCalendar(' + num + ');');177 },178 openCalendar: function(num) {179 document.getElementById(DateTimeShortcuts.calendarDivName1+num).style.display = 'block';180 addEvent(window, 'click', function() { DateTimeShortcuts.dismissCalendar(num); return true; });181 },182 dismissCalendar: function(num) {183 document.getElementById(DateTimeShortcuts.calendarDivName1+num).style.display = 'none';184 },185 drawPrev: function(num) {186 DateTimeShortcuts.calendars[num].drawPreviousMonth();187 },188 drawNext: function(num) {189 DateTimeShortcuts.calendars[num].drawNextMonth();190 },191 handleCalendarCallback: function(num) {192 return "function(y, m, d) { DateTimeShortcuts.calendarInputs["+num+"].value = y+'-'+m+'-'+d; document.getElementById(DateTimeShortcuts.calendarDivName1+"+num+").style.display='none';}";193 },194 handleCalendarQuickLink: function(num, offset) {195 var d = new Date();196 d.setDate(d.getDate() + offset)197 DateTimeShortcuts.calendarInputs[num].value = d.getISODate();198 DateTimeShortcuts.dismissCalendar(num);199 },200 cancelEventPropagation: function(e) {201 if (!e) var e = window.event;202 e.cancelBubble = true;203 if (e.stopPropagation) e.stopPropagation();204 }205 }206 207 addEvent(window, 'load', DateTimeShortcuts.init); -
media/js/dojo/dojo.js
1 /* 2 Copyright (c) 2004-2005, The Dojo Foundation 3 All Rights Reserved. 4 5 Licensed under the Academic Free License version 2.1 or above OR the 6 modified BSD license. For more information on Dojo licensing, see: 7 8 http://dojotoolkit.org/community/licensing.shtml 9 */ 10 11 /* 12 This is a compiled version of Dojo, built for deployment and not for 13 development. To get an editable version, please visit: 14 15 http://dojotoolkit.org 16 17 for documentation and information on getting the source. 18 */ 19 20 var dj_global=this; 21 function dj_undef(_1,_2){ 22 if(!_2){ 23 _2=dj_global; 24 } 25 return (typeof _2[_1]=="undefined"); 26 } 27 if(dj_undef("djConfig")){ 28 var djConfig={}; 29 } 30 var dojo; 31 if(dj_undef("dojo")){ 32 dojo={}; 33 } 34 dojo.version={major:0,minor:2,patch:2,flag:"",revision:Number("$Rev: 2836 $".match(/[0-9]+/)[0]),toString:function(){ 35 with(dojo.version){ 36 return major+"."+minor+"."+patch+flag+" ("+revision+")"; 37 } 38 }}; 39 dojo.evalObjPath=function(_3,_4){ 40 if(typeof _3!="string"){ 41 return dj_global; 42 } 43 if(_3.indexOf(".")==-1){ 44 if((dj_undef(_3,dj_global))&&(_4)){ 45 dj_global[_3]={}; 46 } 47 return dj_global[_3]; 48 } 49 var _5=_3.split(/\./); 50 var _6=dj_global; 51 for(var i=0;i<_5.length;++i){ 52 if(!_4){ 53 _6=_6[_5[i]]; 54 if((typeof _6=="undefined")||(!_6)){ 55 return _6; 56 } 57 }else{ 58 if(dj_undef(_5[i],_6)){ 59 _6[_5[i]]={}; 60 } 61 _6=_6[_5[i]]; 62 } 63 } 64 return _6; 65 }; 66 dojo.errorToString=function(_8){ 67 return ((!dj_undef("message",_8))?_8.message:(dj_undef("description",_8)?_8:_8.description)); 68 }; 69 dojo.raise=function(_9,_a){ 70 if(_a){ 71 _9=_9+": "+dojo.errorToString(_a); 72 } 73 var he=dojo.hostenv; 74 if((!dj_undef("hostenv",dojo))&&(!dj_undef("println",dojo.hostenv))){ 75 dojo.hostenv.println("FATAL: "+_9); 76 } 77 throw Error(_9); 78 }; 79 dj_throw=dj_rethrow=function(m,e){ 80 dojo.deprecated("dj_throw and dj_rethrow deprecated, use dojo.raise instead"); 81 dojo.raise(m,e); 82 }; 83 dojo.debug=function(){ 84 if(!djConfig.isDebug){ 85 return; 86 } 87 var _e=arguments; 88 if(dj_undef("println",dojo.hostenv)){ 89 dojo.raise("dojo.debug not available (yet?)"); 90 } 91 var _f=dj_global["jum"]&&!dj_global["jum"].isBrowser; 92 var s=[(_f?"":"DEBUG: ")]; 93 for(var i=0;i<_e.length;++i){ 94 if(!false&&_e[i] instanceof Error){ 95 var msg="["+_e[i].name+": "+dojo.errorToString(_e[i])+(_e[i].fileName?", file: "+_e[i].fileName:"")+(_e[i].lineNumber?", line: "+_e[i].lineNumber:"")+"]"; 96 }else{ 97 try{ 98 var msg=String(_e[i]); 99 } 100 catch(e){ 101 if(dojo.render.html.ie){ 102 var msg="[ActiveXObject]"; 103 }else{ 104 var msg="[unknown]"; 105 } 106 } 107 } 108 s.push(msg); 109 } 110 if(_f){ 111 jum.debug(s.join(" ")); 112 }else{ 113 dojo.hostenv.println(s.join(" ")); 114 } 115 }; 116 dojo.debugShallow=function(obj){ 117 if(!djConfig.isDebug){ 118 return; 119 } 120 dojo.debug("------------------------------------------------------------"); 121 dojo.debug("Object: "+obj); 122 for(i in obj){ 123 dojo.debug(i+": "+obj[i]); 124 } 125 dojo.debug("------------------------------------------------------------"); 126 }; 127 var dj_debug=dojo.debug; 128 function dj_eval(s){ 129 return dj_global.eval?dj_global.eval(s):eval(s); 130 } 131 dj_unimplemented=dojo.unimplemented=function(_15,_16){ 132 var _17="'"+_15+"' not implemented"; 133 if((!dj_undef(_16))&&(_16)){ 134 _17+=" "+_16; 135 } 136 dojo.raise(_17); 137 }; 138 dj_deprecated=dojo.deprecated=function(_18,_19,_1a){ 139 var _1b="DEPRECATED: "+_18; 140 if(_19){ 141 _1b+=" "+_19; 142 } 143 if(_1a){ 144 _1b+=" -- will be removed in version: "+_1a; 145 } 146 dojo.debug(_1b); 147 }; 148 dojo.inherits=function(_1c,_1d){ 149 if(typeof _1d!="function"){ 150 dojo.raise("superclass: "+_1d+" borken"); 151 } 152 _1c.prototype=new _1d(); 153 _1c.prototype.constructor=_1c; 154 _1c.superclass=_1d.prototype; 155 _1c["super"]=_1d.prototype; 156 }; 157 dj_inherits=function(_1e,_1f){ 158 dojo.deprecated("dj_inherits deprecated, use dojo.inherits instead"); 159 dojo.inherits(_1e,_1f); 160 }; 161 dojo.render=(function(){ 162 function vscaffold(_20,_21){ 163 var tmp={capable:false,support:{builtin:false,plugin:false},prefixes:_20}; 164 for(var x in _21){ 165 tmp[x]=false; 166 } 167 return tmp; 168 } 169 return {name:"",ver:dojo.version,os:{win:false,linux:false,osx:false},html:vscaffold(["html"],["ie","opera","khtml","safari","moz"]),svg:vscaffold(["svg"],["corel","adobe","batik"]),vml:vscaffold(["vml"],["ie"]),swf:vscaffold(["Swf","Flash","Mm"],["mm"]),swt:vscaffold(["Swt"],["ibm"])}; 170 })(); 171 dojo.hostenv=(function(){ 172 var _24={isDebug:false,allowQueryConfig:false,baseScriptUri:"",baseRelativePath:"",libraryScriptUri:"",iePreventClobber:false,ieClobberMinimal:true,preventBackButtonFix:true,searchIds:[],parseWidgets:true}; 173 if(typeof djConfig=="undefined"){ 174 djConfig=_24; 175 }else{ 176 for(var _25 in _24){ 177 if(typeof djConfig[_25]=="undefined"){ 178 djConfig[_25]=_24[_25]; 179 } 180 } 181 } 182 var djc=djConfig; 183 function _def(obj,_28,def){ 184 return (dj_undef(_28,obj)?def:obj[_28]); 185 } 186 return {name_:"(unset)",version_:"(unset)",pkgFileName:"__package__",loading_modules_:{},loaded_modules_:{},addedToLoadingCount:[],removedFromLoadingCount:[],inFlightCount:0,modulePrefixes_:{dojo:{name:"dojo",value:"src"}},setModulePrefix:function(_2a,_2b){ 187 this.modulePrefixes_[_2a]={name:_2a,value:_2b}; 188 },getModulePrefix:function(_2c){ 189 var mp=this.modulePrefixes_; 190 if((mp[_2c])&&(mp[_2c]["name"])){ 191 return mp[_2c].value; 192 } 193 return _2c; 194 },getTextStack:[],loadUriStack:[],loadedUris:[],post_load_:false,modulesLoadedListeners:[],getName:function(){ 195 return this.name_; 196 },getVersion:function(){ 197 return this.version_; 198 },getText:function(uri){ 199 dojo.unimplemented("getText","uri="+uri); 200 },getLibraryScriptUri:function(){ 201 dojo.unimplemented("getLibraryScriptUri",""); 202 }}; 203 })(); 204 dojo.hostenv.getBaseScriptUri=function(){ 205 if(djConfig.baseScriptUri.length){ 206 return djConfig.baseScriptUri; 207 } 208 var uri=new String(djConfig.libraryScriptUri||djConfig.baseRelativePath); 209 if(!uri){ 210 dojo.raise("Nothing returned by getLibraryScriptUri(): "+uri); 211 } 212 var _30=uri.lastIndexOf("/"); 213 djConfig.baseScriptUri=djConfig.baseRelativePath; 214 return djConfig.baseScriptUri; 215 }; 216 dojo.hostenv.setBaseScriptUri=function(uri){ 217 djConfig.baseScriptUri=uri; 218 }; 219 dojo.hostenv.loadPath=function(_32,_33,cb){ 220 if((_32.charAt(0)=="/")||(_32.match(/^\w+:/))){ 221 dojo.raise("relpath '"+_32+"'; must be relative"); 222 } 223 var uri=this.getBaseScriptUri()+_32; 224 if(djConfig.cacheBust&&dojo.render.html.capable){ 225 uri+="?"+String(djConfig.cacheBust).replace(/\W+/g,""); 226 } 227 try{ 228 return ((!_33)?this.loadUri(uri,cb):this.loadUriAndCheck(uri,_33,cb)); 229 } 230 catch(e){ 231 dojo.debug(e); 232 return false; 233 } 234 }; 235 dojo.hostenv.loadUri=function(uri,cb){ 236 if(this.loadedUris[uri]){ 237 return; 238 } 239 var _38=this.getText(uri,null,true); 240 if(_38==null){ 241 return 0; 242 } 243 this.loadedUris[uri]=true; 244 var _39=dj_eval(_38); 245 return 1; 246 }; 247 dojo.hostenv.loadUriAndCheck=function(uri,_3b,cb){ 248 var ok=true; 249 try{ 250 ok=this.loadUri(uri,cb); 251 } 252 catch(e){ 253 dojo.debug("failed loading ",uri," with error: ",e); 254 } 255 return ((ok)&&(this.findModule(_3b,false)))?true:false; 256 }; 257 dojo.loaded=function(){ 258 }; 259 dojo.hostenv.loaded=function(){ 260 this.post_load_=true; 261 var mll=this.modulesLoadedListeners; 262 for(var x=0;x<mll.length;x++){ 263 mll[x](); 264 } 265 dojo.loaded(); 266 }; 267 dojo.addOnLoad=function(obj,_41){ 268 if(arguments.length==1){ 269 dojo.hostenv.modulesLoadedListeners.push(obj); 270 }else{ 271 if(arguments.length>1){ 272 dojo.hostenv.modulesLoadedListeners.push(function(){ 273 obj[_41](); 274 }); 275 } 276 } 277 }; 278 dojo.hostenv.modulesLoaded=function(){ 279 if(this.post_load_){ 280 return; 281 } 282 if((this.loadUriStack.length==0)&&(this.getTextStack.length==0)){ 283 if(this.inFlightCount>0){ 284 dojo.debug("files still in flight!"); 285 return; 286 } 287 if(typeof setTimeout=="object"){ 288 setTimeout("dojo.hostenv.loaded();",0); 289 }else{ 290 dojo.hostenv.loaded(); 291 } 292 } 293 }; 294 dojo.hostenv.moduleLoaded=function(_42){ 295 var _43=dojo.evalObjPath((_42.split(".").slice(0,-1)).join(".")); 296 this.loaded_modules_[(new String(_42)).toLowerCase()]=_43; 297 }; 298 dojo.hostenv._global_omit_module_check=false; 299 dojo.hostenv.loadModule=function(_44,_45,_46){ 300 if(!_44){ 301 return; 302 } 303 _46=this._global_omit_module_check||_46; 304 var _47=this.findModule(_44,false); 305 if(_47){ 306 return _47; 307 } 308 if(dj_undef(_44,this.loading_modules_)){ 309 this.addedToLoadingCount.push(_44); 310 } 311 this.loading_modules_[_44]=1; 312 var _48=_44.replace(/\./g,"/")+".js"; 313 var _49=_44.split("."); 314 var _4a=_44.split("."); 315 for(var i=_49.length-1;i>0;i--){ 316 var _4c=_49.slice(0,i).join("."); 317 var _4d=this.getModulePrefix(_4c); 318 if(_4d!=_4c){ 319 _49.splice(0,i,_4d); 320 break; 321 } 322 } 323 var _4e=_49[_49.length-1]; 324 if(_4e=="*"){ 325 _44=(_4a.slice(0,-1)).join("."); 326 while(_49.length){ 327 _49.pop(); 328 _49.push(this.pkgFileName); 329 _48=_49.join("/")+".js"; 330 if(_48.charAt(0)=="/"){ 331 _48=_48.slice(1); 332 } 333 ok=this.loadPath(_48,((!_46)?_44:null)); 334 if(ok){ 335 break; 336 } 337 _49.pop(); 338 } 339 }else{ 340 _48=_49.join("/")+".js"; 341 _44=_4a.join("."); 342 var ok=this.loadPath(_48,((!_46)?_44:null)); 343 if((!ok)&&(!_45)){ 344 _49.pop(); 345 while(_49.length){ 346 _48=_49.join("/")+".js"; 347 ok=this.loadPath(_48,((!_46)?_44:null)); 348 if(ok){ 349 break; 350 } 351 _49.pop(); 352 _48=_49.join("/")+"/"+this.pkgFileName+".js"; 353 if(_48.charAt(0)=="/"){ 354 _48=_48.slice(1); 355 } 356 ok=this.loadPath(_48,((!_46)?_44:null)); 357 if(ok){ 358 break; 359 } 360 } 361 } 362 if((!ok)&&(!_46)){ 363 dojo.raise("Could not load '"+_44+"'; last tried '"+_48+"'"); 364 } 365 } 366 if(!_46){ 367 _47=this.findModule(_44,false); 368 if(!_47){ 369 dojo.raise("symbol '"+_44+"' is not defined after loading '"+_48+"'"); 370 } 371 } 372 return _47; 373 }; 374 dojo.hostenv.startPackage=function(_50){ 375 var _51=_50.split(/\./); 376 if(_51[_51.length-1]=="*"){ 377 _51.pop(); 378 } 379 return dojo.evalObjPath(_51.join("."),true); 380 }; 381 dojo.hostenv.findModule=function(_52,_53){ 382 var lmn=(new String(_52)).toLowerCase(); 383 if(this.loaded_modules_[lmn]){ 384 return this.loaded_modules_[lmn]; 385 } 386 var _55=dojo.evalObjPath(_52); 387 if((_52)&&(typeof _55!="undefined")&&(_55)){ 388 this.loaded_modules_[lmn]=_55; 389 return _55; 390 } 391 if(_53){ 392 dojo.raise("no loaded module named '"+_52+"'"); 393 } 394 return null; 395 }; 396 if(typeof window=="undefined"){ 397 dojo.raise("no window object"); 398 } 399 (function(){ 400 if(djConfig.allowQueryConfig){ 401 var _56=document.location.toString(); 402 var _57=_56.split("?",2); 403 if(_57.length>1){ 404 var _58=_57[1]; 405 var _59=_58.split("&"); 406 for(var x in _59){ 407 var sp=_59[x].split("="); 408 if((sp[0].length>9)&&(sp[0].substr(0,9)=="djConfig.")){ 409 var opt=sp[0].substr(9); 410 try{ 411 djConfig[opt]=eval(sp[1]); 412 } 413 catch(e){ 414 djConfig[opt]=sp[1]; 415 } 416 } 417 } 418 } 419 } 420 if(((djConfig["baseScriptUri"]=="")||(djConfig["baseRelativePath"]==""))&&(document&&document.getElementsByTagName)){ 421 var _5d=document.getElementsByTagName("script"); 422 var _5e=/(__package__|dojo)\.js([\?\.]|$)/i; 423 for(var i=0;i<_5d.length;i++){ 424 var src=_5d[i].getAttribute("src"); 425 if(!src){ 426 continue; 427 } 428 var m=src.match(_5e); 429 if(m){ 430 root=src.substring(0,m.index); 431 if(!this["djConfig"]){ 432 djConfig={}; 433 } 434 if(djConfig["baseScriptUri"]==""){ 435 djConfig["baseScriptUri"]=root; 436 } 437 if(djConfig["baseRelativePath"]==""){ 438 djConfig["baseRelativePath"]=root; 439 } 440 break; 441 } 442 } 443 } 444 var dr=dojo.render; 445 var drh=dojo.render.html; 446 var dua=drh.UA=navigator.userAgent; 447 var dav=drh.AV=navigator.appVersion; 448 var t=true; 449 var f=false; 450 drh.capable=t; 451 drh.support.builtin=t; 452 dr.ver=parseFloat(drh.AV); 453 dr.os.mac=dav.indexOf("Macintosh")>=0; 454 dr.os.win=dav.indexOf("Windows")>=0; 455 dr.os.linux=dav.indexOf("X11")>=0; 456 drh.opera=dua.indexOf("Opera")>=0; 457 drh.khtml=(dav.indexOf("Konqueror")>=0)||(dav.indexOf("Safari")>=0); 458 drh.safari=dav.indexOf("Safari")>=0; 459 var _68=dua.indexOf("Gecko"); 460 drh.mozilla=drh.moz=(_68>=0)&&(!drh.khtml); 461 if(drh.mozilla){ 462 drh.geckoVersion=dua.substring(_68+6,_68+14); 463 } 464 drh.ie=(document.all)&&(!drh.opera); 465 drh.ie50=drh.ie&&dav.indexOf("MSIE 5.0")>=0; 466 drh.ie55=drh.ie&&dav.indexOf("MSIE 5.5")>=0; 467 drh.ie60=drh.ie&&dav.indexOf("MSIE 6.0")>=0; 468 dr.vml.capable=drh.ie; 469 dr.svg.capable=f; 470 dr.svg.support.plugin=f; 471 dr.svg.support.builtin=f; 472 dr.svg.adobe=f; 473 if(document.implementation&&document.implementation.hasFeature&&document.implementation.hasFeature("org.w3c.dom.svg","1.0")){ 474 dr.svg.capable=t; 475 dr.svg.support.builtin=t; 476 dr.svg.support.plugin=f; 477 dr.svg.adobe=f; 478 }else{ 479 if(navigator.mimeTypes&&navigator.mimeTypes.length>0){ 480 var _69=navigator.mimeTypes["image/svg+xml"]||navigator.mimeTypes["image/svg"]||navigator.mimeTypes["image/svg-xml"]; 481 if(_69){ 482 dr.svg.adobe=_69&&_69.enabledPlugin&&_69.enabledPlugin.description&&(_69.enabledPlugin.description.indexOf("Adobe")>-1); 483 if(dr.svg.adobe){ 484 dr.svg.capable=t; 485 dr.svg.support.plugin=t; 486 } 487 } 488 }else{ 489 if(drh.ie&&dr.os.win){ 490 var _69=f; 491 try{ 492 var _6a=new ActiveXObject("Adobe.SVGCtl"); 493 _69=t; 494 } 495 catch(e){ 496 } 497 if(_69){ 498 dr.svg.capable=t; 499 dr.svg.support.plugin=t; 500 dr.svg.adobe=t; 501 } 502 }else{ 503 dr.svg.capable=f; 504 dr.svg.support.plugin=f; 505 dr.svg.adobe=f; 506 } 507 } 508 } 509 })(); 510 dojo.hostenv.startPackage("dojo.hostenv"); 511 dojo.hostenv.name_="browser"; 512 dojo.hostenv.searchIds=[]; 513 var DJ_XMLHTTP_PROGIDS=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"]; 514 dojo.hostenv.getXmlhttpObject=function(){ 515 var _6b=null; 516 var _6c=null; 517 try{ 518 _6b=new XMLHttpRequest(); 519 } 520 catch(e){ 521 } 522 if(!_6b){ 523 for(var i=0;i<3;++i){ 524 var _6e=DJ_XMLHTTP_PROGIDS[i]; 525 try{ 526 _6b=new ActiveXObject(_6e); 527 } 528 catch(e){ 529 _6c=e; 530 } 531 if(_6b){ 532 DJ_XMLHTTP_PROGIDS=[_6e]; 533 break; 534 } 535 } 536 } 537 if(!_6b){ 538 return dojo.raise("XMLHTTP not available",_6c); 539 } 540 return _6b; 541 }; 542 dojo.hostenv.getText=function(uri,_70,_71){ 543 var _72=this.getXmlhttpObject(); 544 if(_70){ 545 _72.onreadystatechange=function(){ 546 if((4==_72.readyState)&&(_72["status"])){ 547 if(_72.status==200){ 548 _70(_72.responseText); 549 } 550 } 551 }; 552 } 553 _72.open("GET",uri,_70?true:false); 554 _72.send(null); 555 if(_70){ 556 return null; 557 } 558 return _72.responseText; 559 }; 560 dojo.hostenv.defaultDebugContainerId="dojoDebug"; 561 dojo.hostenv._println_buffer=[]; 562 dojo.hostenv._println_safe=false; 563 dojo.hostenv.println=function(_73){ 564 if(!dojo.hostenv._println_safe){ 565 dojo.hostenv._println_buffer.push(_73); 566 }else{ 567 try{ 568 var _74=document.getElementById(djConfig.debugContainerId?djConfig.debugContainerId:dojo.hostenv.defaultDebugContainerId); 569 if(!_74){ 570 _74=document.getElementsByTagName("body")[0]||document.body; 571 } 572 var div=document.createElement("div"); 573 div.appendChild(document.createTextNode(_73)); 574 _74.appendChild(div); 575 } 576 catch(e){ 577 try{ 578 document.write("<div>"+_73+"</div>"); 579 } 580 catch(e2){ 581 window.status=_73; 582 } 583 } 584 } 585 }; 586 dojo.addOnLoad(function(){ 587 dojo.hostenv._println_safe=true; 588 while(dojo.hostenv._println_buffer.length>0){ 589 dojo.hostenv.println(dojo.hostenv._println_buffer.shift()); 590 } 591 }); 592 function dj_addNodeEvtHdlr(_76,_77,fp,_79){ 593 var _7a=_76["on"+_77]||function(){ 594 }; 595 _76["on"+_77]=function(){ 596 fp.apply(_76,arguments); 597 _7a.apply(_76,arguments); 598 }; 599 return true; 600 } 601 dj_addNodeEvtHdlr(window,"load",function(){ 602 if(dojo.render.html.ie){ 603 dojo.hostenv.makeWidgets(); 604 } 605 dojo.hostenv.modulesLoaded(); 606 }); 607 dojo.hostenv.makeWidgets=function(){ 608 var _7b=[]; 609 if(djConfig.searchIds&&djConfig.searchIds.length>0){ 610 _7b=_7b.concat(djConfig.searchIds); 611 } 612 if(dojo.hostenv.searchIds&&dojo.hostenv.searchIds.length>0){ 613 _7b=_7b.concat(dojo.hostenv.searchIds); 614 } 615 if((djConfig.parseWidgets)||(_7b.length>0)){ 616 if(dojo.evalObjPath("dojo.widget.Parse")){ 617 try{ 618 var _7c=new dojo.xml.Parse(); 619 if(_7b.length>0){ 620 for(var x=0;x<_7b.length;x++){ 621 var _7e=document.getElementById(_7b[x]); 622 if(!_7e){ 623 continue; 624 } 625 var _7f=_7c.parseElement(_7e,null,true); 626 dojo.widget.getParser().createComponents(_7f); 627 } 628 }else{ 629 if(djConfig.parseWidgets){ 630 var _7f=_7c.parseElement(document.getElementsByTagName("body")[0]||document.body,null,true); 631 dojo.widget.getParser().createComponents(_7f); 632 } 633 } 634 } 635 catch(e){ 636 dojo.debug("auto-build-widgets error:",e); 637 } 638 } 639 } 640 }; 641 dojo.hostenv.modulesLoadedListeners.push(function(){ 642 if(!dojo.render.html.ie){ 643 dojo.hostenv.makeWidgets(); 644 } 645 }); 646 try{ 647 if(dojo.render.html.ie){ 648 document.write("<style>v:*{ behavior:url(#default#VML); }</style>"); 649 document.write("<xml:namespace ns=\"urn:schemas-microsoft-com:vml\" prefix=\"v\"/>"); 650 } 651 } 652 catch(e){ 653 } 654 dojo.hostenv.writeIncludes=function(){ 655 }; 656 dojo.hostenv.byId=dojo.byId=function(id,doc){ 657 if(typeof id=="string"||id instanceof String){ 658 if(!doc){ 659 doc=document; 660 } 661 return doc.getElementById(id); 662 } 663 return id; 664 }; 665 dojo.hostenv.byIdArray=dojo.byIdArray=function(){ 666 var ids=[]; 667 for(var i=0;i<arguments.length;i++){ 668 if((arguments[i] instanceof Array)||(typeof arguments[i]=="array")){ 669 for(var j=0;j<arguments[i].length;j++){ 670 ids=ids.concat(dojo.hostenv.byIdArray(arguments[i][j])); 671 } 672 }else{ 673 ids.push(dojo.hostenv.byId(arguments[i])); 674 } 675 } 676 return ids; 677 }; 678 dojo.hostenv.conditionalLoadModule=function(_85){ 679 var _86=_85["common"]||[]; 680 var _87=(_85[dojo.hostenv.name_])?_86.concat(_85[dojo.hostenv.name_]||[]):_86.concat(_85["default"]||[]); 681 for(var x=0;x<_87.length;x++){ 682 var _89=_87[x]; 683 if(_89.constructor==Array){ 684 dojo.hostenv.loadModule.apply(dojo.hostenv,_89); 685 }else{ 686 dojo.hostenv.loadModule(_89); 687 } 688 } 689 }; 690 dojo.hostenv.require=dojo.hostenv.loadModule; 691 dojo.require=function(){ 692 dojo.hostenv.loadModule.apply(dojo.hostenv,arguments); 693 }; 694 dojo.requireAfter=dojo.require; 695 dojo.requireIf=function(){ 696 if((arguments[0]===true)||(arguments[0]=="common")||(dojo.render[arguments[0]].capable)){ 697 var _8a=[]; 698 for(var i=1;i<arguments.length;i++){ 699 _8a.push(arguments[i]); 700 } 701 dojo.require.apply(dojo,_8a); 702 } 703 }; 704 dojo.requireAfterIf=dojo.requireIf; 705 dojo.conditionalRequire=dojo.requireIf; 706 dojo.kwCompoundRequire=function(){ 707 dojo.hostenv.conditionalLoadModule.apply(dojo.hostenv,arguments); 708 }; 709 dojo.hostenv.provide=dojo.hostenv.startPackage; 710 dojo.provide=function(){ 711 return dojo.hostenv.startPackage.apply(dojo.hostenv,arguments); 712 }; 713 dojo.setModulePrefix=function(_8c,_8d){ 714 return dojo.hostenv.setModulePrefix(_8c,_8d); 715 }; 716 dojo.profile={start:function(){ 717 },end:function(){ 718 },dump:function(){ 719 }}; 720 dojo.exists=function(obj,_8f){ 721 var p=_8f.split("."); 722 for(var i=0;i<p.length;i++){ 723 if(!(obj[p[i]])){ 724 return false; 725 } 726 obj=obj[p[i]]; 727 } 728 return true; 729 }; 730 dojo.provide("dojo.lang"); 731 dojo.provide("dojo.AdapterRegistry"); 732 dojo.provide("dojo.lang.Lang"); 733 dojo.lang.mixin=function(obj,_93){ 734 var _94={}; 735 for(var x in _93){ 736 if(typeof _94[x]=="undefined"||_94[x]!=_93[x]){ 737 obj[x]=_93[x]; 738 } 739 } 740 if(dojo.render.html.ie&&dojo.lang.isFunction(_93["toString"])&&_93["toString"]!=obj["toString"]){ 741 obj.toString=_93.toString; 742 } 743 return obj; 744 }; 745 dojo.lang.extend=function(_96,_97){ 746 this.mixin(_96.prototype,_97); 747 }; 748 dojo.lang.extendPrototype=function(obj,_99){ 749 this.extend(obj.constructor,_99); 750 }; 751 dojo.lang.anonCtr=0; 752 dojo.lang.anon={}; 753 dojo.lang.nameAnonFunc=function(_9a,_9b){ 754 var nso=(_9b||dojo.lang.anon); 755 if((dj_global["djConfig"])&&(djConfig["slowAnonFuncLookups"]==true)){ 756 for(var x in nso){ 757 if(nso[x]===_9a){ 758 return x; 759 } 760 } 761 } 762 var ret="__"+dojo.lang.anonCtr++; 763 while(typeof nso[ret]!="undefined"){ 764 ret="__"+dojo.lang.anonCtr++; 765 } 766 nso[ret]=_9a; 767 return ret; 768 }; 769 dojo.lang.hitch=function(_9f,_a0){ 770 if(dojo.lang.isString(_a0)){ 771 var fcn=_9f[_a0]; 772 }else{ 773 var fcn=_a0; 774 } 775 return function(){ 776 return fcn.apply(_9f,arguments); 777 }; 778 }; 779 dojo.lang.forward=function(_a2){ 780 return function(){ 781 return this[_a2].apply(this,arguments); 782 }; 783 }; 784 dojo.lang.curry=function(ns,_a4){ 785 var _a5=[]; 786 ns=ns||dj_global; 787 if(dojo.lang.isString(_a4)){ 788 _a4=ns[_a4]; 789 } 790 for(var x=2;x<arguments.length;x++){ 791 _a5.push(arguments[x]); 792 } 793 var _a7=_a4.length-_a5.length; 794 function gather(_a8,_a9,_aa){ 795 var _ab=_aa; 796 var _ac=_a9.slice(0); 797 for(var x=0;x<_a8.length;x++){ 798 _ac.push(_a8[x]); 799 } 800 _aa=_aa-_a8.length; 801 if(_aa<=0){ 802 var res=_a4.apply(ns,_ac); 803 _aa=_ab; 804 return res; 805 }else{ 806 return function(){ 807 return gather(arguments,_ac,_aa); 808 }; 809 } 810 } 811 return gather([],_a5,_a7); 812 }; 813 dojo.lang.curryArguments=function(ns,_b0,_b1,_b2){ 814 var _b3=[]; 815 var x=_b2||0; 816 for(x=_b2;x<_b1.length;x++){ 817 _b3.push(_b1[x]); 818 } 819 return dojo.lang.curry.apply(dojo.lang,[ns,_b0].concat(_b3)); 820 }; 821 dojo.lang.setTimeout=function(_b5,_b6){ 822 var _b7=window,argsStart=2; 823 if(!dojo.lang.isFunction(_b5)){ 824 _b7=_b5; 825 _b5=_b6; 826 _b6=arguments[2]; 827 argsStart++; 828 } 829 if(dojo.lang.isString(_b5)){ 830 _b5=_b7[_b5]; 831 } 832 var _b8=[]; 833 for(var i=argsStart;i<arguments.length;i++){ 834 _b8.push(arguments[i]); 835 } 836 return setTimeout(function(){ 837 _b5.apply(_b7,_b8); 838 },_b6); 839 }; 840 dojo.lang.isObject=function(wh){ 841 return typeof wh=="object"||dojo.lang.isArray(wh)||dojo.lang.isFunction(wh); 842 }; 843 dojo.lang.isArray=function(wh){ 844 return (wh instanceof Array||typeof wh=="array"); 845 }; 846 dojo.lang.isArrayLike=function(wh){ 847 if(dojo.lang.isString(wh)){ 848 return false; 849 } 850 if(dojo.lang.isArray(wh)){ 851 return true; 852 } 853 if(typeof wh!="undefined"&&wh&&dojo.lang.isNumber(wh.length)&&isFinite(wh.length)){ 854 return true; 855 } 856 return false; 857 }; 858 dojo.lang.isFunction=function(wh){ 859 return (wh instanceof Function||typeof wh=="function"); 860 }; 861 dojo.lang.isString=function(wh){ 862 return (wh instanceof String||typeof wh=="string"); 863 }; 864 dojo.lang.isAlien=function(wh){ 865 return !dojo.lang.isFunction()&&/\{\s*\[native code\]\s*\}/.test(String(wh)); 866 }; 867 dojo.lang.isBoolean=function(wh){ 868 return (wh instanceof Boolean||typeof wh=="boolean"); 869 }; 870 dojo.lang.isNumber=function(wh){ 871 return (wh instanceof Number||typeof wh=="number"); 872 }; 873 dojo.lang.isUndefined=function(wh){ 874 return ((wh==undefined)&&(typeof wh=="undefined")); 875 }; 876 dojo.lang.whatAmI=function(wh){ 877 try{ 878 if(dojo.lang.isArray(wh)){ 879 return "array"; 880 } 881 if(dojo.lang.isFunction(wh)){ 882 return "function"; 883 } 884 if(dojo.lang.isString(wh)){ 885 return "string"; 886 } 887 if(dojo.lang.isNumber(wh)){ 888 return "number"; 889 } 890 if(dojo.lang.isBoolean(wh)){ 891 return "boolean"; 892 } 893 if(dojo.lang.isAlien(wh)){ 894 return "alien"; 895 } 896 if(dojo.lang.isUndefined(wh)){ 897 return "undefined"; 898 } 899 for(var _c4 in dojo.lang.whatAmI.custom){ 900 if(dojo.lang.whatAmI.custom[_c4](wh)){ 901 return _c4; 902 } 903 } 904 if(dojo.lang.isObject(wh)){ 905 return "object"; 906 } 907 } 908 catch(E){ 909 } 910 return "unknown"; 911 }; 912 dojo.lang.whatAmI.custom={}; 913 dojo.lang.find=function(arr,val,_c7){ 914 if(!dojo.lang.isArrayLike(arr)&&dojo.lang.isArrayLike(val)){ 915 var a=arr; 916 arr=val; 917 val=a; 918 } 919 var _c9=dojo.lang.isString(arr); 920 if(_c9){ 921 arr=arr.split(""); 922 } 923 if(_c7){ 924 for(var i=0;i<arr.length;++i){ 925 if(arr[i]===val){ 926 return i; 927 } 928 } 929 }else{ 930 for(var i=0;i<arr.length;++i){ 931 if(arr[i]==val){ 932 return i; 933 } 934 } 935 } 936 return -1; 937 }; 938 dojo.lang.indexOf=dojo.lang.find; 939 dojo.lang.findLast=function(arr,val,_cd){ 940 if(!dojo.lang.isArrayLike(arr)&&dojo.lang.isArrayLike(val)){ 941 var a=arr; 942 arr=val; 943 val=a; 944 } 945 var _cf=dojo.lang.isString(arr); 946 if(_cf){ 947 arr=arr.split(""); 948 } 949 if(_cd){ 950 for(var i=arr.length-1;i>=0;i--){ 951 if(arr[i]===val){ 952 return i; 953 } 954 } 955 }else{ 956 for(var i=arr.length-1;i>=0;i--){ 957 if(arr[i]==val){ 958 return i; 959 } 960 } 961 } 962 return -1; 963 }; 964 dojo.lang.lastIndexOf=dojo.lang.findLast; 965 dojo.lang.inArray=function(arr,val){ 966 return dojo.lang.find(arr,val)>-1; 967 }; 968 dojo.lang.getNameInObj=function(ns,_d4){ 969 if(!ns){ 970 ns=dj_global; 971 } 972 for(var x in ns){ 973 if(ns[x]===_d4){ 974 return new String(x); 975 } 976 } 977 return null; 978 }; 979 dojo.lang.has=function(obj,_d7){ 980 return (typeof obj[_d7]!=="undefined"); 981 }; 982 dojo.lang.isEmpty=function(obj){ 983 if(dojo.lang.isObject(obj)){ 984 var tmp={}; 985 var _da=0; 986 for(var x in obj){ 987 if(obj[x]&&(!tmp[x])){ 988 _da++; 989 break; 990 } 991 } 992 return (_da==0); 993 }else{ 994 if(dojo.lang.isArrayLike(obj)||dojo.lang.isString(obj)){ 995 return obj.length==0; 996 } 997 } 998 }; 999 dojo.lang.forEach=function(arr,_dd,_de){ 1000 var _df=dojo.lang.isString(arr); 1001 if(_df){ 1002 arr=arr.split(""); 1003 } 1004 var il=arr.length; 1005 for(var i=0;i<((_de)?il:arr.length);i++){ 1006 if(_dd(arr[i],i,arr)=="break"){ 1007 break; 1008 } 1009 } 1010 }; 1011 dojo.lang.map=function(arr,obj,_e4){ 1012 var _e5=dojo.lang.isString(arr); 1013 if(_e5){ 1014 arr=arr.split(""); 1015 } 1016 if(dojo.lang.isFunction(obj)&&(!_e4)){ 1017 _e4=obj; 1018 obj=dj_global; 1019 }else{ 1020 if(dojo.lang.isFunction(obj)&&_e4){ 1021 var _e6=obj; 1022 obj=_e4; 1023 _e4=_e6; 1024 } 1025 } 1026 if(Array.map){ 1027 var _e7=Array.map(arr,_e4,obj); 1028 }else{ 1029 var _e7=[]; 1030 for(var i=0;i<arr.length;++i){ 1031 _e7.push(_e4.call(obj,arr[i])); 1032 } 1033 } 1034 if(_e5){ 1035 return _e7.join(""); 1036 }else{ 1037 return _e7; 1038 } 1039 }; 1040 dojo.lang.tryThese=function(){ 1041 for(var x=0;x<arguments.length;x++){ 1042 try{ 1043 if(typeof arguments[x]=="function"){ 1044 var ret=(arguments[x]()); 1045 if(ret){ 1046 return ret; 1047 } 1048 } 1049 } 1050 catch(e){ 1051 dojo.debug(e); 1052 } 1053 } 1054 }; 1055 dojo.lang.delayThese=function(_eb,cb,_ed,_ee){ 1056 if(!_eb.length){ 1057 if(typeof _ee=="function"){ 1058 _ee(); 1059 } 1060 return; 1061 } 1062 if((typeof _ed=="undefined")&&(typeof cb=="number")){ 1063 _ed=cb; 1064 cb=function(){ 1065 }; 1066 }else{ 1067 if(!cb){ 1068 cb=function(){ 1069 }; 1070 if(!_ed){ 1071 _ed=0; 1072 } 1073 } 1074 } 1075 setTimeout(function(){ 1076 (_eb.shift())(); 1077 cb(); 1078 dojo.lang.delayThese(_eb,cb,_ed,_ee); 1079 },_ed); 1080 }; 1081 dojo.lang.shallowCopy=function(obj){ 1082 var ret={},key; 1083 for(key in obj){ 1084 if(dojo.lang.isUndefined(ret[key])){ 1085 ret[key]=obj[key]; 1086 } 1087 } 1088 return ret; 1089 }; 1090 dojo.lang.every=function(arr,_f2,_f3){ 1091 var _f4=dojo.lang.isString(arr); 1092 if(_f4){ 1093 arr=arr.split(""); 1094 } 1095 if(Array.every){ 1096 return Array.every(arr,_f2,_f3); 1097 }else{ 1098 if(!_f3){ 1099 if(arguments.length>=3){ 1100 dojo.raise("thisObject doesn't exist!"); 1101 } 1102 _f3=dj_global; 1103 } 1104 for(var i=0;i<arr.length;i++){ 1105 if(!_f2.call(_f3,arr[i],i,arr)){ 1106 return false; 1107 } 1108 } 1109 return true; 1110 } 1111 }; 1112 dojo.lang.some=function(arr,_f7,_f8){ 1113 var _f9=dojo.lang.isString(arr); 1114 if(_f9){ 1115 arr=arr.split(""); 1116 } 1117 if(Array.some){ 1118 return Array.some(arr,_f7,_f8); 1119 }else{ 1120 if(!_f8){ 1121 if(arguments.length>=3){ 1122 dojo.raise("thisObject doesn't exist!"); 1123 } 1124 _f8=dj_global; 1125 } 1126 for(var i=0;i<arr.length;i++){ 1127 if(_f7.call(_f8,arr[i],i,arr)){ 1128 return true; 1129 } 1130 } 1131 return false; 1132 } 1133 }; 1134 dojo.lang.filter=function(arr,_fc,_fd){ 1135 var _fe=dojo.lang.isString(arr); 1136 if(_fe){ 1137 arr=arr.split(""); 1138 } 1139 if(Array.filter){ 1140 var _ff=Array.filter(arr,_fc,_fd); 1141 }else{ 1142 if(!_fd){ 1143 if(arguments.length>=3){ 1144 dojo.raise("thisObject doesn't exist!"); 1145 } 1146 _fd=dj_global; 1147 } 1148 var _ff=[]; 1149 for(var i=0;i<arr.length;i++){ 1150 if(_fc.call(_fd,arr[i],i,arr)){ 1151 _ff.push(arr[i]); 1152 } 1153 } 1154 } 1155 if(_fe){ 1156 return _ff.join(""); 1157 }else{ 1158 return _ff; 1159 } 1160 }; 1161 dojo.AdapterRegistry=function(){ 1162 this.pairs=[]; 1163 }; 1164 dojo.lang.extend(dojo.AdapterRegistry,{register:function(name,_102,wrap,_104){ 1165 if(_104){ 1166 this.pairs.unshift([name,_102,wrap]); 1167 }else{ 1168 this.pairs.push([name,_102,wrap]); 1169 } 1170 },match:function(){ 1171 for(var i=0;i<this.pairs.length;i++){ 1172 var pair=this.pairs[i]; 1173 if(pair[1].apply(this,arguments)){ 1174 return pair[2].apply(this,arguments); 1175 } 1176 } 1177 throw new Error("No match found"); 1178 },unregister:function(name){ 1179 for(var i=0;i<this.pairs.length;i++){ 1180 var pair=this.pairs[i]; 1181 if(pair[0]==name){ 1182 this.pairs.splice(i,1); 1183 return true; 1184 } 1185 } 1186 return false; 1187 }}); 1188 dojo.lang.reprRegistry=new dojo.AdapterRegistry(); 1189 dojo.lang.registerRepr=function(name,_10b,wrap,_10d){ 1190 dojo.lang.reprRegistry.register(name,_10b,wrap,_10d); 1191 }; 1192 dojo.lang.repr=function(obj){ 1193 if(typeof (obj)=="undefined"){ 1194 return "undefined"; 1195 }else{ 1196 if(obj===null){ 1197 return "null"; 1198 } 1199 } 1200 try{ 1201 if(typeof (obj["__repr__"])=="function"){ 1202 return obj["__repr__"](); 1203 }else{ 1204 if((typeof (obj["repr"])=="function")&&(obj.repr!=arguments.callee)){ 1205 return obj["repr"](); 1206 } 1207 } 1208 return dojo.lang.reprRegistry.match(obj); 1209 } 1210 catch(e){ 1211 if(typeof (obj.NAME)=="string"&&(obj.toString==Function.prototype.toString||obj.toString==Object.prototype.toString)){ 1212 return o.NAME; 1213 } 1214 } 1215 if(typeof (obj)=="function"){ 1216 obj=(obj+"").replace(/^\s+/,""); 1217 var idx=obj.indexOf("{"); 1218 if(idx!=-1){ 1219 obj=obj.substr(0,idx)+"{...}"; 1220 } 1221 } 1222 return obj+""; 1223 }; 1224 dojo.lang.reprArrayLike=function(arr){ 1225 try{ 1226 var na=dojo.lang.map(arr,dojo.lang.repr); 1227 return "["+na.join(", ")+"]"; 1228 } 1229 catch(e){ 1230 } 1231 }; 1232 dojo.lang.reprString=function(str){ 1233 return ("\""+str.replace(/(["\\])/g,"\\$1")+"\"").replace(/[\f]/g,"\\f").replace(/[\b]/g,"\\b").replace(/[\n]/g,"\\n").replace(/[\t]/g,"\\t").replace(/[\r]/g,"\\r"); 1234 }; 1235 dojo.lang.reprNumber=function(num){ 1236 return num+""; 1237 }; 1238 (function(){ 1239 var m=dojo.lang; 1240 m.registerRepr("arrayLike",m.isArrayLike,m.reprArrayLike); 1241 m.registerRepr("string",m.isString,m.reprString); 1242 m.registerRepr("numbers",m.isNumber,m.reprNumber); 1243 m.registerRepr("boolean",m.isBoolean,m.reprNumber); 1244 })(); 1245 dojo.lang.unnest=function(){ 1246 var out=[]; 1247 for(var i=0;i<arguments.length;i++){ 1248 if(dojo.lang.isArrayLike(arguments[i])){ 1249 var add=dojo.lang.unnest.apply(this,arguments[i]); 1250 out=out.concat(add); 1251 }else{ 1252 out.push(arguments[i]); 1253 } 1254 } 1255 return out; 1256 }; 1257 dojo.lang.firstValued=function(){ 1258 for(var i=0;i<arguments.length;i++){ 1259 if(typeof arguments[i]!="undefined"){ 1260 return arguments[i]; 1261 } 1262 } 1263 return undefined; 1264 }; 1265 dojo.lang.toArray=function(_119,_11a){ 1266 var _11b=[]; 1267 for(var i=_11a||0;i<_119.length;i++){ 1268 _11b.push(_119[i]); 1269 } 1270 return _11b; 1271 }; 1272 dojo.provide("dojo.string"); 1273 dojo.require("dojo.lang"); 1274 dojo.string.trim=function(str,wh){ 1275 if(!dojo.lang.isString(str)){ 1276 return str; 1277 } 1278 if(!str.length){ 1279 return str; 1280 } 1281 if(wh>0){ 1282 return str.replace(/^\s+/,""); 1283 }else{ 1284 if(wh<0){ 1285 return str.replace(/\s+$/,""); 1286 }else{ 1287 return str.replace(/^\s+|\s+$/g,""); 1288 } 1289 } 1290 }; 1291 dojo.string.trimStart=function(str){ 1292 return dojo.string.trim(str,1); 1293 }; 1294 dojo.string.trimEnd=function(str){ 1295 return dojo.string.trim(str,-1); 1296 }; 1297 dojo.string.paramString=function(str,_122,_123){ 1298 for(var name in _122){ 1299 var re=new RegExp("\\%\\{"+name+"\\}","g"); 1300 str=str.replace(re,_122[name]); 1301 } 1302 if(_123){ 1303 str=str.replace(/%\{([^\}\s]+)\}/g,""); 1304 } 1305 return str; 1306 }; 1307 dojo.string.capitalize=function(str){ 1308 if(!dojo.lang.isString(str)){ 1309 return ""; 1310 } 1311 if(arguments.length==0){ 1312 str=this; 1313 } 1314 var _127=str.split(" "); 1315 var _128=""; 1316 var len=_127.length; 1317 for(var i=0;i<len;i++){ 1318 var word=_127[i]; 1319 word=word.charAt(0).toUpperCase()+word.substring(1,word.length); 1320 _128+=word; 1321 if(i<len-1){ 1322 _128+=" "; 1323 } 1324 } 1325 return new String(_128); 1326 }; 1327 dojo.string.isBlank=function(str){ 1328 if(!dojo.lang.isString(str)){ 1329 return true; 1330 } 1331 return (dojo.string.trim(str).length==0); 1332 }; 1333 dojo.string.encodeAscii=function(str){ 1334 if(!dojo.lang.isString(str)){ 1335 return str; 1336 } 1337 var ret=""; 1338 var _12f=escape(str); 1339 var _130,re=/%u([0-9A-F]{4})/i; 1340 while((_130=_12f.match(re))){ 1341 var num=Number("0x"+_130[1]); 1342 var _132=escape("&#"+num+";"); 1343 ret+=_12f.substring(0,_130.index)+_132; 1344 _12f=_12f.substring(_130.index+_130[0].length); 1345 } 1346 ret+=_12f.replace(/\+/g,"%2B"); 1347 return ret; 1348 }; 1349 dojo.string.summary=function(str,len){ 1350 if(!len||str.length<=len){ 1351 return str; 1352 }else{ 1353 return str.substring(0,len).replace(/\.+$/,"")+"..."; 1354 } 1355 }; 1356 dojo.string.escape=function(type,str){ 1357 var args=[]; 1358 for(var i=1;i<arguments.length;i++){ 1359 args.push(arguments[i]); 1360 } 1361 switch(type.toLowerCase()){ 1362 case "xml": 1363 case "html": 1364 case "xhtml": 1365 return dojo.string.escapeXml.apply(this,args); 1366 case "sql": 1367 return dojo.string.escapeSql.apply(this,args); 1368 case "regexp": 1369 case "regex": 1370 return dojo.string.escapeRegExp.apply(this,args); 1371 case "javascript": 1372 case "jscript": 1373 case "js": 1374 return dojo.string.escapeJavaScript.apply(this,args); 1375 case "ascii": 1376 return dojo.string.encodeAscii.apply(this,args); 1377 default: 1378 return str; 1379 } 1380 }; 1381 dojo.string.escapeXml=function(str,_13a){ 1382 str=str.replace(/&/gm,"&").replace(/</gm,"<").replace(/>/gm,">").replace(/"/gm,"""); 1383 if(!_13a){ 1384 str=str.replace(/'/gm,"'"); 1385 } 1386 return str; 1387 }; 1388 dojo.string.escapeSql=function(str){ 1389 return str.replace(/'/gm,"''"); 1390 }; 1391 dojo.string.escapeRegExp=function(str){ 1392 return str.replace(/\\/gm,"\\\\").replace(/([\f\b\n\t\r])/gm,"\\$1"); 1393 }; 1394 dojo.string.escapeJavaScript=function(str){ 1395 return str.replace(/(["'\f\b\n\t\r])/gm,"\\$1"); 1396 }; 1397 dojo.string.repeat=function(str,_13f,_140){ 1398 var out=""; 1399 for(var i=0;i<_13f;i++){ 1400 out+=str; 1401 if(_140&&i<_13f-1){ 1402 out+=_140; 1403 } 1404 } 1405 return out; 1406 }; 1407 dojo.string.endsWith=function(str,end,_145){ 1408 if(_145){ 1409 str=str.toLowerCase(); 1410 end=end.toLowerCase(); 1411 } 1412 return str.lastIndexOf(end)==str.length-end.length; 1413 }; 1414 dojo.string.endsWithAny=function(str){ 1415 for(var i=1;i<arguments.length;i++){ 1416 if(dojo.string.endsWith(str,arguments[i])){ 1417 return true; 1418 } 1419 } 1420 return false; 1421 }; 1422 dojo.string.startsWith=function(str,_149,_14a){ 1423 if(_14a){ 1424 str=str.toLowerCase(); 1425 _149=_149.toLowerCase(); 1426 } 1427 return str.indexOf(_149)==0; 1428 }; 1429 dojo.string.startsWithAny=function(str){ 1430 for(var i=1;i<arguments.length;i++){ 1431 if(dojo.string.startsWith(str,arguments[i])){ 1432 return true; 1433 } 1434 } 1435 return false; 1436 }; 1437 dojo.string.has=function(str){ 1438 for(var i=1;i<arguments.length;i++){ 1439 if(str.indexOf(arguments[i]>-1)){ 1440 return true; 1441 } 1442 } 1443 return false; 1444 }; 1445 dojo.string.pad=function(str,len,c,dir){ 1446 var out=String(str); 1447 if(!c){ 1448 c="0"; 1449 } 1450 if(!dir){ 1451 dir=1; 1452 } 1453 while(out.length<len){ 1454 if(dir>0){ 1455 out=c+out; 1456 }else{ 1457 out+=c; 1458 } 1459 } 1460 return out; 1461 }; 1462 dojo.string.padLeft=function(str,len,c){ 1463 return dojo.string.pad(str,len,c,1); 1464 }; 1465 dojo.string.padRight=function(str,len,c){ 1466 return dojo.string.pad(str,len,c,-1); 1467 }; 1468 dojo.string.normalizeNewlines=function(text,_15b){ 1469 if(_15b=="\n"){ 1470 text=text.replace(/\r\n/g,"\n"); 1471 text=text.replace(/\r/g,"\n"); 1472 }else{ 1473 if(_15b=="\r"){ 1474 text=text.replace(/\r\n/g,"\r"); 1475 text=text.replace(/\n/g,"\r"); 1476 }else{ 1477 text=text.replace(/([^\r])\n/g,"$1\r\n"); 1478 text=text.replace(/\r([^\n])/g,"\r\n$1"); 1479 } 1480 } 1481 return text; 1482 }; 1483 dojo.string.splitEscaped=function(str,_15d){ 1484 var _15e=[]; 1485 for(var i=0,prevcomma=0;i<str.length;i++){ 1486 if(str.charAt(i)=="\\"){ 1487 i++; 1488 continue; 1489 } 1490 if(str.charAt(i)==_15d){ 1491 _15e.push(str.substring(prevcomma,i)); 1492 prevcomma=i+1; 1493 } 1494 } 1495 _15e.push(str.substr(prevcomma)); 1496 return _15e; 1497 }; 1498 dojo.string.addToPrototype=function(){ 1499 for(var _160 in dojo.string){ 1500 if(dojo.lang.isFunction(dojo.string[_160])){ 1501 var func=(function(){ 1502 var meth=_160; 1503 switch(meth){ 1504 case "addToPrototype": 1505 return null; 1506 break; 1507 case "escape": 1508 return function(type){ 1509 return dojo.string.escape(type,this); 1510 }; 1511 break; 1512 default: 1513 return function(){ 1514 var args=[this]; 1515 for(var i=0;i<arguments.length;i++){ 1516 args.push(arguments[i]); 1517 } 1518 dojo.debug(args); 1519 return dojo.string[meth].apply(dojo.string,args); 1520 }; 1521 } 1522 })(); 1523 if(func){ 1524 String.prototype[_160]=func; 1525 } 1526 } 1527 } 1528 }; 1529 dojo.provide("dojo.io.IO"); 1530 dojo.require("dojo.string"); 1531 dojo.io.transports=[]; 1532 dojo.io.hdlrFuncNames=["load","error"]; 1533 dojo.io.Request=function(url,_167,_168,_169){ 1534 if((arguments.length==1)&&(arguments[0].constructor==Object)){ 1535 this.fromKwArgs(arguments[0]); 1536 }else{ 1537 this.url=url; 1538 if(_167){ 1539 this.mimetype=_167; 1540 } 1541 if(_168){ 1542 this.transport=_168; 1543 } 1544 if(arguments.length>=4){ 1545 this.changeUrl=_169; 1546 } 1547 } 1548 }; 1549 dojo.lang.extend(dojo.io.Request,{url:"",mimetype:"text/plain",method:"GET",content:undefined,transport:undefined,changeUrl:undefined,formNode:undefined,sync:false,bindSuccess:false,useCache:false,preventCache:false,load:function(type,data,evt){ 1550 },error:function(type,_16e){ 1551 },handle:function(){ 1552 },abort:function(){ 1553 },fromKwArgs:function(_16f){ 1554 if(_16f["url"]){ 1555 _16f.url=_16f.url.toString(); 1556 } 1557 if(!_16f["method"]&&_16f["formNode"]&&_16f["formNode"].method){ 1558 _16f.method=_16f["formNode"].method; 1559 } 1560 if(!_16f["handle"]&&_16f["handler"]){ 1561 _16f.handle=_16f.handler; 1562 } 1563 if(!_16f["load"]&&_16f["loaded"]){ 1564 _16f.load=_16f.loaded; 1565 } 1566 if(!_16f["changeUrl"]&&_16f["changeURL"]){ 1567 _16f.changeUrl=_16f.changeURL; 1568 } 1569 _16f.encoding=dojo.lang.firstValued(_16f["encoding"],djConfig["bindEncoding"],""); 1570 _16f.sendTransport=dojo.lang.firstValued(_16f["sendTransport"],djConfig["ioSendTransport"],true); 1571 var _170=dojo.lang.isFunction; 1572 for(var x=0;x<dojo.io.hdlrFuncNames.length;x++){ 1573 var fn=dojo.io.hdlrFuncNames[x]; 1574 if(_170(_16f[fn])){ 1575 continue; 1576 } 1577 if(_170(_16f["handle"])){ 1578 _16f[fn]=_16f.handle; 1579 } 1580 } 1581 dojo.lang.mixin(this,_16f); 1582 }}); 1583 dojo.io.Error=function(msg,type,num){ 1584 this.message=msg; 1585 this.type=type||"unknown"; 1586 this.number=num||0; 1587 }; 1588 dojo.io.transports.addTransport=function(name){ 1589 this.push(name); 1590 this[name]=dojo.io[name]; 1591 }; 1592 dojo.io.bind=function(_177){ 1593 if(!(_177 instanceof dojo.io.Request)){ 1594 try{ 1595 _177=new dojo.io.Request(_177); 1596 } 1597 catch(e){ 1598 dojo.debug(e); 1599 } 1600 } 1601 var _178=""; 1602 if(_177["transport"]){ 1603 _178=_177["transport"]; 1604 if(!this[_178]){ 1605 return _177; 1606 } 1607 }else{ 1608 for(var x=0;x<dojo.io.transports.length;x++){ 1609 var tmp=dojo.io.transports[x]; 1610 if((this[tmp])&&(this[tmp].canHandle(_177))){ 1611 _178=tmp; 1612 } 1613 } 1614 if(_178==""){ 1615 return _177; 1616 } 1617 } 1618 this[_178].bind(_177); 1619 _177.bindSuccess=true; 1620 return _177; 1621 }; 1622 dojo.io.queueBind=function(_17b){ 1623 if(!(_17b instanceof dojo.io.Request)){ 1624 try{ 1625 _17b=new dojo.io.Request(_17b); 1626 } 1627 catch(e){ 1628 dojo.debug(e); 1629 } 1630 } 1631 var _17c=_17b.load; 1632 _17b.load=function(){ 1633 dojo.io._queueBindInFlight=false; 1634 var ret=_17c.apply(this,arguments); 1635 dojo.io._dispatchNextQueueBind(); 1636 return ret; 1637 }; 1638 var _17e=_17b.error; 1639 _17b.error=function(){ 1640 dojo.io._queueBindInFlight=false; 1641 var ret=_17e.apply(this,arguments); 1642 dojo.io._dispatchNextQueueBind(); 1643 return ret; 1644 }; 1645 dojo.io._bindQueue.push(_17b); 1646 dojo.io._dispatchNextQueueBind(); 1647 return _17b; 1648 }; 1649 dojo.io._dispatchNextQueueBind=function(){ 1650 if(!dojo.io._queueBindInFlight){ 1651 dojo.io._queueBindInFlight=true; 1652 dojo.io.bind(dojo.io._bindQueue.shift()); 1653 } 1654 }; 1655 dojo.io._bindQueue=[]; 1656 dojo.io._queueBindInFlight=false; 1657 dojo.io.argsFromMap=function(map,_181){ 1658 var _182=new Object(); 1659 var _183=""; 1660 var enc=/utf/i.test(_181||"")?encodeURIComponent:dojo.string.encodeAscii; 1661 for(var x in map){ 1662 if(!_182[x]){ 1663 _183+=enc(x)+"="+enc(map[x])+"&"; 1664 } 1665 } 1666 return _183; 1667 }; 1668 dojo.provide("dojo.dom"); 1669 dojo.require("dojo.lang"); 1670 dojo.dom.ELEMENT_NODE=1; 1671 dojo.dom.ATTRIBUTE_NODE=2; 1672 dojo.dom.TEXT_NODE=3; 1673 dojo.dom.CDATA_SECTION_NODE=4; 1674 dojo.dom.ENTITY_REFERENCE_NODE=5; 1675 dojo.dom.ENTITY_NODE=6; 1676 dojo.dom.PROCESSING_INSTRUCTION_NODE=7; 1677 dojo.dom.COMMENT_NODE=8; 1678 dojo.dom.DOCUMENT_NODE=9; 1679 dojo.dom.DOCUMENT_TYPE_NODE=10; 1680 dojo.dom.DOCUMENT_FRAGMENT_NODE=11; 1681 dojo.dom.NOTATION_NODE=12; 1682 dojo.dom.dojoml="http://www.dojotoolkit.org/2004/dojoml"; 1683 dojo.dom.xmlns={svg:"http://www.w3.org/2000/svg",smil:"http://www.w3.org/2001/SMIL20/",mml:"http://www.w3.org/1998/Math/MathML",cml:"http://www.xml-cml.org",xlink:"http://www.w3.org/1999/xlink",xhtml:"http://www.w3.org/1999/xhtml",xul:"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",xbl:"http://www.mozilla.org/xbl",fo:"http://www.w3.org/1999/XSL/Format",xsl:"http://www.w3.org/1999/XSL/Transform",xslt:"http://www.w3.org/1999/XSL/Transform",xi:"http://www.w3.org/2001/XInclude",xforms:"http://www.w3.org/2002/01/xforms",saxon:"http://icl.com/saxon",xalan:"http://xml.apache.org/xslt",xsd:"http://www.w3.org/2001/XMLSchema",dt:"http://www.w3.org/2001/XMLSchema-datatypes",xsi:"http://www.w3.org/2001/XMLSchema-instance",rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",rdfs:"http://www.w3.org/2000/01/rdf-schema#",dc:"http://purl.org/dc/elements/1.1/",dcq:"http://purl.org/dc/qualifiers/1.0","soap-env":"http://schemas.xmlsoap.org/soap/envelope/",wsdl:"http://schemas.xmlsoap.org/wsdl/",AdobeExtensions:"http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"}; 1684 dojo.dom.isNode=dojo.lang.isDomNode=function(wh){ 1685 if(typeof Element=="object"){ 1686 try{ 1687 return wh instanceof Element; 1688 } 1689 catch(E){ 1690 } 1691 }else{ 1692 return wh&&!isNaN(wh.nodeType); 1693 } 1694 }; 1695 dojo.lang.whatAmI.custom["node"]=dojo.dom.isNode; 1696 dojo.dom.getTagName=function(node){ 1697 var _188=node.tagName; 1698 if(_188.substr(0,5).toLowerCase()!="dojo:"){ 1699 if(_188.substr(0,4).toLowerCase()=="dojo"){ 1700 return "dojo:"+_188.substring(4).toLowerCase(); 1701 } 1702 var djt=node.getAttribute("dojoType")||node.getAttribute("dojotype"); 1703 if(djt){ 1704 return "dojo:"+djt.toLowerCase(); 1705 } 1706 if((node.getAttributeNS)&&(node.getAttributeNS(this.dojoml,"type"))){ 1707 return "dojo:"+node.getAttributeNS(this.dojoml,"type").toLowerCase(); 1708 } 1709 try{ 1710 djt=node.getAttribute("dojo:type"); 1711 } 1712 catch(e){ 1713 } 1714 if(djt){ 1715 return "dojo:"+djt.toLowerCase(); 1716 } 1717 if((!dj_global["djConfig"])||(!djConfig["ignoreClassNames"])){ 1718 var _18a=node.className||node.getAttribute("class"); 1719 if((_18a)&&(_18a.indexOf)&&(_18a.indexOf("dojo-")!=-1)){ 1720 var _18b=_18a.split(" "); 1721 for(var x=0;x<_18b.length;x++){ 1722 if((_18b[x].length>5)&&(_18b[x].indexOf("dojo-")>=0)){ 1723 return "dojo:"+_18b[x].substr(5).toLowerCase(); 1724 } 1725 } 1726 } 1727 } 1728 } 1729 return _188.toLowerCase(); 1730 }; 1731 dojo.dom.getUniqueId=function(){ 1732 do{ 1733 var id="dj_unique_"+(++arguments.callee._idIncrement); 1734 }while(document.getElementById(id)); 1735 return id; 1736 }; 1737 dojo.dom.getUniqueId._idIncrement=0; 1738 dojo.dom.firstElement=dojo.dom.getFirstChildElement=function(_18e,_18f){ 1739 var node=_18e.firstChild; 1740 while(node&&node.nodeType!=dojo.dom.ELEMENT_NODE){ 1741 node=node.nextSibling; 1742 } 1743 if(_18f&&node&&node.tagName&&node.tagName.toLowerCase()!=_18f.toLowerCase()){ 1744 node=dojo.dom.nextElement(node,_18f); 1745 } 1746 return node; 1747 }; 1748 dojo.dom.lastElement=dojo.dom.getLastChildElement=function(_191,_192){ 1749 var node=_191.lastChild; 1750 while(node&&node.nodeType!=dojo.dom.ELEMENT_NODE){ 1751 node=node.previousSibling; 1752 } 1753 if(_192&&node&&node.tagName&&node.tagName.toLowerCase()!=_192.toLowerCase()){ 1754 node=dojo.dom.prevElement(node,_192); 1755 } 1756 return node; 1757 }; 1758 dojo.dom.nextElement=dojo.dom.getNextSiblingElement=function(node,_195){ 1759 if(!node){ 1760 return null; 1761 } 1762 do{ 1763 node=node.nextSibling; 1764 }while(node&&node.nodeType!=dojo.dom.ELEMENT_NODE); 1765 if(node&&_195&&_195.toLowerCase()!=node.tagName.toLowerCase()){ 1766 return dojo.dom.nextElement(node,_195); 1767 } 1768 return node; 1769 }; 1770 dojo.dom.prevElement=dojo.dom.getPreviousSiblingElement=function(node,_197){ 1771 if(!node){ 1772 return null; 1773 } 1774 if(_197){ 1775 _197=_197.toLowerCase(); 1776 } 1777 do{ 1778 node=node.previousSibling; 1779 }while(node&&node.nodeType!=dojo.dom.ELEMENT_NODE); 1780 if(node&&_197&&_197.toLowerCase()!=node.tagName.toLowerCase()){ 1781 return dojo.dom.prevElement(node,_197); 1782 } 1783 return node; 1784 }; 1785 dojo.dom.moveChildren=function(_198,_199,trim){ 1786 var _19b=0; 1787 if(trim){ 1788 while(_198.hasChildNodes()&&_198.firstChild.nodeType==dojo.dom.TEXT_NODE){ 1789 _198.removeChild(_198.firstChild); 1790 } 1791 while(_198.hasChildNodes()&&_198.lastChild.nodeType==dojo.dom.TEXT_NODE){ 1792 _198.removeChild(_198.lastChild); 1793 } 1794 } 1795 while(_198.hasChildNodes()){ 1796 _199.appendChild(_198.firstChild); 1797 _19b++; 1798 } 1799 return _19b; 1800 }; 1801 dojo.dom.copyChildren=function(_19c,_19d,trim){ 1802 var _19f=_19c.cloneNode(true); 1803 return this.moveChildren(_19f,_19d,trim); 1804 }; 1805 dojo.dom.removeChildren=function(node){ 1806 var _1a1=node.childNodes.length; 1807 while(node.hasChildNodes()){ 1808 node.removeChild(node.firstChild); 1809 } 1810 return _1a1; 1811 }; 1812 dojo.dom.replaceChildren=function(node,_1a3){ 1813 dojo.dom.removeChildren(node); 1814 node.appendChild(_1a3); 1815 }; 1816 dojo.dom.removeNode=function(node){ 1817 if(node&&node.parentNode){ 1818 return node.parentNode.removeChild(node); 1819 } 1820 }; 1821 dojo.dom.getAncestors=function(node,_1a6,_1a7){ 1822 var _1a8=[]; 1823 var _1a9=dojo.lang.isFunction(_1a6); 1824 while(node){ 1825 if(!_1a9||_1a6(node)){ 1826 _1a8.push(node); 1827 } 1828 if(_1a7&&_1a8.length>0){ 1829 return _1a8[0]; 1830 } 1831 node=node.parentNode; 1832 } 1833 if(_1a7){ 1834 return null; 1835 } 1836 return _1a8; 1837 }; 1838 dojo.dom.getAncestorsByTag=function(node,tag,_1ac){ 1839 tag=tag.toLowerCase(); 1840 return dojo.dom.getAncestors(node,function(el){ 1841 return ((el.tagName)&&(el.tagName.toLowerCase()==tag)); 1842 },_1ac); 1843 }; 1844 dojo.dom.getFirstAncestorByTag=function(node,tag){ 1845 return dojo.dom.getAncestorsByTag(node,tag,true); 1846 }; 1847 dojo.dom.isDescendantOf=function(node,_1b1,_1b2){ 1848 if(_1b2&&node){ 1849 node=node.parentNode; 1850 } 1851 while(node){ 1852 if(node==_1b1){ 1853 return true; 1854 } 1855 node=node.parentNode; 1856 } 1857 return false; 1858 }; 1859 dojo.dom.innerXML=function(node){ 1860 if(node.innerXML){ 1861 return node.innerXML; 1862 }else{ 1863 if(typeof XMLSerializer!="undefined"){ 1864 return (new XMLSerializer()).serializeToString(node); 1865 } 1866 } 1867 }; 1868 dojo.dom.createDocumentFromText=function(str,_1b5){ 1869 if(!_1b5){ 1870 _1b5="text/xml"; 1871 } 1872 if(typeof DOMParser!="undefined"){ 1873 var _1b6=new DOMParser(); 1874 return _1b6.parseFromString(str,_1b5); 1875 }else{ 1876 if(typeof ActiveXObject!="undefined"){ 1877 var _1b7=new ActiveXObject("Microsoft.XMLDOM"); 1878 if(_1b7){ 1879 _1b7.async=false; 1880 _1b7.loadXML(str); 1881 return _1b7; 1882 }else{ 1883 dojo.debug("toXml didn't work?"); 1884 } 1885 }else{ 1886 if(document.createElement){ 1887 var tmp=document.createElement("xml"); 1888 tmp.innerHTML=str; 1889 if(document.implementation&&document.implementation.createDocument){ 1890 var _1b9=document.implementation.createDocument("foo","",null); 1891 for(var i=0;i<tmp.childNodes.length;i++){ 1892 _1b9.importNode(tmp.childNodes.item(i),true); 1893 } 1894 return _1b9; 1895 } 1896 return tmp.document&&tmp.document.firstChild?tmp.document.firstChild:tmp; 1897 } 1898 } 1899 } 1900 return null; 1901 }; 1902 dojo.dom.prependChild=function(node,_1bc){ 1903 if(_1bc.firstChild){ 1904 _1bc.insertBefore(node,_1bc.firstChild); 1905 }else{ 1906 _1bc.appendChild(node); 1907 } 1908 return true; 1909 }; 1910 dojo.dom.insertBefore=function(node,ref,_1bf){ 1911 if(_1bf!=true&&(node===ref||node.nextSibling===ref)){ 1912 return false; 1913 } 1914 var _1c0=ref.parentNode; 1915 _1c0.insertBefore(node,ref); 1916 return true; 1917 }; 1918 dojo.dom.insertAfter=function(node,ref,_1c3){ 1919 var pn=ref.parentNode; 1920 if(ref==pn.lastChild){ 1921 if((_1c3!=true)&&(node===ref)){ 1922 return false; 1923 } 1924 pn.appendChild(node); 1925 }else{ 1926 return this.insertBefore(node,ref.nextSibling,_1c3); 1927 } 1928 return true; 1929 }; 1930 dojo.dom.insertAtPosition=function(node,ref,_1c7){ 1931 if((!node)||(!ref)||(!_1c7)){ 1932 return false; 1933 } 1934 switch(_1c7.toLowerCase()){ 1935 case "before": 1936 return dojo.dom.insertBefore(node,ref); 1937 case "after": 1938 return dojo.dom.insertAfter(node,ref); 1939 case "first": 1940 if(ref.firstChild){ 1941 return dojo.dom.insertBefore(node,ref.firstChild); 1942 }else{ 1943 ref.appendChild(node); 1944 return true; 1945 } 1946 break; 1947 default: 1948 ref.appendChild(node); 1949 return true; 1950 } 1951 }; 1952 dojo.dom.insertAtIndex=function(node,_1c9,_1ca){ 1953 var _1cb=_1c9.childNodes; 1954 if(!_1cb.length){ 1955 _1c9.appendChild(node); 1956 return true; 1957 } 1958 var _1cc=null; 1959 for(var i=0;i<_1cb.length;i++){ 1960 var _1ce=_1cb.item(i)["getAttribute"]?parseInt(_1cb.item(i).getAttribute("dojoinsertionindex")):-1; 1961 if(_1ce<_1ca){ 1962 _1cc=_1cb.item(i); 1963 } 1964 } 1965 if(_1cc){ 1966 return dojo.dom.insertAfter(node,_1cc); 1967 }else{ 1968 return dojo.dom.insertBefore(node,_1cb.item(0)); 1969 } 1970 }; 1971 dojo.dom.textContent=function(node,text){ 1972 if(text){ 1973 dojo.dom.replaceChildren(node,document.createTextNode(text)); 1974 return text; 1975 }else{ 1976 var _1d1=""; 1977 if(node==null){ 1978 return _1d1; 1979 } 1980 for(var i=0;i<node.childNodes.length;i++){ 1981 switch(node.childNodes[i].nodeType){ 1982 case 1: 1983 case 5: 1984 _1d1+=dojo.dom.textContent(node.childNodes[i]); 1985 break; 1986 case 3: 1987 case 2: 1988 case 4: 1989 _1d1+=node.childNodes[i].nodeValue; 1990 break; 1991 default: 1992 break; 1993 } 1994 } 1995 return _1d1; 1996 } 1997 }; 1998 dojo.dom.collectionToArray=function(_1d3){ 1999 dojo.deprecated("dojo.dom.collectionToArray","use dojo.lang.toArray instead"); 2000 return dojo.lang.toArray(_1d3); 2001 }; 2002 dojo.dom.hasParent=function(node){ 2003 if(!node||!node.parentNode||(node.parentNode&&!node.parentNode.tagName)){ 2004 return false; 2005 } 2006 return true; 2007 }; 2008 dojo.dom.isTag=function(node){ 2009 if(node&&node.tagName){ 2010 var arr=dojo.lang.toArray(arguments,1); 2011 return arr[dojo.lang.find(node.tagName,arr)]||""; 2012 } 2013 return ""; 2014 }; 2015 dojo.provide("dojo.io.BrowserIO"); 2016 dojo.require("dojo.io"); 2017 dojo.require("dojo.lang"); 2018 dojo.require("dojo.dom"); 2019 try{ 2020 if((!djConfig["preventBackButtonFix"])&&(!dojo.hostenv.post_load_)){ 2021 document.write("<iframe style='border: 0px; width: 1px; height: 1px; position: absolute; bottom: 0px; right: 0px; visibility: visible;' name='djhistory' id='djhistory' src='"+(dojo.hostenv.getBaseScriptUri()+"iframe_history.html")+"'></iframe>"); 2022 } 2023 } 2024 catch(e){ 2025 } 2026 dojo.io.checkChildrenForFile=function(node){ 2027 var _1d8=false; 2028 var _1d9=node.getElementsByTagName("input"); 2029 dojo.lang.forEach(_1d9,function(_1da){ 2030 if(_1d8){ 2031 return; 2032 } 2033 if(_1da.getAttribute("type")=="file"){ 2034 _1d8=true; 2035 } 2036 }); 2037 return _1d8; 2038 }; 2039 dojo.io.formHasFile=function(_1db){ 2040 return dojo.io.checkChildrenForFile(_1db); 2041 }; 2042 dojo.io.encodeForm=function(_1dc,_1dd){ 2043 if((!_1dc)||(!_1dc.tagName)||(!_1dc.tagName.toLowerCase()=="form")){ 2044 dojo.raise("Attempted to encode a non-form element."); 2045 } 2046 var enc=/utf/i.test(_1dd||"")?encodeURIComponent:dojo.string.encodeAscii; 2047 var _1df=[]; 2048 for(var i=0;i<_1dc.elements.length;i++){ 2049 var elm=_1dc.elements[i]; 2050 if(elm.disabled||elm.tagName.toLowerCase()=="fieldset"||!elm.name){ 2051 continue; 2052 } 2053 var name=enc(elm.name); 2054 var type=elm.type.toLowerCase(); 2055 if(type=="select-multiple"){ 2056 for(var j=0;j<elm.options.length;j++){ 2057 if(elm.options[j].selected){ 2058 _1df.push(name+"="+enc(elm.options[j].value)); 2059 } 2060 } 2061 }else{ 2062 if(dojo.lang.inArray(type,["radio","checkbox"])){ 2063 if(elm.checked){ 2064 _1df.push(name+"="+enc(elm.value)); 2065 } 2066 }else{ 2067 if(!dojo.lang.inArray(type,["file","submit","reset","button"])){ 2068 _1df.push(name+"="+enc(elm.value)); 2069 } 2070 } 2071 } 2072 } 2073 var _1e5=_1dc.getElementsByTagName("input"); 2074 for(var i=0;i<_1e5.length;i++){ 2075 var _1e6=_1e5[i]; 2076 if(_1e6.type.toLowerCase()=="image"&&_1e6.form==_1dc){ 2077 var name=enc(_1e6.name); 2078 _1df.push(name+"="+enc(_1e6.value)); 2079 _1df.push(name+".x=0"); 2080 _1df.push(name+".y=0"); 2081 } 2082 } 2083 return _1df.join("&")+"&"; 2084 }; 2085 dojo.io.setIFrameSrc=function(_1e7,src,_1e9){ 2086 try{ 2087 var r=dojo.render.html; 2088 if(!_1e9){ 2089 if(r.safari){ 2090 _1e7.location=src; 2091 }else{ 2092 frames[_1e7.name].location=src; 2093 } 2094 }else{ 2095 var idoc; 2096 if(r.ie){ 2097 idoc=_1e7.contentWindow.document; 2098 }else{ 2099 if(r.moz){ 2100 idoc=_1e7.contentWindow; 2101 }else{ 2102 if(r.safari){ 2103 idoc=_1e7.document; 2104 } 2105 } 2106 } 2107 idoc.location.replace(src); 2108 } 2109 } 2110 catch(e){ 2111 dojo.debug(e); 2112 dojo.debug("setIFrameSrc: "+e); 2113 } 2114 }; 2115 dojo.io.XMLHTTPTransport=new function(){ 2116 var _1ec=this; 2117 this.initialHref=window.location.href; 2118 this.initialHash=window.location.hash; 2119 this.moveForward=false; 2120 var _1ed={}; 2121 this.useCache=false; 2122 this.preventCache=false; 2123 this.historyStack=[]; 2124 this.forwardStack=[]; 2125 this.historyIframe=null; 2126 this.bookmarkAnchor=null; 2127 this.locationTimer=null; 2128 function getCacheKey(url,_1ef,_1f0){ 2129 return url+"|"+_1ef+"|"+_1f0.toLowerCase(); 2130 } 2131 function addToCache(url,_1f2,_1f3,http){ 2132 _1ed[getCacheKey(url,_1f2,_1f3)]=http; 2133 } 2134 function getFromCache(url,_1f6,_1f7){ 2135 return _1ed[getCacheKey(url,_1f6,_1f7)]; 2136 } 2137 this.clearCache=function(){ 2138 _1ed={}; 2139 }; 2140 function doLoad(_1f8,http,url,_1fb,_1fc){ 2141 if((http.status==200)||(location.protocol=="file:"&&http.status==0)){ 2142 var ret; 2143 if(_1f8.method.toLowerCase()=="head"){ 2144 var _1fe=http.getAllResponseHeaders(); 2145 ret={}; 2146 ret.toString=function(){ 2147 return _1fe; 2148 }; 2149 var _1ff=_1fe.split(/[\r\n]+/g); 2150 for(var i=0;i<_1ff.length;i++){ 2151 var pair=_1ff[i].match(/^([^:]+)\s*:\s*(.+)$/i); 2152 if(pair){ 2153 ret[pair[1]]=pair[2]; 2154 } 2155 } 2156 }else{ 2157 if(_1f8.mimetype=="text/javascript"){ 2158 try{ 2159 ret=dj_eval(http.responseText); 2160 } 2161 catch(e){ 2162 dojo.debug(e); 2163 dojo.debug(http.responseText); 2164 ret=null; 2165 } 2166 }else{ 2167 if(_1f8.mimetype=="text/json"){ 2168 try{ 2169 ret=dj_eval("("+http.responseText+")"); 2170 } 2171 catch(e){ 2172 dojo.debug(e); 2173 dojo.debug(http.responseText); 2174 ret=false; 2175 } 2176 }else{ 2177 if((_1f8.mimetype=="application/xml")||(_1f8.mimetype=="text/xml")){ 2178 ret=http.responseXML; 2179 if(!ret||typeof ret=="string"){ 2180 ret=dojo.dom.createDocumentFromText(http.responseText); 2181 } 2182 }else{ 2183 ret=http.responseText; 2184 } 2185 } 2186 } 2187 } 2188 if(_1fc){ 2189 addToCache(url,_1fb,_1f8.method,http); 2190 } 2191 _1f8[(typeof _1f8.load=="function")?"load":"handle"]("load",ret,http); 2192 }else{ 2193 var _202=new dojo.io.Error("XMLHttpTransport Error: "+http.status+" "+http.statusText); 2194 _1f8[(typeof _1f8.error=="function")?"error":"handle"]("error",_202,http); 2195 } 2196 } 2197 function setHeaders(http,_204){ 2198 if(_204["headers"]){ 2199 for(var _205 in _204["headers"]){ 2200 if(_205.toLowerCase()=="content-type"&&!_204["contentType"]){ 2201 _204["contentType"]=_204["headers"][_205]; 2202 }else{ 2203 http.setRequestHeader(_205,_204["headers"][_205]); 2204 } 2205 } 2206 } 2207 } 2208 this.addToHistory=function(args){ 2209 var _207=args["back"]||args["backButton"]||args["handle"]; 2210 var hash=null; 2211 if(!this.historyIframe){ 2212 this.historyIframe=window.frames["djhistory"]; 2213 } 2214 if(!this.bookmarkAnchor){ 2215 this.bookmarkAnchor=document.createElement("a"); 2216 (document.body||document.getElementsByTagName("body")[0]).appendChild(this.bookmarkAnchor); 2217 this.bookmarkAnchor.style.display="none"; 2218 } 2219 if((!args["changeUrl"])||(dojo.render.html.ie)){ 2220 var url=dojo.hostenv.getBaseScriptUri()+"iframe_history.html?"+(new Date()).getTime(); 2221 this.moveForward=true; 2222 dojo.io.setIFrameSrc(this.historyIframe,url,false); 2223 } 2224 if(args["changeUrl"]){ 2225 hash="#"+((args["changeUrl"]!==true)?args["changeUrl"]:(new Date()).getTime()); 2226 setTimeout("window.location.href = '"+hash+"';",1); 2227 this.bookmarkAnchor.href=hash; 2228 if(dojo.render.html.ie){ 2229 var _20a=_207; 2230 var lh=null; 2231 var hsl=this.historyStack.length-1; 2232 if(hsl>=0){ 2233 while(!this.historyStack[hsl]["urlHash"]){ 2234 hsl--; 2235 } 2236 lh=this.historyStack[hsl]["urlHash"]; 2237 } 2238 if(lh){ 2239 _207=function(){ 2240 if(window.location.hash!=""){ 2241 setTimeout("window.location.href = '"+lh+"';",1); 2242 } 2243 _20a(); 2244 }; 2245 } 2246 this.forwardStack=[]; 2247 var _20d=args["forward"]||args["forwardButton"]; 2248 var tfw=function(){ 2249 if(window.location.hash!=""){ 2250 window.location.href=hash; 2251 } 2252 if(_20d){ 2253 _20d(); 2254 } 2255 }; 2256 if(args["forward"]){ 2257 args.forward=tfw; 2258 }else{ 2259 if(args["forwardButton"]){ 2260 args.forwardButton=tfw; 2261 } 2262 } 2263 }else{ 2264 if(dojo.render.html.moz){ 2265 if(!this.locationTimer){ 2266 this.locationTimer=setInterval("dojo.io.XMLHTTPTransport.checkLocation();",200); 2267 } 2268 } 2269 } 2270 } 2271 this.historyStack.push({"url":url,"callback":_207,"kwArgs":args,"urlHash":hash}); 2272 }; 2273 this.checkLocation=function(){ 2274 var hsl=this.historyStack.length; 2275 if((window.location.hash==this.initialHash)||(window.location.href==this.initialHref)&&(hsl==1)){ 2276 this.handleBackButton(); 2277 return; 2278 } 2279 if(this.forwardStack.length>0){ 2280 if(this.forwardStack[this.forwardStack.length-1].urlHash==window.location.hash){ 2281 this.handleForwardButton(); 2282 return; 2283 } 2284 } 2285 if((hsl>=2)&&(this.historyStack[hsl-2])){ 2286 if(this.historyStack[hsl-2].urlHash==window.location.hash){ 2287 this.handleBackButton(); 2288 return; 2289 } 2290 } 2291 }; 2292 this.iframeLoaded=function(evt,_211){ 2293 var isp=_211.href.split("?"); 2294 if(isp.length<2){ 2295 if(this.historyStack.length==1){ 2296 this.handleBackButton(); 2297 } 2298 return; 2299 } 2300 var _213=isp[1]; 2301 if(this.moveForward){ 2302 this.moveForward=false; 2303 return; 2304 } 2305 var last=this.historyStack.pop(); 2306 if(!last){ 2307 if(this.forwardStack.length>0){ 2308 var next=this.forwardStack[this.forwardStack.length-1]; 2309 if(_213==next.url.split("?")[1]){ 2310 this.handleForwardButton(); 2311 } 2312 } 2313 return; 2314 } 2315 this.historyStack.push(last); 2316 if(this.historyStack.length>=2){ 2317 if(isp[1]==this.historyStack[this.historyStack.length-2].url.split("?")[1]){ 2318 this.handleBackButton(); 2319 } 2320 }else{ 2321 this.handleBackButton(); 2322 } 2323 }; 2324 this.handleBackButton=function(){ 2325 var last=this.historyStack.pop(); 2326 if(!last){ 2327 return; 2328 } 2329 if(last["callback"]){ 2330 last.callback(); 2331 }else{ 2332 if(last.kwArgs["backButton"]){ 2333 last.kwArgs["backButton"](); 2334 }else{ 2335 if(last.kwArgs["back"]){ 2336 last.kwArgs["back"](); 2337 }else{ 2338 if(last.kwArgs["handle"]){ 2339 last.kwArgs.handle("back"); 2340 } 2341 } 2342 } 2343 } 2344 this.forwardStack.push(last); 2345 }; 2346 this.handleForwardButton=function(){ 2347 var last=this.forwardStack.pop(); 2348 if(!last){ 2349 return; 2350 } 2351 if(last.kwArgs["forward"]){ 2352 last.kwArgs.forward(); 2353 }else{ 2354 if(last.kwArgs["forwardButton"]){ 2355 last.kwArgs.forwardButton(); 2356 }else{ 2357 if(last.kwArgs["handle"]){ 2358 last.kwArgs.handle("forward"); 2359 } 2360 } 2361 } 2362 this.historyStack.push(last); 2363 }; 2364 this.inFlight=[]; 2365 this.inFlightTimer=null; 2366 this.startWatchingInFlight=function(){ 2367 if(!this.inFlightTimer){ 2368 this.inFlightTimer=setInterval("dojo.io.XMLHTTPTransport.watchInFlight();",10); 2369 } 2370 }; 2371 this.watchInFlight=function(){ 2372 for(var x=this.inFlight.length-1;x>=0;x--){ 2373 var tif=this.inFlight[x]; 2374 if(!tif){ 2375 this.inFlight.splice(x,1); 2376 continue; 2377 } 2378 if(4==tif.http.readyState){ 2379 this.inFlight.splice(x,1); 2380 doLoad(tif.req,tif.http,tif.url,tif.query,tif.useCache); 2381 if(this.inFlight.length==0){ 2382 clearInterval(this.inFlightTimer); 2383 this.inFlightTimer=null; 2384 } 2385 } 2386 } 2387 }; 2388 var _21a=dojo.hostenv.getXmlhttpObject()?true:false; 2389 this.canHandle=function(_21b){ 2390 return _21a&&dojo.lang.inArray((_21b["mimetype"]||"".toLowerCase()),["text/plain","text/html","application/xml","text/xml","text/javascript","text/json"])&&dojo.lang.inArray(_21b["method"].toLowerCase(),["post","get","head"])&&!(_21b["formNode"]&&dojo.io.formHasFile(_21b["formNode"])); 2391 }; 2392 this.multipartBoundary="45309FFF-BD65-4d50-99C9-36986896A96F"; 2393 this.bind=function(_21c){ 2394 if(!_21c["url"]){ 2395 if(!_21c["formNode"]&&(_21c["backButton"]||_21c["back"]||_21c["changeUrl"]||_21c["watchForURL"])&&(!djConfig.preventBackButtonFix)){ 2396 this.addToHistory(_21c); 2397 return true; 2398 } 2399 } 2400 var url=_21c.url; 2401 var _21e=""; 2402 if(_21c["formNode"]){ 2403 var ta=_21c.formNode.getAttribute("action"); 2404 if((ta)&&(!_21c["url"])){ 2405 url=ta; 2406 } 2407 var tp=_21c.formNode.getAttribute("method"); 2408 if((tp)&&(!_21c["method"])){ 2409 _21c.method=tp; 2410 } 2411 _21e+=dojo.io.encodeForm(_21c.formNode,_21c.encoding); 2412 } 2413 if(url.indexOf("#")>-1){ 2414 dojo.debug("Warning: dojo.io.bind: stripping hash values from url:",url); 2415 url=url.split("#")[0]; 2416 } 2417 if(_21c["file"]){ 2418 _21c.method="post"; 2419 } 2420 if(!_21c["method"]){ 2421 _21c.method="get"; 2422 } 2423 if(_21c.method.toLowerCase()=="get"){ 2424 _21c.multipart=false; 2425 }else{ 2426 if(_21c["file"]){ 2427 _21c.multipart=true; 2428 }else{ 2429 if(!_21c["multipart"]){ 2430 _21c.multipart=false; 2431 } 2432 } 2433 } 2434 if(_21c["backButton"]||_21c["back"]||_21c["changeUrl"]){ 2435 this.addToHistory(_21c); 2436 } 2437 var _221=_21c["content"]||{}; 2438 if(_21c.sendTransport){ 2439 _221["dojo.transport"]="xmlhttp"; 2440 } 2441 do{ 2442 if(_21c.postContent){ 2443 _21e=_21c.postContent; 2444 break; 2445 } 2446 if(_221){ 2447 _21e+=dojo.io.argsFromMap(_221,_21c.encoding); 2448 } 2449 if(_21c.method.toLowerCase()=="get"||!_21c.multipart){ 2450 break; 2451 } 2452 var t=[]; 2453 if(_21e.length){ 2454 var q=_21e.split("&"); 2455 for(var i=0;i<q.length;++i){ 2456 if(q[i].length){ 2457 var p=q[i].split("="); 2458 t.push("--"+this.multipartBoundary,"Content-Disposition: form-data; name=\""+p[0]+"\"","",p[1]); 2459 } 2460 } 2461 } 2462 if(_21c.file){ 2463 if(dojo.lang.isArray(_21c.file)){ 2464 for(var i=0;i<_21c.file.length;++i){ 2465 var o=_21c.file[i]; 2466 t.push("--"+this.multipartBoundary,"Content-Disposition: form-data; name=\""+o.name+"\"; filename=\""+("fileName" in o?o.fileName:o.name)+"\"","Content-Type: "+("contentType" in o?o.contentType:"application/octet-stream"),"",o.content); 2467 } 2468 }else{ 2469 var o=_21c.file; 2470 t.push("--"+this.multipartBoundary,"Content-Disposition: form-data; name=\""+o.name+"\"; filename=\""+("fileName" in o?o.fileName:o.name)+"\"","Content-Type: "+("contentType" in o?o.contentType:"application/octet-stream"),"",o.content); 2471 } 2472 } 2473 if(t.length){ 2474 t.push("--"+this.multipartBoundary+"--",""); 2475 _21e=t.join("\r\n"); 2476 } 2477 }while(false); 2478 var _227=_21c["sync"]?false:true; 2479 var _228=_21c["preventCache"]||(this.preventCache==true&&_21c["preventCache"]!=false); 2480 var _229=_21c["useCache"]==true||(this.useCache==true&&_21c["useCache"]!=false); 2481 if(!_228&&_229){ 2482 var _22a=getFromCache(url,_21e,_21c.method); 2483 if(_22a){ 2484 doLoad(_21c,_22a,url,_21e,false); 2485 return; 2486 } 2487 } 2488 var http=dojo.hostenv.getXmlhttpObject(); 2489 var _22c=false; 2490 if(_227){ 2491 this.inFlight.push({"req":_21c,"http":http,"url":url,"query":_21e,"useCache":_229}); 2492 this.startWatchingInFlight(); 2493 } 2494 if(_21c.method.toLowerCase()=="post"){ 2495 http.open("POST",url,_227); 2496 setHeaders(http,_21c); 2497 http.setRequestHeader("Content-Type",_21c.multipart?("multipart/form-data; boundary="+this.multipartBoundary):(_21c.contentType||"application/x-www-form-urlencoded")); 2498 http.send(_21e); 2499 }else{ 2500 var _22d=url; 2501 if(_21e!=""){ 2502 _22d+=(_22d.indexOf("?")>-1?"&":"?")+_21e; 2503 } 2504 if(_228){ 2505 _22d+=(dojo.string.endsWithAny(_22d,"?","&")?"":(_22d.indexOf("?")>-1?"&":"?"))+"dojo.preventCache="+new Date().valueOf(); 2506 } 2507 http.open(_21c.method.toUpperCase(),_22d,_227); 2508 setHeaders(http,_21c); 2509 http.send(null); 2510 } 2511 if(!_227){ 2512 doLoad(_21c,http,url,_21e,_229); 2513 } 2514 _21c.abort=function(){ 2515 return http.abort(); 2516 }; 2517 return; 2518 }; 2519 dojo.io.transports.addTransport("XMLHTTPTransport"); 2520 }; 2521 dojo.require("dojo.lang"); 2522 dojo.provide("dojo.event"); 2523 dojo.event=new function(){ 2524 this.canTimeout=dojo.lang.isFunction(dj_global["setTimeout"])||dojo.lang.isAlien(dj_global["setTimeout"]); 2525 function interpolateArgs(args){ 2526 var dl=dojo.lang; 2527 var ao={srcObj:dj_global,srcFunc:null,adviceObj:dj_global,adviceFunc:null,aroundObj:null,aroundFunc:null,adviceType:(args.length>2)?args[0]:"after",precedence:"last",once:false,delay:null,rate:0,adviceMsg:false}; 2528 switch(args.length){ 2529 case 0: 2530 return; 2531 case 1: 2532 return; 2533 case 2: 2534 ao.srcFunc=args[0]; 2535 ao.adviceFunc=args[1]; 2536 break; 2537 case 3: 2538 if((dl.isObject(args[0]))&&(dl.isString(args[1]))&&(dl.isString(args[2]))){ 2539 ao.adviceType="after"; 2540 ao.srcObj=args[0]; 2541 ao.srcFunc=args[1]; 2542 ao.adviceFunc=args[2]; 2543 }else{ 2544 if((dl.isString(args[1]))&&(dl.isString(args[2]))){ 2545 ao.srcFunc=args[1]; 2546 ao.adviceFunc=args[2]; 2547 }else{ 2548 if((dl.isObject(args[0]))&&(dl.isString(args[1]))&&(dl.isFunction(args[2]))){ 2549 ao.adviceType="after"; 2550 ao.srcObj=args[0]; 2551 ao.srcFunc=args[1]; 2552 var _231=dojo.lang.nameAnonFunc(args[2],ao.adviceObj); 2553 ao.adviceFunc=_231; 2554 }else{ 2555 if((dl.isFunction(args[0]))&&(dl.isObject(args[1]))&&(dl.isString(args[2]))){ 2556 ao.adviceType="after"; 2557 ao.srcObj=dj_global; 2558 var _231=dojo.lang.nameAnonFunc(args[0],ao.srcObj); 2559 ao.srcFunc=_231; 2560 ao.adviceObj=args[1]; 2561 ao.adviceFunc=args[2]; 2562 } 2563 } 2564 } 2565 } 2566 break; 2567 case 4: 2568 if((dl.isObject(args[0]))&&(dl.isObject(args[2]))){ 2569 ao.adviceType="after"; 2570 ao.srcObj=args[0]; 2571 ao.srcFunc=args[1]; 2572 ao.adviceObj=args[2]; 2573 ao.adviceFunc=args[3]; 2574 }else{ 2575 if((dl.isString(args[0]))&&(dl.isString(args[1]))&&(dl.isObject(args[2]))){ 2576 ao.adviceType=args[0]; 2577 ao.srcObj=dj_global; 2578 ao.srcFunc=args[1]; 2579 ao.adviceObj=args[2]; 2580 ao.adviceFunc=args[3]; 2581 }else{ 2582 if((dl.isString(args[0]))&&(dl.isFunction(args[1]))&&(dl.isObject(args[2]))){ 2583 ao.adviceType=args[0]; 2584 ao.srcObj=dj_global; 2585 var _231=dojo.lang.nameAnonFunc(args[1],dj_global); 2586 ao.srcFunc=_231; 2587 ao.adviceObj=args[2]; 2588 ao.adviceFunc=args[3]; 2589 }else{ 2590 if(dl.isObject(args[1])){ 2591 ao.srcObj=args[1]; 2592 ao.srcFunc=args[2]; 2593 ao.adviceObj=dj_global; 2594 ao.adviceFunc=args[3]; 2595 }else{ 2596 if(dl.isObject(args[2])){ 2597 ao.srcObj=dj_global; 2598 ao.srcFunc=args[1]; 2599 ao.adviceObj=args[2]; 2600 ao.adviceFunc=args[3]; 2601 }else{ 2602 ao.srcObj=ao.adviceObj=ao.aroundObj=dj_global; 2603 ao.srcFunc=args[1]; 2604 ao.adviceFunc=args[2]; 2605 ao.aroundFunc=args[3]; 2606 } 2607 } 2608 } 2609 } 2610 } 2611 break; 2612 case 6: 2613 ao.srcObj=args[1]; 2614 ao.srcFunc=args[2]; 2615 ao.adviceObj=args[3]; 2616 ao.adviceFunc=args[4]; 2617 ao.aroundFunc=args[5]; 2618 ao.aroundObj=dj_global; 2619 break; 2620 default: 2621 ao.srcObj=args[1]; 2622 ao.srcFunc=args[2]; 2623 ao.adviceObj=args[3]; 2624 ao.adviceFunc=args[4]; 2625 ao.aroundObj=args[5]; 2626 ao.aroundFunc=args[6]; 2627 ao.once=args[7]; 2628 ao.delay=args[8]; 2629 ao.rate=args[9]; 2630 ao.adviceMsg=args[10]; 2631 break; 2632 } 2633 if((typeof ao.srcFunc).toLowerCase()!="string"){ 2634 ao.srcFunc=dojo.lang.getNameInObj(ao.srcObj,ao.srcFunc); 2635 } 2636 if((typeof ao.adviceFunc).toLowerCase()!="string"){ 2637 ao.adviceFunc=dojo.lang.getNameInObj(ao.adviceObj,ao.adviceFunc); 2638 } 2639 if((ao.aroundObj)&&((typeof ao.aroundFunc).toLowerCase()!="string")){ 2640 ao.aroundFunc=dojo.lang.getNameInObj(ao.aroundObj,ao.aroundFunc); 2641 } 2642 if(!ao.srcObj){ 2643 dojo.raise("bad srcObj for srcFunc: "+ao.srcFunc); 2644 } 2645 if(!ao.adviceObj){ 2646 dojo.raise("bad adviceObj for adviceFunc: "+ao.adviceFunc); 2647 } 2648 return ao; 2649 } 2650 this.connect=function(){ 2651 var ao=interpolateArgs(arguments); 2652 var mjp=dojo.event.MethodJoinPoint.getForMethod(ao.srcObj,ao.srcFunc); 2653 if(ao.adviceFunc){ 2654 var mjp2=dojo.event.MethodJoinPoint.getForMethod(ao.adviceObj,ao.adviceFunc); 2655 } 2656 mjp.kwAddAdvice(ao); 2657 return mjp; 2658 }; 2659 this.connectBefore=function(){ 2660 var args=["before"]; 2661 for(var i=0;i<arguments.length;i++){ 2662 args.push(arguments[i]); 2663 } 2664 return this.connect.apply(this,args); 2665 }; 2666 this.connectAround=function(){ 2667 var args=["around"]; 2668 for(var i=0;i<arguments.length;i++){ 2669 args.push(arguments[i]); 2670 } 2671 return this.connect.apply(this,args); 2672 }; 2673 this._kwConnectImpl=function(_239,_23a){ 2674 var fn=(_23a)?"disconnect":"connect"; 2675 if(typeof _239["srcFunc"]=="function"){ 2676 _239.srcObj=_239["srcObj"]||dj_global; 2677 var _23c=dojo.lang.nameAnonFunc(_239.srcFunc,_239.srcObj); 2678 _239.srcFunc=_23c; 2679 } 2680 if(typeof _239["adviceFunc"]=="function"){ 2681 _239.adviceObj=_239["adviceObj"]||dj_global; 2682 var _23c=dojo.lang.nameAnonFunc(_239.adviceFunc,_239.adviceObj); 2683 _239.adviceFunc=_23c; 2684 } 2685 return dojo.event[fn]((_239["type"]||_239["adviceType"]||"after"),_239["srcObj"]||dj_global,_239["srcFunc"],_239["adviceObj"]||_239["targetObj"]||dj_global,_239["adviceFunc"]||_239["targetFunc"],_239["aroundObj"],_239["aroundFunc"],_239["once"],_239["delay"],_239["rate"],_239["adviceMsg"]||false); 2686 }; 2687 this.kwConnect=function(_23d){ 2688 return this._kwConnectImpl(_23d,false); 2689 }; 2690 this.disconnect=function(){ 2691 var ao=interpolateArgs(arguments); 2692 if(!ao.adviceFunc){ 2693 return; 2694 } 2695 var mjp=dojo.event.MethodJoinPoint.getForMethod(ao.srcObj,ao.srcFunc); 2696 return mjp.removeAdvice(ao.adviceObj,ao.adviceFunc,ao.adviceType,ao.once); 2697 }; 2698 this.kwDisconnect=function(_240){ 2699 return this._kwConnectImpl(_240,true); 2700 }; 2701 }; 2702 dojo.event.MethodInvocation=function(_241,obj,args){ 2703 this.jp_=_241; 2704 this.object=obj; 2705 this.args=[]; 2706 for(var x=0;x<args.length;x++){ 2707 this.args[x]=args[x]; 2708 } 2709 this.around_index=-1; 2710 }; 2711 dojo.event.MethodInvocation.prototype.proceed=function(){ 2712 this.around_index++; 2713 if(this.around_index>=this.jp_.around.length){ 2714 return this.jp_.object[this.jp_.methodname].apply(this.jp_.object,this.args); 2715 }else{ 2716 var ti=this.jp_.around[this.around_index]; 2717 var mobj=ti[0]||dj_global; 2718 var meth=ti[1]; 2719 return mobj[meth].call(mobj,this); 2720 } 2721 }; 2722 dojo.event.MethodJoinPoint=function(obj,_249){ 2723 this.object=obj||dj_global; 2724 this.methodname=_249; 2725 this.methodfunc=this.object[_249]; 2726 this.before=[]; 2727 this.after=[]; 2728 this.around=[]; 2729 }; 2730 dojo.event.MethodJoinPoint.getForMethod=function(obj,_24b){ 2731 if(!obj){ 2732 obj=dj_global; 2733 } 2734 if(!obj[_24b]){ 2735 obj[_24b]=function(){ 2736 }; 2737 }else{ 2738 if((!dojo.lang.isFunction(obj[_24b]))&&(!dojo.lang.isAlien(obj[_24b]))){ 2739 return null; 2740 } 2741 } 2742 var _24c=_24b+"$joinpoint"; 2743 var _24d=_24b+"$joinpoint$method"; 2744 var _24e=obj[_24c]; 2745 if(!_24e){ 2746 var _24f=false; 2747 if(dojo.event["browser"]){ 2748 if((obj["attachEvent"])||(obj["nodeType"])||(obj["addEventListener"])){ 2749 _24f=true; 2750 dojo.event.browser.addClobberNodeAttrs(obj,[_24c,_24d,_24b]); 2751 } 2752 } 2753 obj[_24d]=obj[_24b]; 2754 _24e=obj[_24c]=new dojo.event.MethodJoinPoint(obj,_24d); 2755 obj[_24b]=function(){ 2756 var args=[]; 2757 if((_24f)&&(!arguments.length)&&(window.event)){ 2758 args.push(dojo.event.browser.fixEvent(window.event)); 2759 }else{ 2760 for(var x=0;x<arguments.length;x++){ 2761 if((x==0)&&(_24f)&&(dojo.event.browser.isEvent(arguments[x]))){ 2762 args.push(dojo.event.browser.fixEvent(arguments[x])); 2763 }else{ 2764 args.push(arguments[x]); 2765 } 2766 } 2767 } 2768 return _24e.run.apply(_24e,args); 2769 }; 2770 } 2771 return _24e; 2772 }; 2773 dojo.lang.extend(dojo.event.MethodJoinPoint,{unintercept:function(){ 2774 this.object[this.methodname]=this.methodfunc; 2775 },run:function(){ 2776 var obj=this.object||dj_global; 2777 var args=arguments; 2778 var _254=[]; 2779 for(var x=0;x<args.length;x++){ 2780 _254[x]=args[x]; 2781 } 2782 var _256=function(marr){ 2783 if(!marr){ 2784 dojo.debug("Null argument to unrollAdvice()"); 2785 return; 2786 } 2787 var _258=marr[0]||dj_global; 2788 var _259=marr[1]; 2789 if(!_258[_259]){ 2790 dojo.raise("function \""+_259+"\" does not exist on \""+_258+"\""); 2791 } 2792 var _25a=marr[2]||dj_global; 2793 var _25b=marr[3]; 2794 var msg=marr[6]; 2795 var _25d; 2796 var to={args:[],jp_:this,object:obj,proceed:function(){ 2797 return _258[_259].apply(_258,to.args); 2798 }}; 2799 to.args=_254; 2800 var _25f=parseInt(marr[4]); 2801 var _260=((!isNaN(_25f))&&(marr[4]!==null)&&(typeof marr[4]!="undefined")); 2802 if(marr[5]){ 2803 var rate=parseInt(marr[5]); 2804 var cur=new Date(); 2805 var _263=false; 2806 if((marr["last"])&&((cur-marr.last)<=rate)){ 2807 if(dojo.event.canTimeout){ 2808 if(marr["delayTimer"]){ 2809 clearTimeout(marr.delayTimer); 2810 } 2811 var tod=parseInt(rate*2); 2812 var mcpy=dojo.lang.shallowCopy(marr); 2813 marr.delayTimer=setTimeout(function(){ 2814 mcpy[5]=0; 2815 _256(mcpy); 2816 },tod); 2817 } 2818 return; 2819 }else{ 2820 marr.last=cur; 2821 } 2822 } 2823 if(_25b){ 2824 _25a[_25b].call(_25a,to); 2825 }else{ 2826 if((_260)&&((dojo.render.html)||(dojo.render.svg))){ 2827 dj_global["setTimeout"](function(){ 2828 if(msg){ 2829 _258[_259].call(_258,to); 2830 }else{ 2831 _258[_259].apply(_258,args); 2832 } 2833 },_25f); 2834 }else{ 2835 if(msg){ 2836 _258[_259].call(_258,to); 2837 }else{ 2838 _258[_259].apply(_258,args); 2839 } 2840 } 2841 } 2842 }; 2843 if(this.before.length>0){ 2844 dojo.lang.forEach(this.before,_256,true); 2845 } 2846 var _266; 2847 if(this.around.length>0){ 2848 var mi=new dojo.event.MethodInvocation(this,obj,args); 2849 _266=mi.proceed(); 2850 }else{ 2851 if(this.methodfunc){ 2852 _266=this.object[this.methodname].apply(this.object,args); 2853 } 2854 } 2855 if(this.after.length>0){ 2856 dojo.lang.forEach(this.after,_256,true); 2857 } 2858 return (this.methodfunc)?_266:null; 2859 },getArr:function(kind){ 2860 var arr=this.after; 2861 if((typeof kind=="string")&&(kind.indexOf("before")!=-1)){ 2862 arr=this.before; 2863 }else{ 2864 if(kind=="around"){ 2865 arr=this.around; 2866 } 2867 } 2868 return arr; 2869 },kwAddAdvice:function(args){ 2870 this.addAdvice(args["adviceObj"],args["adviceFunc"],args["aroundObj"],args["aroundFunc"],args["adviceType"],args["precedence"],args["once"],args["delay"],args["rate"],args["adviceMsg"]); 2871 },addAdvice:function(_26b,_26c,_26d,_26e,_26f,_270,once,_272,rate,_274){ 2872 var arr=this.getArr(_26f); 2873 if(!arr){ 2874 dojo.raise("bad this: "+this); 2875 } 2876 var ao=[_26b,_26c,_26d,_26e,_272,rate,_274]; 2877 if(once){ 2878 if(this.hasAdvice(_26b,_26c,_26f,arr)>=0){ 2879 return; 2880 } 2881 } 2882 if(_270=="first"){ 2883 arr.unshift(ao); 2884 }else{ 2885 arr.push(ao); 2886 } 2887 },hasAdvice:function(_277,_278,_279,arr){ 2888 if(!arr){ 2889 arr=this.getArr(_279); 2890 } 2891 var ind=-1; 2892 for(var x=0;x<arr.length;x++){ 2893 if((arr[x][0]==_277)&&(arr[x][1]==_278)){ 2894 ind=x; 2895 } 2896 } 2897 return ind; 2898 },removeAdvice:function(_27d,_27e,_27f,once){ 2899 var arr=this.getArr(_27f); 2900 var ind=this.hasAdvice(_27d,_27e,_27f,arr); 2901 if(ind==-1){ 2902 return false; 2903 } 2904 while(ind!=-1){ 2905 arr.splice(ind,1); 2906 if(once){ 2907 break; 2908 } 2909 ind=this.hasAdvice(_27d,_27e,_27f,arr); 2910 } 2911 return true; 2912 }}); 2913 dojo.require("dojo.event"); 2914 dojo.provide("dojo.event.topic"); 2915 dojo.event.topic=new function(){ 2916 this.topics={}; 2917 this.getTopic=function(_283){ 2918 if(!this.topics[_283]){ 2919 this.topics[_283]=new this.TopicImpl(_283); 2920 } 2921 return this.topics[_283]; 2922 }; 2923 this.registerPublisher=function(_284,obj,_286){ 2924 var _284=this.getTopic(_284); 2925 _284.registerPublisher(obj,_286); 2926 }; 2927 this.subscribe=function(_287,obj,_289){ 2928 var _287=this.getTopic(_287); 2929 _287.subscribe(obj,_289); 2930 }; 2931 this.unsubscribe=function(_28a,obj,_28c){ 2932 var _28a=this.getTopic(_28a); 2933 _28a.unsubscribe(obj,_28c); 2934 }; 2935 this.publish=function(_28d,_28e){ 2936 var _28d=this.getTopic(_28d); 2937 var args=[]; 2938 if((arguments.length==2)&&(_28e.length)&&(typeof _28e!="string")){ 2939 args=_28e; 2940 }else{ 2941 var args=[]; 2942 for(var x=1;x<arguments.length;x++){ 2943 args.push(arguments[x]); 2944 } 2945 } 2946 _28d.sendMessage.apply(_28d,args); 2947 }; 2948 }; 2949 dojo.event.topic.TopicImpl=function(_291){ 2950 this.topicName=_291; 2951 var self=this; 2952 self.subscribe=function(_293,_294){ 2953 var tf=_294||_293; 2954 var to=(!_294)?dj_global:_293; 2955 dojo.event.kwConnect({srcObj:self,srcFunc:"sendMessage",adviceObj:to,adviceFunc:tf}); 2956 }; 2957 self.unsubscribe=function(_297,_298){ 2958 var tf=(!_298)?_297:_298; 2959 var to=(!_298)?null:_297; 2960 dojo.event.kwDisconnect({srcObj:self,srcFunc:"sendMessage",adviceObj:to,adviceFunc:tf}); 2961 }; 2962 self.registerPublisher=function(_29b,_29c){ 2963 dojo.event.connect(_29b,_29c,self,"sendMessage"); 2964 }; 2965 self.sendMessage=function(_29d){ 2966 }; 2967 }; 2968 dojo.provide("dojo.event.browser"); 2969 dojo.require("dojo.event"); 2970 dojo_ie_clobber=new function(){ 2971 this.clobberNodes=[]; 2972 function nukeProp(node,prop){ 2973 try{ 2974 node[prop]=null; 2975 } 2976 catch(e){ 2977 } 2978 try{ 2979 delete node[prop]; 2980 } 2981 catch(e){ 2982 } 2983 try{ 2984 node.removeAttribute(prop); 2985 } 2986 catch(e){ 2987 } 2988 } 2989 this.clobber=function(_2a0){ 2990 var na; 2991 var tna; 2992 if(_2a0){ 2993 tna=_2a0.getElementsByTagName("*"); 2994 na=[_2a0]; 2995 for(var x=0;x<tna.length;x++){ 2996 if(tna[x]["__doClobber__"]){ 2997 na.push(tna[x]); 2998 } 2999 } 3000 }else{ 3001 try{ 3002 window.onload=null; 3003 } 3004 catch(e){ 3005 } 3006 na=(this.clobberNodes.length)?this.clobberNodes:document.all; 3007 } 3008 tna=null; 3009 var _2a4={}; 3010 for(var i=na.length-1;i>=0;i=i-1){ 3011 var el=na[i]; 3012 if(el["__clobberAttrs__"]){ 3013 for(var j=0;j<el.__clobberAttrs__.length;j++){ 3014 nukeProp(el,el.__clobberAttrs__[j]); 3015 } 3016 nukeProp(el,"__clobberAttrs__"); 3017 nukeProp(el,"__doClobber__"); 3018 } 3019 } 3020 na=null; 3021 }; 3022 }; 3023 if(dojo.render.html.ie){ 3024 window.onunload=function(){ 3025 dojo_ie_clobber.clobber(); 3026 try{ 3027 if((dojo["widget"])&&(dojo.widget["manager"])){ 3028 dojo.widget.manager.destroyAll(); 3029 } 3030 } 3031 catch(e){ 3032 } 3033 try{ 3034 window.onload=null; 3035 } 3036 catch(e){ 3037 } 3038 try{ 3039 window.onunload=null; 3040 } 3041 catch(e){ 3042 } 3043 dojo_ie_clobber.clobberNodes=[]; 3044 }; 3045 } 3046 dojo.event.browser=new function(){ 3047 var _2a8=0; 3048 this.clean=function(node){ 3049 if(dojo.render.html.ie){ 3050 dojo_ie_clobber.clobber(node); 3051 } 3052 }; 3053 this.addClobberNode=function(node){ 3054 if(!node["__doClobber__"]){ 3055 node.__doClobber__=true; 3056 dojo_ie_clobber.clobberNodes.push(node); 3057 node.__clobberAttrs__=[]; 3058 } 3059 }; 3060 this.addClobberNodeAttrs=function(node,_2ac){ 3061 this.addClobberNode(node); 3062 for(var x=0;x<_2ac.length;x++){ 3063 node.__clobberAttrs__.push(_2ac[x]); 3064 } 3065 }; 3066 this.removeListener=function(node,_2af,fp,_2b1){ 3067 if(!_2b1){ 3068 var _2b1=false; 3069 } 3070 _2af=_2af.toLowerCase(); 3071 if(_2af.substr(0,2)=="on"){ 3072 _2af=_2af.substr(2); 3073 } 3074 if(node.removeEventListener){ 3075 node.removeEventListener(_2af,fp,_2b1); 3076 } 3077 }; 3078 this.addListener=function(node,_2b3,fp,_2b5,_2b6){ 3079 if(!node){ 3080 return; 3081 } 3082 if(!_2b5){ 3083 var _2b5=false; 3084 } 3085 _2b3=_2b3.toLowerCase(); 3086 if(_2b3.substr(0,2)!="on"){ 3087 _2b3="on"+_2b3; 3088 } 3089 if(!_2b6){ 3090 var _2b7=function(evt){ 3091 if(!evt){ 3092 evt=window.event; 3093 } 3094 var ret=fp(dojo.event.browser.fixEvent(evt)); 3095 if(_2b5){ 3096 dojo.event.browser.stopEvent(evt); 3097 } 3098 return ret; 3099 }; 3100 }else{ 3101 _2b7=fp; 3102 } 3103 if(node.addEventListener){ 3104 node.addEventListener(_2b3.substr(2),_2b7,_2b5); 3105 return _2b7; 3106 }else{ 3107 if(typeof node[_2b3]=="function"){ 3108 var _2ba=node[_2b3]; 3109 node[_2b3]=function(e){ 3110 _2ba(e); 3111 return _2b7(e); 3112 }; 3113 }else{ 3114 node[_2b3]=_2b7; 3115 } 3116 if(dojo.render.html.ie){ 3117 this.addClobberNodeAttrs(node,[_2b3]); 3118 } 3119 return _2b7; 3120 } 3121 }; 3122 this.isEvent=function(obj){ 3123 return (typeof obj!="undefined")&&(typeof Event!="undefined")&&(obj.eventPhase); 3124 }; 3125 this.currentEvent=null; 3126 this.callListener=function(_2bd,_2be){ 3127 if(typeof _2bd!="function"){ 3128 dojo.raise("listener not a function: "+_2bd); 3129 } 3130 dojo.event.browser.currentEvent.currentTarget=_2be; 3131 return _2bd.call(_2be,dojo.event.browser.currentEvent); 3132 }; 3133 this.stopPropagation=function(){ 3134 dojo.event.browser.currentEvent.cancelBubble=true; 3135 }; 3136 this.preventDefault=function(){ 3137 dojo.event.browser.currentEvent.returnValue=false; 3138 }; 3139 this.keys={KEY_BACKSPACE:8,KEY_TAB:9,KEY_ENTER:13,KEY_SHIFT:16,KEY_CTRL:17,KEY_ALT:18,KEY_PAUSE:19,KEY_CAPS_LOCK:20,KEY_ESCAPE:27,KEY_SPACE:32,KEY_PAGE_UP:33,KEY_PAGE_DOWN:34,KEY_END:35,KEY_HOME:36,KEY_LEFT_ARROW:37,KEY_UP_ARROW:38,KEY_RIGHT_ARROW:39,KEY_DOWN_ARROW:40,KEY_INSERT:45,KEY_DELETE:46,KEY_LEFT_WINDOW:91,KEY_RIGHT_WINDOW:92,KEY_SELECT:93,KEY_F1:112,KEY_F2:113,KEY_F3:114,KEY_F4:115,KEY_F5:116,KEY_F6:117,KEY_F7:118,KEY_F8:119,KEY_F9:120,KEY_F10:121,KEY_F11:122,KEY_F12:123,KEY_NUM_LOCK:144,KEY_SCROLL_LOCK:145}; 3140 this.revKeys=[]; 3141 for(var key in this.keys){ 3142 this.revKeys[this.keys[key]]=key; 3143 } 3144 this.fixEvent=function(evt){ 3145 if((!evt)&&(window["event"])){ 3146 var evt=window.event; 3147 } 3148 if((evt["type"])&&(evt["type"].indexOf("key")==0)){ 3149 evt.keys=this.revKeys; 3150 for(var key in this.keys){ 3151 evt[key]=this.keys[key]; 3152 } 3153 if((dojo.render.html.ie)&&(evt["type"]=="keypress")){ 3154 evt.charCode=evt.keyCode; 3155 } 3156 } 3157 if(dojo.render.html.ie){ 3158 if(!evt.target){ 3159 evt.target=evt.srcElement; 3160 } 3161 if(!evt.currentTarget){ 3162 evt.currentTarget=evt.srcElement; 3163 } 3164 if(!evt.layerX){ 3165 evt.layerX=evt.offsetX; 3166 } 3167 if(!evt.layerY){ 3168 evt.layerY=evt.offsetY; 3169 } 3170 if(evt.fromElement){ 3171 evt.relatedTarget=evt.fromElement; 3172 } 3173 if(evt.toElement){ 3174 evt.relatedTarget=evt.toElement; 3175 } 3176 this.currentEvent=evt; 3177 evt.callListener=this.callListener; 3178 evt.stopPropagation=this.stopPropagation; 3179 evt.preventDefault=this.preventDefault; 3180 } 3181 return evt; 3182 }; 3183 this.stopEvent=function(ev){ 3184 if(window.event){ 3185 ev.returnValue=false; 3186 ev.cancelBubble=true; 3187 }else{ 3188 ev.preventDefault(); 3189 ev.stopPropagation(); 3190 } 3191 }; 3192 }; 3193 dojo.hostenv.conditionalLoadModule({common:["dojo.event","dojo.event.topic"],browser:["dojo.event.browser"]}); 3194 dojo.hostenv.moduleLoaded("dojo.event.*"); 3195 -
templatetags/admin_modify.py
17 17 def class_name_to_underscored(name): 18 18 return '_'.join([s.lower() for s in word_re.findall(name)[:-1]]) 19 19 20 def include_admin_script(script_path):21 return '<script type="text/javascript" src="%s%s"></script>' % (settings.ADMIN_MEDIA_PREFIX, script_path)22 include_admin_script = register.simple_tag(include_admin_script)23 24 20 def submit_row(context): 25 21 opts = context['opts'] 26 22 change = context['change'] … … 163 159 return ''.join([str(f) for f in form_fields]) 164 160 output_all = register.simple_tag(output_all) 165 161 166 def auto_populated_field_script(auto_pop_fields, change = False):167 for field in auto_pop_fields:168 t = []169 if change:170 t.append('document.getElementById("id_%s")._changed = true;' % field.name)171 else:172 t.append('document.getElementById("id_%s").onchange = function() { this._changed = true; };' % field.name)173 174 add_values = ' + " " + '.join(['document.getElementById("id_%s").value' % g for g in field.prepopulate_from])175 for f in field.prepopulate_from:176 t.append('document.getElementById("id_%s").onkeyup = function() {' \177 ' var e = document.getElementById("id_%s");' \178 ' if(!e._changed) { e.value = URLify(%s, %s);} }; ' % (179 f, field.name, add_values, field.maxlength))180 return ''.join(t)181 auto_populated_field_script = register.simple_tag(auto_populated_field_script)182 183 def filter_interface_script_maybe(bound_field):184 f = bound_field.field185 if f.rel and isinstance(f.rel, models.ManyToManyRel) and f.rel.filter_interface:186 return '<script type="text/javascript">addEvent(window, "load", function(e) {' \187 ' SelectFilter.init("id_%s", "%s", %s, "%s"); });</script>\n' % (188 f.name, f.verbose_name, f.rel.filter_interface-1, settings.ADMIN_MEDIA_PREFIX)189 else:190 return ''191 filter_interface_script_maybe = register.simple_tag(filter_interface_script_maybe)192 193 162 def field_widget(parser, token): 194 163 bits = token.contents.split() 195 164 if len(bits) != 2: -
views/main.py
79 79 myappend('_' + item) 80 80 return "".join(res) 81 81 82 def get_javascript_imports(opts, auto_populated_fields, field_sets):83 # Put in any necessary JavaScript imports.84 js = ['js/core.js', 'js/admin/RelatedObjectLookups.js']85 if auto_populated_fields:86 js.append('js/urlify.js')87 if opts.has_field_type(models.DateTimeField) or opts.has_field_type(models.TimeField) or opts.has_field_type(models.DateField):88 js.extend(['js/calendar.js', 'js/admin/DateTimeShortcuts.js'])89 if opts.get_ordered_objects():90 js.extend(['js/getElementsBySelector.js', 'js/dom-drag.js' , 'js/admin/ordering.js'])91 if opts.admin.js:92 js.extend(opts.admin.js)93 seen_collapse = False94 for field_set in field_sets:95 if not seen_collapse and 'collapse' in field_set.classes:96 seen_collapse = True97 js.append('js/admin/CollapsedFieldsets.js')98 99 for field_line in field_set:100 try:101 for f in field_line:102 if f.rel and isinstance(f, models.ManyToManyField) and f.rel.filter_interface:103 js.extend(['js/SelectBox.js' , 'js/SelectFilter2.js'])104 raise StopIteration105 except StopIteration:106 break107 return js108 109 82 class AdminBoundField(object): 110 83 def __init__(self, field, field_mapping, original): 111 84 self.field = field … … 190 163 def render_change_form(model, manipulator, context, add=False, change=False, form_url=''): 191 164 opts = model._meta 192 165 app_label = opts.app_label 193 auto_populated_fields = [f for f in opts.fields if f.prepopulate_from] 166 auto_populated_fields = add and [f for f in opts.fields if f.prepopulate_from] 167 many_to_many_filters = [f for f in opts.many_to_many if isinstance(f.rel, models.ManyToManyRel) and f.rel.filter_interface] 168 date_time_fields = [f for f in opts.fields if f.get_internal_type() in ['DateField', 'TimeField', 'DateTimeField']] 194 169 field_sets = opts.admin.get_field_sets(opts) 195 170 original = getattr(manipulator, 'original_object', None) 196 171 bound_field_sets = [field_set.bind(context['form'], original, AdminBoundFieldSet) for field_set in field_sets] … … 201 176 'add': add, 202 177 'change': change, 203 178 'has_delete_permission': context['perms'][app_label][opts.get_delete_permission()], 204 'has_change_permission': context['perms'][app_label][opts.get_change_permission()],205 179 'has_file_field': opts.has_field_type(models.FileField), 206 180 'has_absolute_url': hasattr(model, 'get_absolute_url'), 207 181 'auto_populated_fields': auto_populated_fields, 182 'many_to_many_filters': many_to_many_filters, 183 'date_time_fields': date_time_fields, 208 184 'bound_field_sets': bound_field_sets, 209 185 'first_form_field_id': first_form_field_id, 210 'javascript_imports': get_javascript_imports(opts, auto_populated_fields, field_sets),211 186 'ordered_objects': ordered_objects, 212 187 'inline_related_objects': inline_related_objects, 213 188 'form_url': form_url, … … 220 195 "admin/%s/change_form" % app_label, 221 196 "admin/change_form"], context_instance=context) 222 197 198 223 199 def index(request): 224 200 return render_to_response('admin/index', {'title': _('Site administration')}, context_instance=template.RequestContext(request)) 225 201 index = staff_member_required(never_cache(index)) … … 264 240 post_url_continue += "?_popup=1" 265 241 return HttpResponseRedirect(post_url_continue % pk_value) 266 242 if request.POST.has_key("_popup"): 267 return HttpResponse('<script type="text/javascript">opener.d ismissAddAnotherPopup(window, %s, "%s");</script>' % \243 return HttpResponse('<script type="text/javascript">opener.django.admin.RelatedLookups.dismissAddAnotherPopup(window, %s, "%s");</script>' % \ 268 244 (pk_value, str(new_object).replace('"', '\\"'))) 269 245 elif request.POST.has_key("_addanother"): 270 246 request.user.message_set.create(message=msg + ' ' + (_("You may add another %s below.") % opts.verbose_name)) -
templates/widget/foreign.html
2 2 {% output_all bound_field.form_fields %} 3 3 {% if bound_field.raw_id_admin %} 4 4 {% if bound_field.field.rel.limit_choices_to %} 5 <a href="../../../{{ bound_field.field.rel.to.app_label }}/{{ bound_field.field.rel.to.module_name }}/?{% for limit_choice in bound_field.field.rel.limit_choices_to.items %}{% if not forloop.first %}&{% endif %}{{ limit_choice|join:"=" }}{% endfor %}" class="related-lookup" id="lookup_{{ bound_field.element_id }}" onclick="return showRelatedObjectLookupPopup(this);"> <img src="{% admin_media_prefix %}img/admin/selector-search.gif" width="16" height="16" alt="Lookup"></a>5 <a href="../../../{{ bound_field.field.rel.to.app_label }}/{{ bound_field.field.rel.to.module_name }}/?{% for limit_choice in bound_field.field.rel.limit_choices_to.items %}{% if not forloop.first %}&{% endif %}{{ limit_choice|join:"=" }}{% endfor %}" class="related-lookup" id="lookup_{{ bound_field.element_id }}" onclick="return django.admin.RelatedLookups.showRelatedObjectLookupPopup(this);"> <img src="{% admin_media_prefix %}img/admin/selector-search.gif" width="16" height="16" alt="Lookup"></a> 6 6 {% else %} 7 <a href="{{ bound_field.related_url }}" class="related-lookup" id="lookup_{{ bound_field.element_id }}" onclick="return showRelatedObjectLookupPopup(this);"> <img src="{% admin_media_prefix %}img/admin/selector-search.gif" width="16" height="16" alt="Lookup"></a>7 <a href="{{ bound_field.related_url }}" class="related-lookup" id="lookup_{{ bound_field.element_id }}" onclick="return django.admin.RelatedLookups.showRelatedObjectLookupPopup(this);"> <img src="{% admin_media_prefix %}img/admin/selector-search.gif" width="16" height="16" alt="Lookup"></a> 8 8 {% endif %} 9 9 {% else %} 10 10 {% if bound_field.needs_add_label %} 11 <a href="{{ bound_field.related_url }}add/" class="add-another" id="add_{{ bound_field.element_id }}" onclick="return showAddAnotherPopup(this);"> <img src="{% admin_media_prefix %}img/admin/icon_addlink.gif" width="10" height="10" alt="Add Another"/></a>11 <a href="{{ bound_field.related_url }}add/" class="add-another" id="add_{{ bound_field.element_id }}"> <img src="{% admin_media_prefix %}img/admin/icon_addlink.gif" width="10" height="10" alt="Add Another"/></a> 12 12 {% endif %}{% endif %} -
templates/admin/change_form.html
2 2 {% load i18n admin_modify adminmedia %} 3 3 {% block extrahead %}{{ block.super }} 4 4 <script type="text/javascript" src="../../../jsi18n/"></script> 5 {% for js in javascript_imports %}{% include_admin_script js %}{% endfor %} 5 <script type="text/javascript" src="../../../../media/js/dojo/dojo.js"></script> 6 <script type="text/javascript"> 7 dojo.setModulePrefix('django', '../django'); 8 var admin_media_prefix = '{% admin_media_prefix %}'; 9 {% if add %} 10 var first_form_field_id = '{{ first_form_field_id }}'; 11 {% endif %} 12 {% if auto_populated_fields %} 13 var auto_populate_array = { 14 {% for field in auto_populated_fields %} 15 'id_{{ field.name }}': [{% for source_field in field.prepopulate_from %}'id_{{ source_field }}'{% if not forloop.last %},{% endif %}{% endfor %}]{% if not forloop.last %},{% endif %} 16 {% endfor %} 17 }; 18 {% endif %} 19 {% if many_to_many_filters %} 20 var select_filter_array = { 21 {% for field in many_to_many_filters %} 22 'id_{{ field.name }}': ['{{ field.verbose_name }}', {% ifequal field.rel.filter_interface 1 %}0{% else %}1{% endifequal %}, admin_media_prefix]{% if not forloop.last %},{% endif %} 23 {% endfor %} 24 }; 25 {% endif %} 26 {% if date_time_fields %} 27 var date_time_fields = true; 28 {% endif %} 29 dojo.require('django.admin.*'); 30 </script> 6 31 {% endblock %} 7 32 {% block stylesheet %}{% admin_media_prefix %}css/forms.css{% endblock %} 8 33 {% block coltype %}{% if ordered_objects %}colMS{% else %}colM{% endif %}{% endblock %} … … 37 62 {% for bound_field_line in bound_field_set %} 38 63 {% admin_field_line bound_field_line %} 39 64 {% for bound_field in bound_field_line %} 40 {% filter_interface_script_maybe bound_field %}41 65 {% endfor %} 42 66 {% endfor %} 43 67 </fieldset> … … 55 79 {% for related_object in inline_related_objects %}{% edit_inline related_object %}{% endfor %} 56 80 {% block after_related_objects %}{% endblock %} 57 81 {% submit_row %} 58 {% if add %}59 <script type="text/javascript">document.getElementById("{{ first_form_field_id }}").focus();</script>60 {% endif %}61 {% if auto_populated_fields %}62 <script type="text/javascript">63 {% auto_populated_field_script auto_populated_fields change %}64 </script>65 {% endif %}66 82 </div> 67 83 </form></div> 68 84 {% endblock %}