Bước tới nội dung

Thành viên:Trần Nguyễn Minh Huy/local.css

Bách khoa toàn thư mở Wikipedia

Chú ý: Sau khi lưu thay đổi trang, bạn phải xóa bộ nhớ đệm của trình duyệt để nhìn thấy các thay đổi. Google Chrome, Firefox, Internet ExplorerSafari: Giữ phím ⇧ Shift và nhấn nút Reload/Tải lại trên thanh công cụ của trình duyệt. Để biết chi tiết và hướng dẫn cho các trình duyệt khác, xem Trợ giúp:Xóa bộ nhớ đệm.

  }
    },
 
    scrollStep_: function() {
      this.scrollStart_ = Date.now();
      window.webkitRequestAnimationFrame(this.scrollListener_);
    },
 
    scrollImpl_: function(time) {
      if (!appDragAndDrop.isDragging()) {
        this.stopScroll_();
        return;
      }
 
      if (!this.scrollMouseXY_)
        return;
 
      var step = time - this.scrollStart_;
 
      window.scrollBy(
          this.calcScroll_(this.scrollMouseXY_.dx, step),
          this.calcScroll_(this.scrollMouseXY_.dy, step));
 
      this.scrollStep_();
    },
 
    calcScroll_: function(delta, step) {
      if (delta == 0)
        return 0;
 
      // Increase the multiplier for every 50px the mouse is beyond the edge.
      var sign = delta > 0 ? 1 : -1;
      var scalar = APP_AUTOSCROLL_RATE * step / 1000;
      var multiplier = Math.floor(Math.abs(delta) / 50) + 1;
 
      return sign * scalar * multiplier;
    },
 
    stopScroll_: function() {
      this.scrollListener_ = null;
      this.scrollMouseXY_ = null;
    },
 
    saveDrag: function() {
      this.invalidate_();
      this.layout();
 
      var appIds = this.data.filter(function(id) {
        return id != 'web-store-entry';
      });
 
      // Wait until the transitions are complete before notifying the browser.
      // Otherwise, the apps will be re-rendered while still transitioning.
      setTimeout(function() {
        chrome.send('reorderApps', appIds);
      }, this.transitionsDuration + 10);
    },
 
    layout: function(options) {
      options = options || {};
      if (!this.dirty_ && options.force != true)
        return;
 
      try {
        var container = this.dragContainer;
        if (options.disableAnimations)
          container.setAttribute('launcher-animations', false);
        var d0 = Date.now();
        this.layoutImpl_();
        this.dirty_ = false;
        logEvent('apps.layout: ' + (Date.now() - d0));
 
      } finally {
        if (options.disableAnimations) {
          // We need to re-enable animations asynchronously, so that the
          // animations are still disabled for this layout update.
          setTimeout(function() {
            container.setAttribute('launcher-animations', true);
          }, 0);
        }
      }
    },
 
    layoutImpl_: function() {
      var apps = this.data;
      var rects = this.getLayoutRects_(apps.length);
      var appsContent = this.dragContainer;
 
      if (!this.visible)
        return;
 
      for (var i = 0; i < apps.length; i++) {
        var app = appsContent.querySelector('[app-id='+apps[i]+']').parentNode;
 
        // If the node is being dragged, don't try to place it in the grid.
        if (app == this.dragItem)
          continue;
 
        app.style.left = rects[i].left + 'px';
        app.style.top = rects[i].top + 'px';
      }
 
      // We need to set the container's height manually because the apps use
      // absolute positioning.
      var rows = Math.ceil(apps.length / MAX_APPS_PER_ROW[layoutMode]);
      appsContent.style.height = (rows * this.dimensions.height) + 'px';
    },
 
    getLayoutRects_: function(appCount) {
      var availableWidth = this.dragContainer.offsetWidth;
      var rtl = isRtl();
      var rects = [];
      var w = this.dimensions.width;
      var h = this.dimensions.height;
      var appsPerRow = MAX_APPS_PER_ROW[layoutMode];
 
      for (var i = 0; i < appCount; i++) {
        var top = Math.floor(i / appsPerRow) * h;
        var left = (i % appsPerRow) * w;
 
        // Reflect the X axis if an RTL language is active.
        if (rtl)
          left = availableWidth - left - w;
        rects[i] = {left: left, top: top};
      }
      return rects;
    },
 
    createElement: function(app) {
      var div = createElement(app);
      var a = div.firstChild;
 
      a.onclick = handleClick;
      a.setAttribute('ping', PING_APP_LAUNCH_PREFIX + '+' + this.showPromo);
      a.style.backgroundImage = url(app['icon_big']);
      if (hashParams['app-id'] == app['id']) {
        div.setAttribute('new', 'new');
        // Delay changing the attribute a bit to let the page settle down a bit.
        setTimeout(function() {
          // Make sure the new icon is scrolled into view.
          document.body.scrollTop = document.body.scrollHeight;
 
          // This will trigger the 'bounce' animation defined in apps.css.
          div.setAttribute('new', 'installed');
        }, 500);
        div.addEventListener('webkitAnimationEnd', function(e) {
          div.removeAttribute('new');
 
          // If we get new data (eg because something installs in another tab,
          // or because we uninstall something here), don't run the install
          // animation again.
          document.documentElement.setAttribute("install-animation-enabled",
                                                "false");
        });
      }
 
      var settingsButton = div.appendChild(new cr.ui.ContextMenuButton);
      settingsButton.className = 'app-settings';
      settingsButton.title = localStrings.getString('appsettings');
 
      addContextMenu(div, app);
 
      return div;
    },
 
    createMiniviewElement: function(app) {
      var span = document.createElement('span');
      var a = span.appendChild(document.createElement('a'));
 
      a.setAttribute('app-id', app['id']);
      a.textContent = app['name'];
      a.href = app['launch_url'];
      a.onclick = handleClick;
      a.setAttribute('ping', PING_APP_LAUNCH_PREFIX + '+' + this.showPromo);
      a.style.backgroundImage = url(app['icon_small']);
      a.className = 'item';
      span.appendChild(a);
 
      addContextMenu(span, app);
 
      return span;
    },
 
    createClosedMenuElement: function(app) {
      var a = document.createElement('a');
      a.setAttribute('app-id', app['id']);
      a.textContent = app['name'];
      a.href = app['launch_url'];
      a.onclick = handleClick;
      a.setAttribute('ping', PING_APP_LAUNCH_PREFIX + '+' + this.showPromo);
      a.style.backgroundImage = url(app['icon_small']);
      a.className = 'item';
 
      addContextMenu(a, app);
 
      return a;
    },
 
    createWebStoreElement: function() {
      var elm = createElement({
        'id': 'web-store-entry',
        'name': localStrings.getString('web_store_title'),
        'launch_url': localStrings.getString('web_store_url')
      });
      elm.classList.add('web-store-entry');
      return elm;
    },
 
    createWebStoreMiniElement: function() {
      var span = document.createElement('span');
      span.appendChild(this.createWebStoreClosedMenuElement());
      return span;
    },
 
    createWebStoreClosedMenuElement: function() {
      var a = document.createElement('a');
      a.textContent = localStrings.getString('web_store_title');
      a.href = localStrings.getString('web_store_url');
      a.style.backgroundImage = url('chrome://theme/IDR_PRODUCT_LOGO_16');
      a.className = 'item';
      return a;
    }
  };
})();
 
