This repository has been archived by the owner on May 3, 2022. It is now read-only.
EZP-23147: As a developer, I want to be able to write plugins for the apps #100
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
081cf4d
EZP-23147: As a developer, I want to be able to write plugins for the…
dpobel bb01f92
EZP-23147: Moved the Handlebars partial registration to an app plugin
dpobel 6f2d523
EZP-23147: Moved the Handlebars helper registration to an app plugin
dpobel 1204fea
EZP-23147: Moved the DOM state handling to a dedicated app plugin
dpobel File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright (C) eZ Systems AS. All rights reserved. | ||
* For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
YUI.add('ez-domstateplugin', function (Y) { | ||
"user strict"; | ||
/** | ||
* Provides the DOM state plugin | ||
* | ||
* @module ez-domstateplugin | ||
*/ | ||
Y.namespace('eZ.Plugin'); | ||
|
||
var MINIMIZE_DISCOVERY_BAR_CLASS = 'is-discoverybar-minimized'; | ||
|
||
/** | ||
* DOM State plugin. Reflects the application state in the DOM by setting | ||
* some classes depending on the events. | ||
* | ||
* @namespace eZ.Plugin | ||
* @class DomState | ||
* @constructor | ||
* @extends Plugin.Base | ||
*/ | ||
Y.eZ.Plugin.DomState = Y.Base.create('domStatePlugin', Y.Plugin.Base, [], { | ||
initializer: function () { | ||
this.onHostEvent( | ||
'*:minimizeDiscoveryBarAction', this._uiMinimizeDiscoveryBar | ||
); | ||
this.onHostEvent( | ||
'*:navigationModeChange', this._uiNavigationModeChange | ||
); | ||
}, | ||
|
||
/** | ||
* `minimizeDiscoveryBarAction` event handler. It toggles the discovery | ||
* bar mininized class on the app container to minimize/maximize it. | ||
* | ||
* @method _uiMinimizeDiscoveryBar | ||
* @protected | ||
* @param {Object} e minimizeDiscoveryBarAction event facade | ||
*/ | ||
_uiMinimizeDiscoveryBar: function (e) { | ||
this.get('host').get('container').toggleClass(MINIMIZE_DISCOVERY_BAR_CLASS); | ||
}, | ||
|
||
/** | ||
* `navigationModeChange` event handler. it sets or unsets the | ||
* navigation mode class provided in the event facade to handle the fact | ||
* that the navigation hub can be fixed or not. | ||
* | ||
* @method _uiNavigationModeChange | ||
* @protected | ||
* @param {Object} e navigationModeChange event facade | ||
*/ | ||
_uiNavigationModeChange: function (e) { | ||
var container = this.get('host').get('container'); | ||
|
||
if ( e.navigation.value ) { | ||
container.addClass(e.navigation.modeClass); | ||
} else { | ||
container.removeClass(e.navigation.modeClass); | ||
} | ||
}, | ||
}, { | ||
NS: 'domState', | ||
}); | ||
|
||
Y.eZ.PluginRegistry.registerPlugin( | ||
Y.eZ.Plugin.DomState, ['platformuiApp'] | ||
); | ||
}); |
51 changes: 51 additions & 0 deletions
51
Resources/public/js/apps/plugins/ez-registerpartialsplugin.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (C) eZ Systems AS. All rights reserved. | ||
* For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
YUI.add('ez-registerpartialsplugin', function (Y) { | ||
"user strict"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo |
||
/** | ||
* Provides the register partials plugin | ||
* | ||
* @module ez-registerpartialsplugin | ||
*/ | ||
Y.namespace('eZ.Plugin'); | ||
|
||
var PARTIALS_SEL = '.ez-platformui-app-partial'; | ||
|
||
/** | ||
* Register partial plugin. It's a plugin for the PlatformUI application to | ||
* automatically register Handlebars partials found in the DOM. | ||
* | ||
* @namespace eZ.Plugin | ||
* @class RegisterPartials | ||
* @constructor | ||
* @extends Plugin.Base | ||
*/ | ||
Y.eZ.Plugin.RegisterPartials = Y.Base.create('registerPartialsPlugin', Y.Plugin.Base, [], { | ||
initializer: function () { | ||
this._registerPartials(); | ||
}, | ||
|
||
/** | ||
* Register the handlebar partials available in the DOM. The content of | ||
* any element with the class `ez-platformui-app-partial` is considered | ||
* as a handlebars partial and is registered with its `id` as the | ||
* partial name. | ||
* | ||
* @method _registerPartials | ||
* @protected | ||
*/ | ||
_registerPartials: function () { | ||
Y.all(PARTIALS_SEL).each(function (partial) { | ||
Y.Handlebars.registerPartial(partial.get('id'), partial.getHTML()); | ||
}); | ||
}, | ||
}, { | ||
NS: 'registerPartials', | ||
}); | ||
|
||
Y.eZ.PluginRegistry.registerPlugin( | ||
Y.eZ.Plugin.RegisterPartials, ['platformuiApp'] | ||
); | ||
}); |
68 changes: 68 additions & 0 deletions
68
Resources/public/js/apps/plugins/ez-registerurlhelpersplugin.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright (C) eZ Systems AS. All rights reserved. | ||
* For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
YUI.add('ez-registerurlhelpersplugin', function (Y) { | ||
"user strict"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo |
||
/** | ||
* Provides the register url helpers plugin | ||
* | ||
* @module ez-registerhelpersplugin | ||
*/ | ||
Y.namespace('eZ.Plugin'); | ||
|
||
/** | ||
* Register Url Helpers plugin for the Platform UI application. It registers | ||
* two handlebars helpers to deal with the url: | ||
* | ||
* * `path` is meant to build link to application routes. It takes the | ||
* name of a route and the expected route parameters as a literal object | ||
* * `asset` is meant to build url to a static file provided by the | ||
* PlatformUIBundle (typically an image) | ||
* | ||
* @namespace eZ.Plugin | ||
* @class RegisterUrlHelpers | ||
* @constructor | ||
* @extends Plugin.Base | ||
*/ | ||
Y.eZ.Plugin.RegisterUrlHelpers = Y.Base.create('registerUrlHelpersPlugin', Y.Plugin.Base, [], { | ||
initializer: function () { | ||
this._registerPath(); | ||
this._registerAsset(); | ||
}, | ||
|
||
/** | ||
* Registers the `path` handlebars helper. | ||
* | ||
* @method _registerPath | ||
* @protected | ||
*/ | ||
_registerPath: function () { | ||
var app = this.get('host'); | ||
|
||
Y.Handlebars.registerHelper('path', function (routeName, options) { | ||
return app.routeUri(routeName, options.hash); | ||
}); | ||
}, | ||
|
||
/** | ||
* Registers the `asset` handlebars helper. | ||
* | ||
* @method _registerAsset | ||
* @protected | ||
*/ | ||
_registerAsset: function () { | ||
var app = this.get('host'); | ||
|
||
Y.Handlebars.registerHelper('asset', function (uri) { | ||
return app.get('assetRoot').replace(/\/+$/, '') + '/' + uri.replace(/^\/+/, ''); | ||
}); | ||
}, | ||
}, { | ||
NS: 'registerUrlHelpers', | ||
}); | ||
|
||
Y.eZ.PluginRegistry.registerPlugin( | ||
Y.eZ.Plugin.RegisterUrlHelpers, ['platformuiApp'] | ||
); | ||
}); |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo