[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/yuilib/3.17.2/scrollview-list/ -> scrollview-list.js (source)

   1  /*
   2  YUI 3.17.2 (build 9c3c78e)
   3  Copyright 2014 Yahoo! Inc. All rights reserved.
   4  Licensed under the BSD License.
   5  http://yuilibrary.com/license/
   6  */
   7  
   8  YUI.add('scrollview-list', function (Y, NAME) {
   9  
  10  /**
  11   * Provides a plugin, which adds support for a scroll indicator to ScrollView instances
  12   *
  13   * @module scrollview-list
  14   */
  15  var getCN = Y.ClassNameManager.getClassName,
  16  SCROLLVIEW = 'scrollview',
  17  LIST_CLASS = getCN(SCROLLVIEW, 'list'),
  18  ITEM_CLASS = getCN(SCROLLVIEW, 'item'),
  19  CONTENT_BOX = "contentBox",
  20  HOST = "host";
  21  
  22  /**
  23   * ScrollView plugin that adds class names to immediate descendant "<li>" to
  24   *  allow for easier styling through CSS
  25   *
  26   * @class ScrollViewList
  27   * @namespace Plugin
  28   * @extends Plugin.Base
  29   * @constructor
  30   */
  31  function ListPlugin() {
  32      ListPlugin.superclass.constructor.apply(this, arguments);
  33  }
  34  
  35  
  36  /**
  37   * The identity of the plugin
  38   *
  39   * @property NAME
  40   * @type String
  41   * @default 'pluginList'
  42   * @static
  43   */
  44  ListPlugin.NAME = 'pluginList';
  45  
  46  /**
  47   * The namespace on which the plugin will reside.
  48   *
  49   * @property NS
  50   * @type String
  51   * @default 'list'
  52   * @static
  53   */
  54  ListPlugin.NS = 'list';
  55  
  56  
  57  /**
  58   * The default attribute configuration for the plugin
  59   *
  60   * @property ATTRS
  61   * @type Object
  62   * @static
  63   */
  64  ListPlugin.ATTRS = {
  65  
  66      /**
  67       * Specifies whether the list elements (the immediate <ul>'s and the
  68       *  immediate <li>'s inside those <ul>'s) have class names attached to
  69       *  them or not
  70       *
  71       * @attribute isAttached
  72       * @type boolean
  73       * @deprecated No real use for this attribute on the public API
  74       */
  75      isAttached: {
  76          value:false,
  77          validator: Y.Lang.isBoolean
  78      }
  79  };
  80  
  81  Y.namespace("Plugin").ScrollViewList = Y.extend(ListPlugin, Y.Plugin.Base, {
  82  
  83      /**
  84       * Designated initializer
  85       *
  86       * @method initializer
  87       */
  88      initializer: function() {
  89          this._host = this.get(HOST);
  90          this.afterHostEvent("render", this._addClassesToList);
  91      },
  92  
  93      _addClassesToList: function() {
  94          if (!this.get('isAttached')) {
  95              var cb = this._host.get(CONTENT_BOX),
  96              ulList,
  97              liList;
  98  
  99              if (cb.hasChildNodes()) {
 100                  //get all direct descendants of the UL's that are directly under the content box.
 101                  ulList = cb.all('> ul');
 102                  liList = cb.all('> ul > li');
 103  
 104                  //go through the UL's and add the class
 105                  ulList.each(function(list) {
 106                      list.addClass(LIST_CLASS);
 107                  });
 108  
 109                  //go through LI's and add the class
 110                  liList.each(function(item) {
 111                      item.addClass(ITEM_CLASS);
 112                  });
 113  
 114                  this.set('isAttached', true);
 115  
 116                  // We need to call this again, since sv-list
 117                  //  relies on the "-vert" class, to apply padding.
 118                  //  [ 1st syncUI pass applies -vert, 2nd pass re-calcs dims ]
 119                  this._host.syncUI();
 120              }
 121          }
 122      }
 123  
 124  });
 125  
 126  
 127  
 128  
 129  
 130  
 131  
 132  
 133  
 134  
 135  
 136  
 137  }, '3.17.2', {"requires": ["plugin", "classnamemanager"], "skinnable": true});


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1