// Enable drag and drop reordering of the app launcher.
var appDragAndDrop = new DragAndDropController(apps);
</script> 
 
<script> 
  cr.ui.decorate('menu', cr.ui.Menu);
  cr.ui.decorate('command', cr.ui.Command);
  cr.ui.decorate('button[menu]', cr.ui.MenuButton);
 
  if (cr.isChromeOS)
    $('closed-sections-bar').setAttribute('chromeos', true);
 
  initializeLogin();
 
  initializeSection('apps', MENU_APPS, Section.APPS);
  initializeSection('most-visited', MENU_THUMB, Section.THUMB);
  initializeSection('recently-closed', MENU_RECENT);
 
  updateSimpleSection('apps', Section.APPS);
  updateSimpleSection('most-visited', Section.THUMB);
  var appsInitiallyMenu = shownSections & MENU_APPS;
  var mostVisitedInitiallyMenu = shownSections & MENU_THUMB;
  var recentlyClosedInitiallyMenu = shownSections & MENU_RECENT;
  setSectionMenuMode('apps', Section.APPS, appsInitiallyMenu, MENU_APPS);
  setSectionMenuMode('most-visited', Section.THUMB, mostVisitedInitiallyMenu,
                     MENU_THUMB);
  setSectionMenuMode('recently-closed', undefined, recentlyClosedInitiallyMenu,
                     MENU_RECENT);
 
  layoutSections();
</script>