Browse Source

Fix edit profile form generating api key

Angel Fernando Quiroz Campos 9 years ago
parent
commit
fff4a7a2da
2 changed files with 25 additions and 24 deletions
  1. 21 20
      main/auth/profile.php
  2. 4 4
      main/inc/ajax/user_manager.ajax.php

+ 21 - 20
main/auth/profile.php

@@ -79,6 +79,20 @@ $(document).ready(function() {
         $cropButton.addClass("hidden");
         return false;
     });
+
+    $(\'#id_generate_api_key\').on(\'click\', function (e) {
+        e.preventDefault();
+
+        $.ajax({
+            contentType: "application/x-www-form-urlencoded",
+            type: "POST",
+            url: "'.api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=generate_api_key",
+            data: "num_key_id="+"",
+            success: function(datos) {
+                $("#div_api_key").html(datos);
+            }
+        });
+    });
 });
 
 function confirmation(name) {
@@ -94,19 +108,6 @@ function show_image(image,width,height) {
     window_x = window.open(image,\'windowX\',\'width=\'+ width + \', height=\'+ height + \'\');
 
 }
-function generate_open_id_form() {
-    $.ajax({
-        contentType: "application/x-www-form-urlencoded",
-        beforeSend: function(objeto) {
-        /*$("#div_api_key").html("Loading...");*/ },
-        type: "POST",
-        url: "'.api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=generate_api_key",
-        data: "num_key_id="+"",
-        success: function(datos) {
-         $("#div_api_key").html(datos);
-        }
-    });
-}
 
 function hide_icon_edit(element_html)  {
     ident="#edit_image";
@@ -404,15 +405,15 @@ if (api_get_setting('profile', 'apikeys') == 'true') {
         array('size' => 40, 'id' => 'id_api_key_generate')
     );
     $form->addElement('html', '</div>');
-    $form->addElement(
-        'button',
+    $form->addButton(
         'generate_api_key',
         get_lang('GenerateApiKey'),
-        array(
-            'id' => 'id_generate_api_key',
-            'onclick' => 'generate_open_id_form(); return false;',
-        )
-    ); //generate_open_id_form()
+        'cogs',
+        'default',
+        'default',
+        null,
+        ['id' => 'id_generate_api_key']
+    );
 }
 //    SUBMIT
 if (is_profile_editable()) {

+ 4 - 4
main/inc/ajax/user_manager.ajax.php

@@ -95,10 +95,10 @@ switch ($action) {
             $num = UserManager::update_api_key($user_id, $api_service);
             $array_list_key = UserManager::get_api_keys($user_id, $api_service);
             ?>
-            <div class="row">
-                <div class="label"><?php echo get_lang('MyApiKey'); ?></div>
-                <div class="formw">
-                <input type="text" name="api_key_generate" id="id_api_key_generate" size="40" value="<?php echo $array_list_key[$num]; ?>"/>
+            <div class="form-group">
+                <label class="col-sm-2 control-label"><?php echo get_lang('MyApiKey'); ?></label>
+                <div class="col-sm-8">
+                    <input type="text" name="api_key_generate" id="id_api_key_generate" class="form-control" value="<?php echo $array_list_key[$num]; ?>"/>
                 </div>
             </div>
             <?php