2015-03-14 21:31:31 +00:00
|
|
|
define([
|
2015-10-09 07:52:37 +00:00
|
|
|
'jquery', 'knockout', 'text!./sidebarwidget.html', 'jquery-ui/draggable', 'jquery-ui/dialog'
|
2015-03-14 21:31:31 +00:00
|
|
|
], function(jquery, ko, htmlString) {
|
|
|
|
|
2015-10-09 07:52:37 +00:00
|
|
|
function ViewModel(params, componentInfo) {
|
2015-03-14 21:31:31 +00:00
|
|
|
var self = this;
|
|
|
|
|
2015-10-09 07:52:37 +00:00
|
|
|
self.element = componentInfo.element;
|
|
|
|
|
2015-03-14 21:31:31 +00:00
|
|
|
self.widget = ko.observable(params.widget);
|
|
|
|
|
|
|
|
self.pinned = ko.observable(true);
|
|
|
|
self.pin = function() {
|
|
|
|
self.pinned(!self.pinned());
|
|
|
|
}
|
|
|
|
|
|
|
|
self.close = function() {
|
2015-10-09 07:52:37 +00:00
|
|
|
jquery(self.element).remove();
|
|
|
|
}
|
|
|
|
|
|
|
|
self.detach = function() {
|
|
|
|
jquery(self.element).find('.phi-widget').dialog();
|
|
|
|
jquery(self.element).remove();
|
2015-03-14 21:31:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
self.expanded = ko.observable(true);
|
|
|
|
|
|
|
|
self.onMouseover = function() {
|
|
|
|
self.expanded(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
self.onMouseout = function() {
|
|
|
|
if (!self.pinned())
|
|
|
|
self.expanded(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return component definition
|
|
|
|
return {
|
2015-10-09 07:52:37 +00:00
|
|
|
viewModel : {
|
|
|
|
createViewModel : function(params, componentInfo) {
|
|
|
|
return new ViewModel(params, componentInfo);
|
|
|
|
},
|
|
|
|
},
|
2015-03-14 21:31:31 +00:00
|
|
|
template : htmlString
|
|
|
|
};
|
|
|
|
});
|