Advertisement
oportell

YUI3 + gallery-aui-dialog

Mar 11th, 2011
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // 1. Inline javascript
  2. var MyAppConfig = {
  3.    "dialog": {
  4.       "name":"loginPanel",
  5.       "header":"Log in",
  6.       "close":"true"
  7.       "container":"panelBody",
  8.       "html":"<h1>xxx</h1><p>zzz</p>"
  9.    }
  10. };
  11.  
  12. var YUI_config = {
  13.   filter: 'debug',
  14.   groups: {
  15.       'myapp': {
  16.          modules: {
  17.             'project-myapp-core': {
  18.                fullpath: 'http://www.myapp.com/scripts/Core.js',
  19.                requires: ['node-base']
  20.             }
  21.          }
  22.       },
  23.       'alloy': {
  24.          gallery: 'gallery-2011.02.09-21-32',
  25.          modules:  {
  26.             'gallery-aui-skin-base': {
  27.                fullpath: 'http://yui.yahooapis.com/gallery-2011.02.09-21-32/build/gallery-aui-skin-base/css/gallery-aui-skin-base-min.css',
  28.                type: 'css'
  29.             },
  30.             'gallery-aui-skin-classic': {
  31.                fullpath: 'http://yui.yahooapis.com/gallery-2011.02.09-21-32/build/gallery-aui-skin-classic/css/gallery-aui-skin-classic-min.css',
  32.                type: 'css',
  33.                requires: ['gallery-aui-skin-base']
  34.             }
  35.          }
  36.       }
  37.   }
  38. };
  39.  
  40. YUI(YUI_config).use('node', 'base', 'project-myapp-core', function(Y) {
  41.   var MyApp = {};
  42.   MyApp.Core = new Y.MyApp.Core();
  43.   Y.on('domready', MyApp.Core.begin, Y, null, application);
  44. });
  45.  
  46.  
  47.  
  48. // 2. Core module
  49. YUI.add('project-myapp-core', function(Y) {
  50.  
  51.    function Core(config) {
  52.       Core.superclass.constructor.apply(this, arguments);
  53.    }
  54.    Core.NAME = 'myapp-core';
  55.    Core.ATTRS = {
  56.       dialog: {
  57.          value: false
  58.       }
  59.    };
  60.    
  61.    var Panel;
  62.    Panel = [];
  63.  
  64.   Y.extend(Core, Y.Base, {
  65.  
  66.       initializer: function (cfg) {
  67.          var dialogconfig = this.get('dialog');
  68.          if (dialogconfig) {
  69.             this.openDialog(dialogconfig);
  70.          }
  71.       },
  72.  
  73.       openDialog: function(config) {
  74.          var name = config.name;
  75.          if (Panel[name]) {
  76.             Panel[name].destroy();
  77.          }
  78.          Y.use('gallery-aui-dialog', function (Y) {
  79.             var Panel[name] = new Y.Dialog({
  80.                centered: true,
  81.                constrain2view: true,
  82.                draggable: false,
  83.                resizable: false,
  84.                close: true,
  85.                destroyOnClose: true,
  86.                modal: true,
  87.                width: '500px',
  88.                zIndex: 6000
  89.             }).render();
  90.          });
  91.       }
  92.  
  93.   });
  94.  
  95.   Y.namespace('MyApp');
  96.   Y.MyApp.Core = Core;
  97.  
  98. }, '0.0.1', { requires: ['node-base'] });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement