|
createThumbbarButtons: function (options) { |
|
var defaultOptions; |
|
if (!siteModeSupported()) { |
|
return this; |
|
} |
|
defaultOptions = { |
|
buttons: [] |
|
}; |
|
options = $.extend({}, defaultOptions, options); |
|
return callWindowExternalSafely(function () { |
|
var ButtonStyle, buttons, clickCurrent; |
|
if (window.external.msIsSiteMode()) { |
|
buttons = []; |
|
ButtonStyle = (function () { |
|
function ButtonStyle() { } |
|
ButtonStyle.prototype.button = null; |
|
ButtonStyle.prototype.alternateStyle = null; |
|
ButtonStyle.prototype.activeStyle = 0; |
|
ButtonStyle.prototype.click = null; |
|
ButtonStyle.prototype.hidden = false; |
|
return ButtonStyle; |
|
})(); |
|
clickCurrent = function (btn) { |
|
var curr, newStyle; |
|
curr = buttons[btn.buttonID]; |
|
curr.click(); |
|
if (curr.alternateStyle) { |
|
newStyle = curr.activeStyle === 0 ? curr.alternateStyle : 0; |
|
window.external.msSiteModeShowButtonStyle(curr.button, newStyle); |
|
return curr.activeStyle = newStyle; |
|
} |
|
}; |
|
$.each(options.buttons, function (key, value) { |
|
var altBtn, btn, buttonStyle, style; |
|
btn = window.external.msSiteModeAddThumbBarButton(value.icon, value.name); |
|
if (value.alternateStyle) { |
|
style = value.alternateStyle; |
|
altBtn = window.external.msSiteModeAddButtonStyle(btn, style.icon, style.name); |
|
} |
|
buttonStyle = new ButtonStyle; |
|
buttonStyle.button = btn; |
|
buttonStyle.alternateStyle = altBtn; |
|
buttonStyle.click = value.click; |
|
buttonStyle.hidden = value.hidden || false; |
|
buttons[btn] = buttonStyle; |
|
if (document.addEventListener) { |
|
return document.addEventListener('msthumbnailclick', clickCurrent, false); |
|
} else if (document.attachEvent) { |
|
return document.attachEvent('onmsthumbnailclick', clickCurrent); |
|
} |
|
}); |
|
window.onunload = function () { |
|
var key, value; |
|
for (key in buttons) { |
|
if (!__hasProp.call(buttons, key)) continuel; |
|
value = buttons[key]; |
|
window.external.msSiteModeUpdateThumbBarButton(value.button, true, false); |
|
} |
|
}; |
|
window.onload = function () { |
|
var key, value; |
|
for (key in buttons) { |
|
if (!__hasProp.call(buttons, key)) continue; |
|
value = buttons[key]; |
|
if (!value.hidden) { |
|
window.external.msSiteModeUpdateThumbBarButton(value.button, true, true); |
|
} |
|
} |
|
}; |
|
return window.external.msSiteModeShowThumbBar(); |
|
} |
|
}); |
|
} |