Created
          September 19, 2012 11:59 
        
      - 
      
- 
        Save p3drosola/3749285 to your computer and use it in GitHub Desktop. 
    Task preview
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | $(function () { | |
| var regex = /\/#!\/projects\/[^\/]+\/tasks\/(\d+)\/?/; | |
| function showModal (model) { | |
| console.log('previewing task#' + model.id, model); | |
| var view, dialog; | |
| view = new Teambox.Views.Thread({model: model}); | |
| dialog = (new Teambox.Views.Dialog({ | |
| extraClassName: 'share' | |
| , header: 'Task Quickview' | |
| , content: view.render().el | |
| })).open(); | |
| dialog.$('.dialog_box').css({width: '600px', marginLeft: '-300px'}); | |
| } | |
| $(document).on('click', '.textilized a, .page_content a', function (e) { | |
| console.log('intercepted click on an anchor', e); | |
| var match, model, view, dialog; | |
| if (e.metaKey) { | |
| match = $(this).attr('href').match(regex); | |
| if (match[1]) { | |
| e.preventDefault(); | |
| model = Teambox.collections.tasks.get(match[1]); | |
| if (!model){ | |
| model = new Teambox.Models.Task({ | |
| id: match[1] | |
| }); | |
| model.fetch({ | |
| success: function (model){ | |
| Teambox.collections.tasks.add(model); | |
| showModal(model); | |
| } | |
| }); | |
| } else { | |
| showModal(model); | |
| } | |
| } | |
| } | |
| }); | |
| }); | |
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment