1. Benoit Chesneau
  2. couchit

Commits

Benoit Chesneau  committed f0c69e3

fix snippet box focus

  • Participants
  • Parent commits 8410f4c
  • Branches default

Comments (0)

Files changed (3)

File static/js/src/application.js

View file
         return true;
         
     }
-})
+});
 
 
 document.observe("dom:loaded", function() {

File static/js/src/page.js

View file
                     }).join('\n')
                     snippet = "\n\n    :::" + $('snippet_language').getValue() +
                     "\n" + code;
-                    obj.insertAfterSelection(snippet);
+                    obj.replaceSelection(snippet);
                     self.snippet_window.close();
                     $('snippet_content').value = "";
                 } else {
                          }).join('\n');
                          
                          snippet = " \n\n    :::" + data['language'] + "\n"  + code;
-                         obj.insertAfterSelection(snippet);
+                         obj.replaceSelection(snippet);
                          self.snippet_window.close();
                          $('snippet_content').value = "";
                       },
                       onFailure: function() {
-                          alert("fuck")
+                          alert("mmm... error while trying to fetch content from friendpaste:(")
                       }
                     });
                 }
                 Event.stop(e);
                 self.snippet_window.close();
                 return false;
-            })
+            });
+            
+            $('snippet_url', 'snippet_language', 'snippet_content').each(function(el) {
+                el.observe("focus", function(e) {
+                    if (this.id == "snippet_url")
+                        $('sfp').checked = true;
+                    else
+                        $('si').checked = true;
+                }, false);
+            });
+            
+            
+            
+            
           },{  
               id: 'markdown_snippet_button'  
           });

File templates/page/show.html

View file
      <div id="snippet_window_close"></div>
      <div id="snippet_window_title">Insert a snippet</div>
      <form name="fsnippet" id="fsnippet">
-         <p class="choice"><input type="radio" name="snippet_from" value="0" class="tsnippet" checked="checked" />Paste it here :</p>           
+         <p class="choice"><input type="radio" name="snippet_from"  id="si" value="0" class="tsnippet" checked="checked" />Paste it here :</p>           
          <table>
              <tr>
                  <th><label for="snippet_language">Programming language</label></th>
                 </td>
             </tr>
         </table>
-        <p class="choice"><input type="radio" name="snippet_from"  value="1" class="tsnippet" />Or insert a snippet from <a href="http://www.friendpaste.com">Friendpaste</a></p>
+        <p class="choice"><input type="radio" name="snippet_from"  id="sfp" value="1" class="tsnippet" />Or insert a snippet from <a href="http://www.friendpaste.com">Friendpaste</a></p>
          <table>
              <tr>
                  <th>URL:</th>