Last active
December 11, 2015 04:09
-
-
Save caridy/4543247 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (c) 2011-2013, Yahoo! Inc. All rights reserved. | |
* Copyrights licensed under the New BSD License. | |
* See the accompanying LICENSE file for terms. | |
*/ | |
/*jslint anon:true, sloppy:true, nomen:true*/ | |
/*global YUI*/ | |
YUI.add('IntlHTMLFrameMojit', function (Y, NAME) { | |
'use strict'; | |
Y.namespace('mojito.controllers')[NAME] = { | |
index: function (ac) { | |
// composite execution for the children structure | |
// coming from application.json specs. | |
ac.composite.execute(ac.config.get(), function (data, meta) { | |
// meta.assets from children should be piped into | |
// the frame's assets before doing anything else. | |
ac.assets.addAssets(meta.assets); | |
// deploying YUI to the client side | |
ac.deploy.constructMojitoClientRuntime(ac.assets, meta.binders); | |
// 1. mixing bottom and top fragments from assets into | |
// the template data, along with title and mojito version. | |
// 2. mixing meta with child metas, along with some extra | |
// headers. | |
ac.done( | |
Y.merge(data, ac.assets.renderLocations(), { | |
"name": NAME, | |
"page-title": "some fancy title... from intl", | |
"greeting": ac.intl.lang("GREETING"), | |
"says": ac.intl.lang("SAYS"), | |
"preposition": ac.intl.lang("PREPOSITION"), | |
"today": ac.intl.formatDate(new Date()), | |
"mojito_version": Y.mojito.version | |
}), | |
Y.merge(meta, { | |
http: { | |
headers: { | |
'content-type': 'text/html; charset="utf-8"' | |
} | |
}, | |
view: { | |
name: 'index' | |
} | |
}) | |
); | |
}); | |
} | |
}; | |
}, '0.1.0', {requires: [ | |
'mojito', | |
'mojito-assets-addon', | |
'mojito-deploy-addon', | |
'mojito-config-addon', | |
'mojito-composite-addon', | |
'mojito-intl-addon' | |
]}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (c) 2011-2013, Yahoo! Inc. All rights reserved. | |
* Copyrights licensed under the New BSD License. | |
* See the accompanying LICENSE file for terms. | |
*/ | |
/*jslint anon:true, sloppy:true, nomen:true*/ | |
/*global YUI*/ | |
YUI.add('ShakerHTMLFrameMojit', function (Y, NAME) { | |
'use strict'; | |
Y.namespace('mojito.controllers'); | |
Y.mojito.controllers[NAME] = Y.merge(Y.mojito.controllers.HTMLFrameMojit, { | |
__call: function (ac) { | |
Y.log('executing ShakerHTMLFrameMojit child', 'mojito', 'qeperf'); | |
this._renderChild(ac, function (data, meta) { | |
// meta.assets from child should be piped into | |
// the frame's assets before doing anything else. | |
ac.assets.addAssets(meta.assets); | |
// SHAKER RUNTIME! | |
// NOTE: We move the deployment of the client to within Shaker addon... | |
ac.shaker.run(meta); | |
Y.log('ShakerHTMLFrameMojit done()', 'mojito', 'qeperf'); | |
// 1. mixing bottom and top fragments from assets into | |
// the template data, along with title and mojito version. | |
// 2. mixing meta with child metas, along with some extra | |
// headers. | |
ac.done( | |
Y.merge(data, ac.assets.renderLocations(), { | |
title: ac.config.get('title') || 'Powered by Mojito', | |
enableDynamicTitle: ac.config.get('enableDynamicTitle'), | |
mojito_version: Y.mojito.version | |
}), | |
Y.merge(meta, { | |
http: { | |
headers: { | |
'content-type': 'text/html; charset="utf-8"' | |
} | |
}, | |
view: { | |
name: 'index' | |
} | |
}) | |
); | |
}); | |
} | |
}); | |
}, '0.1.0', {requires: [ | |
'HTMLFrameMojit', | |
'mojito-shaker-addon' | |
]}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (c) 2011-2013, Yahoo! Inc. All rights reserved. | |
* Copyrights licensed under the New BSD License. | |
* See the accompanying LICENSE file for terms. | |
*/ | |
/*jslint anon:true, sloppy:true, nomen:true*/ | |
/*global YUI*/ | |
YUI.add('ShakerHTMLFrameMojit', function (Y, NAME) { | |
'use strict'; | |
Y.namespace('mojito.controllers')[NAME] = { | |
index: function (ac) { | |
this.__call(ac); | |
}, | |
__call: function (ac) { | |
Y.log('executing ShakerHTMLFrameMojit child', 'mojito', 'qeperf'); | |
this._renderChild(ac, function (data, meta) { | |
// meta.assets from child should be piped into | |
// the frame's assets before doing anything else. | |
ac.assets.addAssets(meta.assets); | |
// SHAKER RUNTIME! | |
// NOTE: We move the deployment of the client to within Shaker addon... | |
ac.shaker.run(meta); | |
Y.log('ShakerHTMLFrameMojit done()', 'mojito', 'qeperf'); | |
// 1. mixing bottom and top fragments from assets into | |
// the template data, along with title and mojito version. | |
// 2. mixing meta with child metas, along with some extra | |
// headers. | |
ac.done( | |
Y.merge(data, ac.assets.renderLocations(), { | |
title: ac.config.get('title') || 'Powered by Mojito', | |
enableDynamicTitle: ac.config.get('enableDynamicTitle'), | |
mojito_version: Y.mojito.version | |
}), | |
Y.merge(meta, { | |
http: { | |
headers: { | |
'content-type': 'text/html; charset="utf-8"' | |
} | |
}, | |
view: { | |
name: 'index' | |
} | |
}) | |
); | |
}); | |
}, | |
/** | |
* Renders a child mojit based on a config called "child" and | |
* the "assets" collection specified in the specs. | |
* @method _renderChild | |
* @protected | |
* @param {Object} ac Action Context Object. | |
* @param {Function} callback The callback. | |
*/ | |
_renderChild: function (ac, callback) { | |
// Grab the "child" from the config an add it as the | |
// only item in the "children" map. | |
var child = ac.config.get('child'), | |
cfg; | |
// Map the action to the child if the action | |
// is not specified as part of the child config. | |
child.action = child.action || ac.action; | |
// Create a config object for the composite addon | |
cfg = { | |
children: { | |
child: child | |
}, | |
assets: ac.config.get('assets') | |
}; | |
// Now execute the child as a composite | |
ac.composite.execute(cfg, callback); | |
} | |
}; | |
}, '0.1.0', {requires: [ | |
'mojito', | |
'mojito-assets-addon', | |
'mojito-deploy-addon', | |
'mojito-config-addon', | |
'mojito-composite-addon', | |
'mojito-shaker-addon' | |
]}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment