Last active
August 29, 2015 14:01
-
-
Save sweetpi/901c222517bd627a50b3 to your computer and use it in GitHub Desktop.
extending-mobile-frontend
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
# in your plugins init-function: | |
init: (@app, @framework, @config) => | |
# [...] | |
# wait till all plugins are loaded | |
@framework.on "after init", => | |
# Check if the mobile-frontent was loaded and get a instance | |
mobileFrontend = @framework.pluginManager.getPlugin 'mobile-frontend' | |
if mobileFrontend? | |
mobileFrontend.registerAssetFile 'js', "pimatic-your-plugin/app/some-js.coffee" | |
mobileFrontend.registerAssetFile 'css', "pimatic-your-plugin/app/css/some-css.css" | |
mobileFrontend.registerAssetFile 'html', "pimatic-your-plugin/app/some-html.jade" | |
else | |
env.logger.warn "your plugin could not find the mobile-frontend. No gui will be available" |
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
$(document).on( "templateinit", (event) -> | |
# define the item class | |
class CustomDeviceItem extends pimatic.DeviceItem | |
constructor: (data) -> | |
super(data) | |
# Do something, after create: console.log(this) | |
afterRender: (elements) -> | |
super(elements) | |
# Do something after the html-element was added | |
onButtonPress: -> | |
$.get("/api/device/#{@deviceId}/actionToCall").fail(ajaxAlertFail) | |
# register the item-class | |
pimatic.templateClasses['customdevice'] = CustomDeviceItem | |
) |
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
<script id="customdevice-template" type="text/template"> | |
<li class="sortable device no-header"> | |
<label data-bind="text: name" class="device-label"></label> | |
<a data-bind="click: onButtonPress" class="ui-btn ui-mini ui-btn-inline ui-corner-all">click me</a> | |
</li> | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment