-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScript.js
122 lines (111 loc) · 5.12 KB
/
Script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
(function () {
var DXDemo = {};
DXDemo.toggleNavigationPanel = function () {
if (!window.NavigationPanel)
return;
if (window.innerWidth <= NavigationPanel.cpCollapseAtWindowInnerWidth) {
if (!NavigationPanel.GetVisible())
NavigationPanel.SetVisible(true);
NavigationPanel.Toggle();
} else {
NavigationPanel.SetVisible(!NavigationPanel.GetVisible());
ASPx.GetControlCollection().ProcessControlsInContainer(document.getElementById('DemoArea'), function (control) {
control.AdjustControl();
});
}
DXDemo.adjustDemoSettingsBlock();
};
DXDemo.toggleThemeSettingsPanel = function () {
if (!window.ThemeSettingsPanel)
return;
ThemeSettingsPanel.Toggle();
};
DXDemo.CurrentThemeCookieKey = "DXCurrentTheme";
DXDemo.CurrentBaseColorCookieKey = "DXCurrentBaseColor";
DXDemo.CurrentAdaptiveThemeCookieKey = "DXCurrentAdaptiveTheme";
DXDemo.CurrentAdaptiveBaseColorCookieKey = "DXCurrentAdaptiveBaseColor";
DXDemo.CurrentFontCookieKey = "DXCurrentFont";
DXDemo.SetCurrentAdaptiveTheme = function (theme) {
ASPxClientUtils.SetCookie(DXDemo.CurrentAdaptiveThemeCookieKey, theme);
forceReloadPage();
}
DXDemo.SetCurrentTheme = function (theme) {
ASPxClientUtils.SetCookie(DXDemo.CurrentThemeCookieKey, theme);
forceReloadPage();
}
DXDemo.OnShowAllThemesClick = function () {
var themesListsNames = ShowAllThemesButton.cpThemesListsNames;
for (var i = 0; i < themesListsNames.length; i++) {
var themesList = window[themesListsNames[i]];
themesList.SetVisible(!themesList.GetVisible());
}
var showAllThemesText = 'Show All Themes';
var showTopThemesText = 'Show Top Themes';
ShowAllThemesButton.SetText(ShowAllThemesButton.GetText() != showAllThemesText ? showAllThemesText : showTopThemesText);
}
DXDemo.OnThemesListSelectedIndexChanged = function (sender) {
var selectedThemeName = sender.GetSelectedItem().value;
if (ShowAllThemesButton.cpCurrenTheme != selectedThemeName)
DXDemo.SetCurrentTheme(selectedThemeName !== 'Default' ? selectedThemeName : '');
}
DXDemo.OnThemesListInit = function (sender) {
var mainElement = sender.GetMainElement();
var itemElements = Array.prototype.slice.call(mainElement.getElementsByClassName("item"), 0);
var newItemElements = itemElements.filter(function (elem) {
return sender.cpNewThemes.indexOf(elem.textContent.trim()) !== -1;
});
newItemElements.forEach(function (itemElement) {
if (itemElement.className.indexOf("new-item") === -1)
itemElement.className += " new-item";
});
},
DXDemo.SetCurrentFont = function (font) {
ASPxClientUtils.SetCookie(DXDemo.CurrentFontCookieKey, font);
forceReloadPage();
}
DXDemo.SetCurrentAdaptiveBaseColor = function (color) {
ASPxClientUtils.SetCookie(DXDemo.CurrentAdaptiveBaseColorCookieKey, color);
forceReloadPage();
}
DXDemo.SetCurrentBaseColor = function (color) {
ASPxClientUtils.SetCookie(DXDemo.CurrentBaseColorCookieKey, color);
forceReloadPage();
}
forceReloadPage = function () {
if (document.forms[0] && (!document.forms[0].onsubmit
|| (document.forms[0].onsubmit.toString().indexOf("Sys.Mvc.AsyncForm") == -1 && !document.forms[0].hasAttribute("data-ajax")))) {
// for export purposes
var eventTarget = document.getElementById("__EVENTTARGET");
if (eventTarget)
eventTarget.value = "";
var eventArgument = document.getElementById("__EVENTARGUMENT");
if (eventArgument)
eventArgument.value = "";
document.forms[0].submit();
} else {
window.location.reload();
}
}
DXDemo.iconButtonClick = function (s, e) {
if (e.buttonIndex === 0)
s.Focus();
}
function selectorPopupContainerElement_Click(popupControl, event) {
var eventSource = ASPx.Evt.GetEventSource(event);
if (eventSource && eventSource.className.indexOf('dxpc-content') >= 0) {
popupControl.HideWindow();
}
}
function DXSelectorPopupContainer_Init(sender) {
var content = sender.GetWindowContentElement(-1);
ASPxClientUtils.AttachEventToElement(content, 'click', function (event) { selectorPopupContainerElement_Click(sender, event); });
}
function DXThemeSettingsPopupContainer_Init(sender) {
var content = sender.GetWindowContentElement(-1);
var themesButtonWrapper = content.querySelector(".themes-button-wrapper");
// ASPxClientUtils.AttachEventToElement(themesButtonWrapper, 'click', function(event) { ThemeParametersPopup.Hide(); ThemeSelectorPopup.Show(); });
}
window.DXDemo = DXDemo;
window.DXSelectorPopupContainer_Init = DXSelectorPopupContainer_Init;
window.DXThemeSettingsPopupContainer_Init = DXThemeSettingsPopupContainer_Init;
})();