<commit_before>Joshfire.define(['joshfire/app', 'joshfire/class', './src/tree.data', './src/tree.ui.phone', 'joshfire/utils/splashscreen', 'joshfire/uielements/panel', './src/lib/ba-linkify', 'src/ui-components'], function(BaseApp, Class, Data, UI, Splash, Panel, linkify, UItpl) {
  
  return Class(BaseApp, {

    id: 'defaultApp',

    uiClass: UI,

    dataClass: Data,

    setup: function(callback) {
      var _this = this,
          footer = _this.ui.element('/footer'),
          itemList = _this.ui.element('/content/itemList'),
          detailPanel = _this.ui.element('/content/detail'),
          twitterPanel = _this.ui.element('/content/detail/twitter'),
          prevBtn = _this.ui.element('/header/prev'),
          logo = _this.ui.element('/header/title');

      this.splash = new Splash();

      // Change app name globally
      document.title = Joshfire.factory.config.app.name;

      // Populate footer
      footer.subscribe('data', function(event, data) {
        // We have data, remove splashscreen
        // Todo: it may better to remove it "onAfterShow" or "onAfterInsert"
        _this.splash.remove();

        // Select the first tab on our footer
        footer.selectByIndex(0);
      });

      // Handle clicks on footer
      footer.subscribe('select', function(event, data) {
        var datasourceId = data[0][0];

        // if about page
        if(datasourceId == 'about') {
          console.log("about");
          _this.ui.element('/content/about').show();
          return;
        }

        // Set the new dataPath
        _this.ui.element('/content/itemList').setDataPath('/datasource/' + datasourceId + '/');

        // Show itemList, because we could be on a detail panel
        _this.ui.element('/content').switchTo('itemList');

        // Hide prev button (todo: check if it's visible before doing so)
        prevBtn.hide();
      });

      // Refresh content each time new data is attached
      itemList.subscribe('data', function(event, data) {
        itemList.refresh();
      });

      // Open item when selected
      itemList.subscribe('select', function(event, data) {

        //use this code if wyou want to disable the preview for a certain datasource
        //var dataPath = itemList.dataPath + data[0];
        //var ds = _app.data.get(dataPath);

        // display detail page except for twitter
        //if(ds.source != 'twitter' ) {
        _this.ui.element('/content/detail').show();

        //   _this.ui.element('/content/detail').setDataPath(dataPath);
        //   _this.ui.element('/content/detail/article').setDataPath(dataPath);
        //   _this.ui.element('/content/detail/video').setDataPath(dataPath);
        //   _this.ui.element('/content/detail/video/player.youtube').setDataPath(dataPath);
        //   _this.ui.element('/content/detail/video/title').setDataPath(dataPath);                                          
        // }

      });

      // if no item is displayed, display a message
      itemList.subscribe('afterRefresh', function(event, data) {
        var $items = $('#defaultApp__content__itemList li');
        if($items.length == 0) {
          $('#defaultApp__content__itemList').html(UItpl.tplNothingToSeeHere);
        }
      });

      // Show prev button when viewing details
      detailPanel.subscribe('afterShow', function(event, data) {
        prevBtn.show();
      });

      // linkify the tweets
      twitterPanel.subscribe('afterRefresh', function(event, data) {
        $('.linkify').html( linkify( $('.linkify').text() ) );
      });

      // when the menu is built, create the "more" button
      footer.subscribe('afterShow', function(event, data) {
        var $menuitems = $('#defaultApp__footer li');
        if($menuitems.length > 5) {
          $($menuitems[3]).after("<li class='more-footer'><div class='picto'></div><div class='name'>more</div></li>");
        }
        $('.more-footer').bind('click', function(){<commit_msg>scroll for flickr list<commit_after>Joshfire.define(['joshfire/app', 'joshfire/class', './src/tree.data', './src/tree.ui.phone', 'joshfire/utils/splashscreen', 'joshfire/uielements/panel', './src/lib/ba-linkify', 'src/ui-components'], function(BaseApp, Class, Data, UI, Splash, Panel, linkify, UItpl) {
  
  return Class(BaseApp, {

    id: 'defaultApp',

    uiClass: UI,

    dataClass: Data,

    setup: function(callback) {
      var _this = this,
          footer = _this.ui.element('/footer'),
          itemList = _this.ui.element('/content/itemList'),
          detailPanel = _this.ui.element('/content/detail'),
          twitterPanel = _this.ui.element('/content/detail/twitter'),
          prevBtn = _this.ui.element('/header/prev'),
          logo = _this.ui.element('/header/title');

      this.splash = new Splash();

      // Change app name globally
      document.title = Joshfire.factory.config.app.name;

      // Populate footer
      footer.subscribe('data', function(event, data) {
        // We have data, remove splashscreen
        // Todo: it may better to remove it "onAfterShow" or "onAfterInsert"
        _this.splash.remove();

        // Select the first tab on our footer
        footer.selectByIndex(0);
      });

      // Handle clicks on footer
      footer.subscribe('select', function(event, data) {
        var datasourceId = data[0][0];

        // if about page
        if(datasourceId == 'about') {
          console.log("about");
          _this.ui.element('/content/about').show();
          return;
        }

        // Set the new dataPath
        _this.ui.element('/content/itemList').setDataPath('/datasource/' + datasourceId + '/');

        // Show itemList, because we could be on a detail panel
        _this.ui.element('/content').switchTo('itemList');

        // Hide prev button (todo: check if it's visible before doing so)
        prevBtn.hide();
      });

      // Refresh content each time new data is attached
      itemList.subscribe('data', function(event, data) {
        itemList.refresh();
      });

      // Open item when selected
      itemList.subscribe('select', function(event, data) {

        //use this code if wyou want to disable the preview for a certain datasource
        //var dataPath = itemList.dataPath + data[0];
        //var ds = _app.data.get(dataPath);

        // display detail page except for twitter
        //if(ds.source != 'twitter' ) {
        _this.ui.element('/content/detail').show();

        //   _this.ui.element('/content/detail').setDataPath(dataPath);
        //   _this.ui.element('/content/detail/article').setDataPath(dataPath);
        //   _this.ui.element('/content/detail/video').setDataPath(dataPath);
        //   _this.ui.element('/content/detail/video/player.youtube').setDataPath(dataPath);
        //   _this.ui.element('/content/detail/video/title').setDataPath(dataPath);                                          
        // }

      });

      // if no item is displayed, display a message
      itemList.subscribe('afterRefresh', function(event, data) {
        var $items = $('#defaultApp__content__itemList li');
        if($items.length == 0) {
          $('#defaultApp__content__itemList').html(UItpl.tplNothingToSeeHere);
        }

        if( $('#defaultApp__content__itemList li.grid').length > 0 ) {
           $('#defaultApp__content__itemList ul').append('<li style="clear:both;"></li>');
        }
      });

      // Show prev button when viewing details
      detailPanel.subscribe('afterShow', function(event, data) {
        prevBtn.show();
      });

      // linkify the tweets
      twitterPanel.subscribe('afterRefresh', function(event, data) {
        $('.linkify').html( linkify( $('.linkify').text() ) );
      });

      // when the menu is built, create the "more" button
      footer.subscribe('afterShow', function(event, data) {
        var $menuitems = $('#defaultApp__footer li');
        if($menuitems.length > 5) {
          $($menuitems[3]).after("<li class='more-footer'><div class='picto'></div><div class='name'>more</div></li>");
        }
        $('.more-footer').bind('click', function(){
{'fraction_non_alphanumeric': 0.15661909448818898, 'fraction_numerical': 0.0018454724409448819, 'mean_word_length': 2.3941544885177453, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3574561', 'n_tokens_mistral': 2394, 'n_tokens_neox': 2298, 'n_words': 491}