Author: leidel
Date: Sat Dec 6 09:43:24 2008
New Revision: 265
Modified:
trunk/pages/media/pages/javascript/change_form.js
Log:
Add prompt to confirm language and template change if a page is not saved
Modified: trunk/pages/media/pages/javascript/change_form.js
==============================================================================
--- trunk/pages/media/pages/javascript/change_form.js (original)
+++ trunk/pages/media/pages/javascript/change_form.js Sat Dec 6 09:43:24
2008
@@ -1,15 +1,22 @@
$(document).ready(function() {
- $('#id_template').change(function() {
- var index = this.selectedIndex;
- var array = window.location.href.split('?');
- var query = $.query.set('template',
this.options[index].value).toString();
- window.location.href=array[0]+query;
- });
- $('#id_language').change(function() {
- var index = this.selectedIndex;
- var array = window.location.href.split('?');
- var query = $.query.set('language',
this.options[index].value).toString();
- window.location.href=array[0]+query;
+ // Confirm language and template change if page is not saved
+ var selects = ["language", "template"];
+ var original_values = Array()
+ $.each(selects, function(i, name){
+ original_values[i] = $('#id_'+name)[0].selectedIndex;
+ $('#id_'+name).change(function() {
+ var index = this.selectedIndex;
+ if (index != original_values[i]) {
+ var array = window.location.href.split('?');
+ var query = $.query.set(name,
this.options[index].value).toString();
+ var answer = confirm(gettext("Are you sure you want to
change the "+name+" without saving the page first?"));
+ if (answer) {
+ window.location.href = array[0]+query;
+ } else {
+ this.selectedIndex = original_values[i];
+ }
+ }
+ });
});
document.getElementById("id_title").focus();
var template = $.query.get('template');
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pinax-updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pinax-updates?hl=en
-~----------~----~----~----~------~----~------~--~---