2010-02-08 02:22:42 +00:00
|
|
|
|
/// <reference path="/umbraco_client/Application/NamespaceManager.js" />
|
|
|
|
|
|
|
|
|
|
|
|
Umbraco.Sys.registerNamespace("Umbraco.Controls");
|
|
|
|
|
|
|
|
|
|
|
|
(function($) {
|
|
|
|
|
|
Umbraco.Controls.TreePicker = function(clientId, label, itemIdValueClientID, itemTitleClientID, itemPickerUrl, width, height, showHeader, umbracoPath) {
|
|
|
|
|
|
var obj = {
|
|
|
|
|
|
_itemPickerUrl: itemPickerUrl,
|
2012-10-06 11:46:37 -02:00
|
|
|
|
_webServiceUrl: umbracoPath + "/webservices/legacyAjaxCalls.asmx/GetNodeBreadcrumbs",
|
2010-02-08 02:22:42 +00:00
|
|
|
|
_label: label,
|
|
|
|
|
|
_width: width,
|
|
|
|
|
|
_height: height,
|
|
|
|
|
|
_itemIdValueClientID: itemIdValueClientID,
|
|
|
|
|
|
_itemTitleClientID: itemTitleClientID,
|
|
|
|
|
|
_showHeader: showHeader,
|
|
|
|
|
|
_clientId: clientId,
|
|
|
|
|
|
|
|
|
|
|
|
GetValue: function() {
|
|
|
|
|
|
return $("#" + this._itemIdValueClientID).val();
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2010-03-03 15:19:51 +00:00
|
|
|
|
LaunchPicker: function() {
|
2010-02-08 02:22:42 +00:00
|
|
|
|
var _this = this;
|
2010-03-08 14:52:29 +00:00
|
|
|
|
UmbClientMgr.openModalWindow(this._itemPickerUrl, this._label, this._showHeader, this._width, this._height, 60, 0, ['#cancelbutton'], function(e) { _this.SaveSelection(e); });
|
2010-02-08 02:22:42 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
SaveSelection: function(e) {
|
|
|
|
|
|
if (!e.outVal) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
$("#" + this._itemIdValueClientID).val(e.outVal);
|
|
|
|
|
|
var _this = this;
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
|
type: "POST",
|
|
|
|
|
|
url: _this._webServiceUrl,
|
|
|
|
|
|
data: '{ "nodeId": ' + e.outVal + ' }',
|
|
|
|
|
|
contentType: "application/json; charset=utf-8",
|
|
|
|
|
|
dataType: "json",
|
|
|
|
|
|
success: function(msg) {
|
2012-10-06 01:26:56 +07:00
|
|
|
|
var a = msg.d;
|
|
|
|
|
|
var name = a[a.length - 1];
|
|
|
|
|
|
var breadcrumbs = a.join(" > ");
|
|
|
|
|
|
$("#" + _this._itemTitleClientID)
|
|
|
|
|
|
.html(name)
|
|
|
|
|
|
.attr('title', breadcrumbs)
|
|
|
|
|
|
.parent()
|
|
|
|
|
|
.show();
|
2010-02-08 02:22:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
ClearSelection: function() {
|
2012-10-06 01:26:56 +07:00
|
|
|
|
$("#" + this._itemTitleClientID)
|
|
|
|
|
|
.attr('title', '')
|
|
|
|
|
|
.parent()
|
|
|
|
|
|
.hide();
|
2010-02-08 02:22:42 +00:00
|
|
|
|
$("#" + this._itemIdValueClientID).val('');
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//store this instance (by counter and id) so we can retrieve it later if needed
|
|
|
|
|
|
Umbraco.Controls.TreePicker.inst[++Umbraco.Controls.TreePicker.cntr] = obj;
|
|
|
|
|
|
Umbraco.Controls.TreePicker.inst[clientId] = obj;
|
|
|
|
|
|
|
|
|
|
|
|
return obj;
|
2012-10-06 11:46:37 -02:00
|
|
|
|
};
|
2010-02-08 02:22:42 +00:00
|
|
|
|
|
2012-10-06 11:46:37 -02:00
|
|
|
|
$(document).ready(function () {
|
|
|
|
|
|
// Tooltip only Text
|
|
|
|
|
|
$('.treePickerTitle').hover(function () {
|
|
|
|
|
|
// Hover over code
|
|
|
|
|
|
var title = $(this).attr('title');
|
|
|
|
|
|
$(this).data('tipText', title).removeAttr('title');
|
2012-10-23 08:24:33 -02:00
|
|
|
|
$('<p class="treePickerTooltip" style="z-index: 1000;"></p>').text(title).appendTo('body').fadeIn('fast');;
|
2012-10-06 11:46:37 -02:00
|
|
|
|
}, function () {
|
|
|
|
|
|
// Hover out code
|
|
|
|
|
|
$(this).attr('title', $(this).data('tipText'));
|
|
|
|
|
|
$('.treePickerTooltip').remove();
|
|
|
|
|
|
}).mousemove(function (e) {
|
|
|
|
|
|
var mousex = e.pageX + 10; //Get X coordinates
|
|
|
|
|
|
var mousey = e.pageY + 5; //Get Y coordinates
|
|
|
|
|
|
$('.treePickerTooltip').css({ top: mousey, left: mousex });
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2010-02-08 02:22:42 +00:00
|
|
|
|
// Static methods
|
|
|
|
|
|
|
|
|
|
|
|
//return the existing picker object based on client id of the control
|
|
|
|
|
|
Umbraco.Controls.TreePicker.GetPickerById = function(id) {
|
|
|
|
|
|
return Umbraco.Controls.TreePicker.inst[id] || null;
|
|
|
|
|
|
};
|
2012-10-06 11:46:37 -02:00
|
|
|
|
|
2010-02-08 02:22:42 +00:00
|
|
|
|
// instance manager
|
|
|
|
|
|
Umbraco.Controls.TreePicker.cntr = 0;
|
|
|
|
|
|
Umbraco.Controls.TreePicker.inst = {};
|
2012-10-06 11:46:37 -02:00
|
|
|
|
|
2010-02-08 02:22:42 +00:00
|
|
|
|
})(jQuery);
|