Anonymous avatar Anonymous committed 71779ed

fix click.

Comments (0)

Files changed (1)

static/js/src/page.js

                   $('link_from_'+self.link_types_hide[selected]).hide();
               }
               
+         insertLinkHandler = function(e) {
+                Event.stop(e);
+
+                var link_type = $('link_type').getValue();
+                var link_text = $('link_label').getValue();
+                var link_page = $('link_page').getValue();
+                var url = $('link_url').getValue();
+
+                if (link_page == null || url == null)
+                  return
+
+                if (link_type == "page") {
+                    tb.replaceSelection('[' + (link_text == '' ? decodeURIComponent(link_page.replace(Site.url, '').replace(/_/g, " ").replace(/\//, '')) : link_text) + '](' + link_page + ')');
+                } else {
+                    tb.replaceSelection('[' + (link_text == '' ? 'Link Text' : link_text) + '](' + (url == '' ? 'http://link_url/' : url) + ')');
+                }
+                self.link_window.close();
+                this.stopObserving("click", arguments.callee, false);
+            }
+              
               self.link_window.open();
               display_link_type($('link_type').getValue())
               
               
               var tb = this;
               var selection = this.getSelection();  
-              $("slink").observe('click', function(e) {
-                  Event.stop(e);
-                  var link_type = $('link_type').getValue();
-                  var link_text = $('link_label').getValue();
-                  if (link_type == "page") {
-                      tb.replaceSelection('[' + (link_text == '' ? 'Link Text' : link_text) + '](' + $('link_page').getValue() + ')');
-                  } else {
-                      var url = $('link_url').getValue();
-;                     tb.replaceSelection('[' + (link_text == '' ? 'Link Text' : link_text) + '](' + (url == '' ? 'http://link_url/' : url).replace(/^(?!(f|ht)tps?:\/\/)/,'http://') + ')');
-                  }
-                  self.link_window.close();
-                  return false;
-              }, false);
-              return
+              $("slink").observe("click", insertLinkHandler, false);
+              
           },{  
               id: 'markdown_link_button'  
           });  
                       }
                     });
                 }
-                
-                return false;
+                this.stopObserving("click", arguments.callee, false);
             }
             
             $("ssnippet").observe("click", insert_snippet, false);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.