includes/clientside/static/ajax.js
changeset 869 58bc29c14a4d
parent 823 4596c40aaa94
child 870 82bbfe3dc8a0
equal deleted inserted replaced
868:75dcd8cf6232 869:58bc29c14a4d
  1377         }
  1377         }
  1378       }
  1378       }
  1379     });
  1379     });
  1380 }
  1380 }
  1381 
  1381 
  1382 window.ajaxPluginAction = function(action, plugin_filename, btnobj)
  1382 window.ajaxPluginAction = function(action, plugin_filename, btnobj, send_confirm)
  1383 {
  1383 {
  1384   // if installing, uninstalling, or re-importing, confirm
  1384   // if installing, uninstalling, or re-importing, confirm
  1385   if ( action == 'install' || action == 'uninstall' || action == 'reimport' )
  1385   if ( action == 'install' || action == 'uninstall' || action == 'reimport' )
  1386   {
  1386   {
  1387     var prompt = miniPrompt(function(div)
  1387     var prompt = miniPrompt(function(div)
  1418         btn_go.onclick = function()
  1418         btn_go.onclick = function()
  1419         {
  1419         {
  1420           ajaxPluginAction(this._action + '_confirm', this._filename, this._button);
  1420           ajaxPluginAction(this._action + '_confirm', this._filename, this._button);
  1421           miniPromptDestroy(this);
  1421           miniPromptDestroy(this);
  1422           return false;
  1422           return false;
  1423         }
  1423         };
  1424         btn_cancel.onclick = function()
  1424         btn_cancel.onclick = function()
  1425         {
  1425         {
  1426           miniPromptDestroy(this);
  1426           miniPromptDestroy(this);
  1427           return false;
  1427           return false;
  1428         }
  1428         };
  1429       });
  1429       });
  1430     return true;
  1430     return true;
  1431   }
  1431   }
  1432   action = action.replace(/_confirm$/, '');
  1432   action = action.replace(/_confirm$/, '');
  1433   // white-out the plugin info box
  1433   // white-out the plugin info box
  1434   if ( btnobj )
  1434   if ( btnobj )
  1435   {
  1435   {
  1436     var td = btnobj.parentNode.parentNode.parentNode.parentNode;
  1436     var td = btnobj.parentNode.parentNode.parentNode.parentNode;
  1437     var blackbox = whiteOutElement(td);
  1437     var blackbox = whiteOutElement(td);
  1438   }
  1438   }
  1439   var request = toJSONString({
  1439   var request = {
  1440       mode: action,
  1440       mode: action,
  1441       plugin: plugin_filename
  1441       plugin: plugin_filename
  1442     });
  1442     };
       
  1443   if ( send_confirm )
       
  1444   {
       
  1445     request.install_confirmed = true;
       
  1446   }
       
  1447   request = toJSONString(request);
  1443   ajaxPost(makeUrlNS('Admin', 'PluginManager/action.json'), 'r=' + ajaxEscape(request), function(ajax)
  1448   ajaxPost(makeUrlNS('Admin', 'PluginManager/action.json'), 'r=' + ajaxEscape(request), function(ajax)
  1444     {
  1449     {
  1445       if ( ajax.readyState == 4 && ajax.status == 200 )
  1450       if ( ajax.readyState == 4 && ajax.status == 200 )
  1446       {
  1451       {
  1447         var response = String(ajax.responseText + '');
  1452         var response = String(ajax.responseText + '');
  1449         {
  1454         {
  1450           handle_invalid_json(response);
  1455           handle_invalid_json(response);
  1451           return false;
  1456           return false;
  1452         }
  1457         }
  1453         response = parseJSON(response);
  1458         response = parseJSON(response);
       
  1459         if ( blackbox )
       
  1460         {
       
  1461           blackbox.parentNode.removeChild(blackbox);
       
  1462         }
  1454         if ( response.success )
  1463         if ( response.success )
  1455         {
  1464         {
  1456           if ( blackbox )
       
  1457           {
       
  1458             blackbox.parentNode.removeChild(blackbox);
       
  1459           }
       
  1460           ajaxPage( namespace_list['Admin'] + 'PluginManager' );
  1465           ajaxPage( namespace_list['Admin'] + 'PluginManager' );
  1461           return true;
  1466           return true;
  1462         } 
  1467         }
       
  1468         if ( response.need_confirm )
       
  1469         {
       
  1470           miniPromptMessage({
       
  1471               title: $lang.get(response.confirm_title),
       
  1472               message: $lang.get(response.confirm_body),
       
  1473               buttons: [
       
  1474                 {
       
  1475                   text: $lang.get('acppl_btn_install'),
       
  1476                   color: 'red',
       
  1477                   style: {
       
  1478                     fontWeight: 'bold',
       
  1479                   },
       
  1480                   onclick: function() {
       
  1481                     ajaxPluginAction(action + '_confirm', plugin_filename, btnobj, true);
       
  1482                     miniPromptDestroy(this);
       
  1483                   }
       
  1484                 },
       
  1485                 {
       
  1486                   text: $lang.get('etc_cancel'),
       
  1487                   color: 'blue',
       
  1488                   onclick: function() {
       
  1489                     miniPromptDestroy(this);
       
  1490                   }
       
  1491                 }
       
  1492               ]
       
  1493             });
       
  1494           return true;
       
  1495         }
  1463         // wait for fade effect to finish its run
  1496         // wait for fade effect to finish its run
  1464         setTimeout(function()
  1497         setTimeout(function()
  1465           {
  1498           {
  1466             miniPrompt(function(div)
  1499             miniPrompt(function(div)
  1467               {
  1500               {