API Docs for: undefined
Show:

File: js/google-maps-frame.js

  1. /**
  2.  * @module gallery-google-maps-frame
  3.  */
  4. (function (Y, moduleName) {
  5.     'use strict';

  6.     var _Base = Y.Base,
  7.         _Frame = Y.Frame;
  8.        
  9.     /**
  10.      * @class GoogleMapsFrame
  11.      * @constructor
  12.      * @extends Base
  13.      * @param {Object} config
  14.      */
  15.     Y.GoogleMapsFrame = _Base.create(moduleName, _Base, [], {
  16.         initializer: function () {
  17.             var me = this;
  18.            
  19.             /**
  20.              * Fired when Google Maps Loader fails.
  21.              * @event failure
  22.              */
  23.             me.publish('failure');
  24.            
  25.             /**
  26.              * Fired when Google Maps Loader succeeds.
  27.              * @event load
  28.              * @fireOnce
  29.              */
  30.             me.publish('load', {
  31.                 fireOnce: true
  32.             });
  33.            
  34.             /**
  35.              * Fired when Google Maps Loader times out.
  36.              * @event timeout
  37.              */
  38.             me.publish('timeout');

  39.             var frame = new _Frame({
  40.                 content: '<div id="map"></div>',
  41.                 extracss: 'body, html, #map {height: 100%; width: 100%;}'
  42.             });

  43.             frame.on('ready', function () {
  44.                 var iY = frame.getInstance();

  45.                 iY.config.win.YUI = YUI;
  46.                 iY.use('gallery-google-maps-loader', 'node', function (iY) {
  47.                     var googleMapsLoader = new iY.GoogleMapsLoader();

  48.                     googleMapsLoader.on('failure', function () {
  49.                         me.fire('failure');
  50.                     });
  51.                    
  52.                     googleMapsLoader.on('success', function () {
  53.                         me.google = iY.config.win.google;
  54.                         me._set('loaded', true);
  55.                         me.fire('load');
  56.                     });
  57.                    
  58.                     googleMapsLoader.on('timeout', function () {
  59.                         me.fire('timeout');
  60.                     });
  61.                    
  62.                     googleMapsLoader.load(me.get('parameters'));

  63.                     me._set('domNode', iY.Node.getDOMNode(iY.one('#map')));
  64.                     me._set('frame', frame);
  65.                 });
  66.             });

  67.             frame.render(me.get('container'));
  68.         }
  69.     }, {
  70.         ATTRS: {
  71.             /**
  72.              * A selector string or node object which will contain the iframe.
  73.              * @attribute container
  74.              * @initOnly
  75.              * @type Node|String
  76.              */
  77.             container: {
  78.                 value: null,
  79.                 writeOnce: 'initOnly'
  80.             },
  81.             /**
  82.              * Reference to an empty div created inside the iframe. (This is not
  83.              * an instance of Node.)
  84.              * @attribute domNode
  85.              * @readOnly
  86.              */
  87.             domNode: {
  88.                 readOnly: true,
  89.                 value: null
  90.             },
  91.             /**
  92.              * The Y.Frame instance that created the iframe.
  93.              * @attribute frame
  94.              * @readOnly
  95.              */
  96.             frame: {
  97.                 readOnly: true,
  98.                 value: null
  99.             },
  100.             /**
  101.              * @attribute loaded
  102.              * @default false
  103.              * @readOnly
  104.              * @type Boolean
  105.              */
  106.             loaded: {
  107.                 readOnly: true,
  108.                 value: false
  109.             },
  110.             /**
  111.              * An optional parameters object passed to GoogleMapsLoader. (see
  112.              * gallery-google-maps-loader for information)
  113.              * @attribute parameters
  114.              * @initOnly
  115.              * @type Object
  116.              */
  117.             parameters: {
  118.                 value: null,
  119.                 writeOnce: 'initOnly'
  120.             }
  121.         }
  122.     });
  123. }(Y, arguments[1]));
  124.