Skip to content

Instantly share code, notes, and snippets.

@GorosVi
Last active October 3, 2015 22:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save GorosVi/279bf246ead3f67b3ca4 to your computer and use it in GitHub Desktop.
Save GorosVi/279bf246ead3f67b3ca4 to your computer and use it in GitHub Desktop.
Widget test
define(['lib'], function (lib) {
var PresetWidgetView = lib.marionette.ItemView.extend({
template: lib.handlebars.compile(
'<div>{{displayName}}</div>' +
'<div class="col-sm-9 col-xs-9">' +
'<div class="btn-group btn-group-justified">' +
'<a href="#" class="btn btn-default th-pointer js-btn-load"> Load </a>' +
'</div>' +
'</div>' +
'<div class="col-sm-3 col-xs-3">' +
'<div class="btn-group btn-group-justified">' +
'<a href="#" class="btn btn-default th-pointer js-btn-save"> Save </a>' +
'</div>' +
'</div>' +
'<div class="clearfix"></div>'),
triggers: {
"click .js-btn-load": "preset:load",
"click .js-btn-save": "preset:save"
}
});
var createSender = function (channel, cmd) {
return function () {
return lib.$.getJSON('/api/noolite', { ch: channel, cmd: cmd });
}
};
return {
show: function (model, region) {
var view = new PresetWidgetView({ model: model });
var channel = model.get('data').channel;
view.on("preset:load", createSender(channel, 7)); // NooLite Load
view.on("preset:save", createSender(channel, 8)); // NooLite Save
region.show(view);
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment