includes/clientside/sbedit.js
changeset 1274 673a1b6712fa
parent 1039 4226cedb3bc4
equal deleted inserted replaced
1273:3351055b467e 1274:673a1b6712fa
    16         ajaxUpdateSidebarOrder();
    16         ajaxUpdateSidebarOrder();
    17       }
    17       }
    18     });
    18     });
    19   };
    19   };
    20   
    20   
       
    21 addOnloadHook(function()
       
    22 	{
       
    23 		attachHook('admin_page_onload', 'sbedit_conditional_init(t, qs);');
       
    24 	});
       
    25 
       
    26 // if the page was loaded directly this will be used instead
    21 addOnloadHook(sbedit_load);
    27 addOnloadHook(sbedit_load);
       
    28 
       
    29 function sbedit_conditional_init(t, qs)
       
    30 {
       
    31 	if ( t != namespace_list.Admin + 'EditSidebar' )
       
    32 		return false;
       
    33 	
       
    34 	if ( qs == '&action=new&id=0' )
       
    35 		setType(document.getElementById('sbedit_create_select_type'));
       
    36 	else
       
    37 		sbedit_load();
       
    38 }
    22 
    39 
    23 function serialize_sidebar()
    40 function serialize_sidebar()
    24 {
    41 {
    25   var columns = {};
    42   var columns = {};
    26   var i = 0;
    43   var i = 0;
    82     .animate({ width: 500, height: 400, top: top, left: (getWidth() / 2) - 250 }, 400, function()
    99     .animate({ width: 500, height: 400, top: top, left: (getWidth() / 2) - 250 }, 400, function()
    83       {
   100       {
    84         var whitey = whiteOutElement(this);
   101         var whitey = whiteOutElement(this);
    85         $(this).append('<textarea style="width: 98%; height: 360px; margin: 0 auto; display: block;" rows="20" cols="80"></textarea>');
   102         $(this).append('<textarea style="width: 98%; height: 360px; margin: 0 auto; display: block;" rows="20" cols="80"></textarea>');
    86         $(this).append('<p style="text-align: center;"><a href="#" onclick="sbedit_edit_save(this); return false;">' + $lang.get('etc_save_changes') + '</a> | <a href="#" onclick="sbedit_edit_cancel(this); return false;">' + $lang.get('etc_cancel') + '</a></p>');
   103         $(this).append('<p style="text-align: center;"><a href="#" onclick="sbedit_edit_save(this); return false;">' + $lang.get('etc_save_changes') + '</a> | <a href="#" onclick="sbedit_edit_cancel(this); return false;">' + $lang.get('etc_cancel') + '</a></p>');
    87         $.get(makeUrlNS('Special', 'EditSidebar', 'action=getsource&noheaders&id=' + item_id), {}, function(response, statustext)
   104         $.get(makeUrlNS('Admin', 'EditSidebar', 'action=getsource&noheaders&id=' + item_id), {}, function(response, statustext)
    88           {
   105           {
    89             $('textarea', box).val(response);
   106             $('textarea', box).val(response);
    90             $(whitey).remove();
   107             $(whitey).remove();
    91             
   108             
    92             $(box).attr('enano:item_id', item_id);
   109             $(box).attr('enano:item_id', item_id);
    98 function sbedit_edit_save(a)
   115 function sbedit_edit_save(a)
    99 {
   116 {
   100   var box = a.parentNode.parentNode;
   117   var box = a.parentNode.parentNode;
   101   var parent = document.getElementById('block:' + $(box).attr('enano:item_id'));
   118   var parent = document.getElementById('block:' + $(box).attr('enano:item_id'));
   102   var whitey = whiteOutElement(box);
   119   var whitey = whiteOutElement(box);
   103   $.post(makeUrlNS('Special', 'EditSidebar', 'noheaders&action=save&id=' + $(box).attr('enano:item_id')), { content: $('textarea', box).attr('value') }, function(response, statustext)
   120   $.post(makeUrlNS('Admin', 'EditSidebar', 'noheaders&action=save&id=' + $(box).attr('enano:item_id')), { content: $('textarea', box).attr('value') }, function(response, statustext)
   104     {
   121     {
   105       whiteOutReportSuccess(whitey);
   122       whiteOutReportSuccess(whitey);
   106       setTimeout(function()
   123       setTimeout(function()
   107         {
   124         {
   108           sbedit_close_editor(parent, box);
   125           sbedit_close_editor(parent, box);
   185 {
   202 {
   186   var parent = box;
   203   var parent = box;
   187   var id = parseInt($(parent).attr('id').replace(/^block:/, ''));
   204   var id = parseInt($(parent).attr('id').replace(/^block:/, ''));
   188   var whitey = whiteOutElement(parent);
   205   var whitey = whiteOutElement(parent);
   189   
   206   
   190   $.get(makeUrlNS('Special', 'EditSidebar', 'action=delete&ajax=true&noheaders&id=' + id), function(response, statustext)
   207   $.get(makeUrlNS('Admin', 'EditSidebar', 'action=delete&ajax=true&noheaders&id=' + id), function(response, statustext)
   191     {
   208     {
   192       if ( response == 'GOOD' )
   209       if ( response == 'GOOD' )
   193       {
   210       {
   194         whiteOutReportSuccess(whitey);
   211         whiteOutReportSuccess(whitey);
   195         setTimeout(function()
   212         setTimeout(function()
   221         case 13:
   238         case 13:
   222           // enter
   239           // enter
   223           var whitey = whiteOutElement(this.parentNode);
   240           var whitey = whiteOutElement(this.parentNode);
   224           var me = this;
   241           var me = this;
   225           var id = parseInt($(parent).attr('id').replace(/^block:/, ''));
   242           var id = parseInt($(parent).attr('id').replace(/^block:/, ''));
   226           $.post(makeUrlNS('Special', 'EditSidebar', 'ajax&noheaders&action=rename&id='+id), { newname: $(this).attr('value') }, function(response, statustext)
   243           $.post(makeUrlNS('Admin', 'EditSidebar', 'ajax&noheaders&action=rename&id='+id), { newname: $(this).attr('value') }, function(response, statustext)
   227             {
   244             {
   228               if ( response == 'GOOD' )
   245               if ( response == 'GOOD' )
   229               {
   246               {
   230                 whiteOutReportSuccess(whitey);
   247                 whiteOutReportSuccess(whitey);
   231                 setTimeout(function()
   248                 setTimeout(function()
   254 
   271 
   255 function sbedit_disenable_block(a)
   272 function sbedit_disenable_block(a)
   256 {
   273 {
   257   var parent = sbedit_get_parent(a);
   274   var parent = sbedit_get_parent(a);
   258   var whitey = whiteOutElement(parent);
   275   var whitey = whiteOutElement(parent);
   259   $.get(makeUrlNS('Special', 'EditSidebar', 'action=disenable&ajax=true&noheaders&id=' + parseInt($(parent).attr('id').replace(/^block:/, ''))), {}, function(response, statustext)
   276   $.get(makeUrlNS('Admin', 'EditSidebar', 'action=disenable&ajax=true&noheaders&id=' + parseInt($(parent).attr('id').replace(/^block:/, ''))), {}, function(response, statustext)
   260     {
   277     {
   261       if ( response == 'GOOD' )
   278       if ( response == 'GOOD' )
   262       {
   279       {
   263         whiteOutReportSuccess(whitey);
   280         whiteOutReportSuccess(whitey);
   264         $(parent).toggleClass('disabled');
   281         $(parent).toggleClass('disabled');
   299         $(msg).fadeOut(500, function() { $(this).remove(); });
   316         $(msg).fadeOut(500, function() { $(this).remove(); });
   300       }, 1000);
   317       }, 1000);
   301     unsetAjaxLoading();
   318     unsetAjaxLoading();
   302     return false;
   319     return false;
   303   }
   320   }
   304   $.post(makeUrlNS('Special', 'EditSidebar', 'update_order'), { order: ser }, function(response, statustext)
   321   $.post(makeUrlNS('Admin', 'EditSidebar', 'update_order'), { order: ser }, function(response, statustext)
   305     {
   322     {
   306       var msg = document.createElement('div');
   323       var msg = document.createElement('div');
   307       $(msg)
   324       $(msg)
   308         .addClass('info-box-mini')
   325         .addClass('info-box-mini')
   309         .text($lang.get('sbedit_msg_order_saved'))
   326         .text($lang.get('sbedit_msg_order_saved'))
   317         }, 1000);
   334         }, 1000);
   318       unsetAjaxLoading();
   335       unsetAjaxLoading();
   319     }, 'json');
   336     }, 'json');
   320 }
   337 }
   321 
   338 
       
   339 function setType(input)
       
   340 {
       
   341 	val = input.value;
       
   342 	if(!val)
       
   343 	{
       
   344 		return false;
       
   345 	}
       
   346 	var divs = getElementsByClassName(document, 'div', 'sbadd_block');
       
   347 	for(var i in divs)
       
   348 	{
       
   349 		if(divs[i].id == 'blocktype_'+val) divs[i].style.display = 'block';
       
   350 		else divs[i].style.display = 'none';
       
   351 	}
       
   352 }