or
<!DOCTYPE html><
br
><
html
><
br
><
head
><
br
><
meta
charset
=
"ISO-8859-1"
><
br
><
title
>Login</
title
><
br
> <
link
href
=
"styles/kendo.mobile.all.min.css"
rel
=
"stylesheet"
/><
br
></
head
><
br
><
body
><
br
> <
div
data-role
=
"view"
data-title
=
"Settings"
id
=
"loginForm"
><
br
> <
header
data-role
=
"header"
><
br
> <
div
data-role
=
"navbar"
><
br
> <
span
data-role
=
"view-title"
></
span
><
br
> </
div
><
br
> </
header
><
br
> Server: <
input
id
=
"serverid"
name
=
"authserver"
type
=
"url"
data-bind
=
"value: authserver"
required
data-required-msg
=
"Enter server address"
data-url-msg
=
"Enter a valid url for server"
><
br
> <
span
class
=
"k-invalid-msg"
data-for
=
"authserver"
></
span
><
br
/><
br
> UserName: <
input
id
=
"emailid"
name
=
"username"
type
=
"email"
data-bind
=
"value: username"
required
data-required-msg
=
"You need to enter email"
data-email-msg
=
"Enter a valid email id"
><
br
> <
span
class
=
"k-invalid-msg"
data-for
=
"username"
></
span
><
br
/><
br
> Password: <
input
id
=
"pwd"
name
=
"password"
type
=
"password"
data-bind
=
"value: password"
required
validationMessage
=
"Enter Password with minimum 6 characters"
><
br
> <
span
class
=
"k-invalid-msg"
data-for
=
"password"
></
span
><
br
/><
br
> <
button
data-bind
=
"click: getUserDetails"
>Login</
button
><
br
> </
div
><
br
> <
script
src
=
"scripts/jquery.min.js"
></
script
><
br
> <
script
src
=
"scripts/kendo.all.min.js"
></
script
><
br
> <
script
src
=
"scripts/viewModel/loginModel.js"
></
script
><
br
> <
script
src
=
"scripts/viewModel/loginViewModel.js"
></
script
><
br
> <
script
><
br
> /** Initial the kendo mobile application */<
br
> var app = new kendo.mobile.Application(document.body);<
br
> </
script
><
br
></
body
><
br
></
html
>
var validator = $("#loginForm").kendoValidator().data("kendoValidator");<
br
><
br
>var loginViewModel = kendo.observable({<
br
> authserver: "",<
br
> username:"",<
br
> password:"",<
br
> getUserDetails: function(){<
br
> if(validator.validate()){<
br
> // alert("Server Address -- "+ this.get("authserver")+" User Name -- "+ this.get("username")+" User Password -- "+ this.get("password"));<
br
> <
br
> var dataSource = new kendo.data.DataSource({<
br
> transport:{<
br
> read:{<
br
> url: "http://127.0.0.1/api/index.php",<
br
> type: "POST",<
br
> dataType: "html",<
br
> <
br
> }<
br
> },<
br
> change: function(data){<
br
> alert("aaa"+dataSource.data);<
br
> alert(data);<
br
> },<
br
> error: function(xhr, error){<
br
> console.log(xhr);<
br
> console.log(error);<
br
> }<
br
> });<
br
> }else{<
br
> alert("Not valid");<
br
> }<
br
> <
br
> },<
br
> <
br
>}) ;
<!--- Layout --->
<
section
data-role
=
"layout"
data-id
=
"default"
>
<!--View content will render here-->
<
header
data-role
=
"footer"
>
<
div
data-role
=
"navbar"
>
<
span
data-role
=
"view-title"
>Home</
span
>
<
a
data-align
=
"right"
data-icon
=
"icon-three-dot"
data-role
=
"button"
href
=
""
></
a
>
<
a
data-align
=
"left"
data-icon
=
"icon-three-bar"
data-role
=
"button"
href
=
"#sideMenuView"
data-rel
=
"drawer"
></
a
>
</
div
>
</
header
>
</
section
>
<!--- End Layout --->
<!--- Drawers --->
<
div
data-role
=
"drawer"
id
=
"sideMenuView"
data-show
=
"rebindListView"
data-transition
=
"slide"
>
<
div
data-role
=
"footer"
>
<
div
id
=
"sideMenuNavbar"
data-role
=
"navbar"
class
=
"bg-white"
>
<
span
data-role
=
"view-title"
>
<
img
src
=
"./styles/images/SlideNav.png"
>
</
span
>
<
a
data-role
=
"backbutton"
id
=
"btnDrawerBack"
data-align
=
"left"
>Back</
a
>
</
div
>
</
div
>
<
div
class
=
"container"
>
<
ul
id
=
"sideMenuListView"
class
=
"sideMenuListView"
data-role
=
"listview"
data-template
=
"sideMenuDrawer-template"
data-style
=
"inset"
>
</
ul
>
</
div
>
</
div
>
<!--- End Drawers --->
<!-- Script Templates -->
<
script
id
=
"sideMenuDrawer-template"
type
=
"text/x-kendo-template"
>
<
div
class
=
"#: style #"
>
# if (data.style == 'settings') { #
<
a
data-align
=
"left"
data-icon
=
"icon-gears"
data-role
=
"button"
class
=
"btn-icon" data-click="rebindListView"
></
a
>
# } else { #
<
a
data-align
=
"left"
data-icon
=
"icon-angle-right"
data-role
=
"button"
class
=
"btn-icon" data-click="rebindListView"
></
a
>
# } #
<
div
data-role
=
"button"
class
=
"text btn-text"
data-click
=
"#: view #"
>#: name #</
div
>
</
div
>
</
script
>
<!-- End Script Templates -->
<!-- Script Variables -->
<
script
>
var category = new kendo.data.DataSource({
data: [
{id: 1, name: "Dogs", view:"dogView", style:""},
{id: 2, name: "Cats", view:"catModalView", style:""},
{id: 3, name: "Birds", view:"birdView", style:""},
{id: 4, name: "Snakes", view:"snakeView", style:""},
{id: 5, name: "Cows", view:"cowView", style:""}
]
}),
type = new kendo.data.DataSource({
data: [
{id: 1, category: 2, name: "Persian"},
{id: 2, category: 2, name: "Arabian"},
{id: 3, category: 2, name: "Local"},
{id: 4, category: 1, name: "Husky"},
{id: 5, category: 1, name: "Retriever"}
]
})
</
script
>
<!-- End Script Variables -->
<!-- Script Functions -->
<
script
>
function rebindListView(e) {
var params = e.view.params,
element = e.view.element,
backButton = element.find('#btnDrawerBack'),
listView = element.find("#sideMenuListView").data('kendoMobileListView');
if (params) {
var parentID = e.view.params.parent;
sideItem = type.filter({field: "category", operator: "eq", value: parentID});
if (sideItem) {
backButton.show();
listView.setDataSource(sideItem);
} else {
// redirect to root
setTimeout(function() {
kendo.mobile.application.navigate('#homeView');
}, 0);
}
} else {
backButton.hide();
listView.setDataSource(category);
}
e.view.scroller.scrollTo(0, 0);
}
</
script
>
<!-- End Script Functions -->
/* Topics illustrated in this file:
* How to define a custom widget
* How to configure options from base
* How to define and access custom options
* How to capture scope
* How to manipulate the DOM of "this"
* How to expose custom methods
* How to expose an event handler delegate
*/
define([
'jquery'
,
'underscore'
,
'utils/helpers'
,
'text!views/schoolFilterItem.html'
,
'kendoui/kendo.treeview.min'
,
],
function
($, _, Helpers, schoolFilterItemTemplate) {
var
schoolData;
// This defines a Kendo widget object
var
TreeView = kendo.ui.TreeView.extend({
init:
function
(element, options) {
// Assigning this to another variable name captures the context of init, which is "this TreeView"
var
me =
this
;
options.dataSource = {
transport: {
read:
function
(options) {
$.getJSON(Helpers.toServicesUrl(
"/GetfltSchoolByDistrict"
),
{
// If you tried to use "this" in here, it would refer to the dataSource instead of the TreeView
userName: me.options.userName,
districtId: me.options.districtId,
schoolCodes: me.options.schoolCodes
},
function
(data) {
options.success([]);
schoolData = data.GetfltSchoolByDistrictResult.RootResults;
schoolData = [
{
text:
"Schools"
,
expanded:
false
,
items: _(schoolData)
.chain()
.groupBy(
"SchoolTypeName"
)
.map(
function
(groupItems, groupKey) {
return
{
SchoolTypeName: groupKey,
items: groupItems,
expanded:
false
}
})
.value()
}
];
me.dataSource.data(schoolData);
});
}
},
schema: {
model: {
children:
"items"
}
}
};
options.dataBound =
function
(e) {
me.element.find(
"input:checkbox:first"
).prop(
"disabled"
,
true
);
me.element.find(
"input:checkbox"
).on(
"change"
,
function
(e) {
var
parentItems = $(e.target).parents(
".k-item"
);
var
node = parentItems.eq(0);
var
parentNode = parentItems.eq(1);
// Toggle children to match parent
node.find(
"input:checkbox"
).prop(
"checked"
, e.target.checked);
// Update parent's state
var
parentCheckBox = parentNode.find(
"input:checkbox:first"
);
if
(!parentCheckBox.prop(
"disabled"
)) {
var
hasChecked = parentNode.find(
".k-group input:checked"
).length > 0;
var
hasUnchecked = parentNode.find(
".k-group input:not(:checked)"
).length > 0;
parentCheckBox.prop(
"checked"
, hasChecked);
parentCheckBox.prop(
"indeterminate"
, hasChecked && hasUnchecked);
}
// The rest is unchecking other SchoolTypes if a different SchoolType is checked. If "this" is unchecked, no further action required.
if
(!e.target.checked)
return
;
var
dataItem = me.dataItem(node);
if
(!dataItem.SchoolTypeName) {
e.target.checked =
false
;
return
;
}
me.element.find(
"input:checked"
).each(
function
() {
var
eachDataItem = me.dataItem($(
this
).closest(
".k-item"
))
if
(eachDataItem.SchoolTypeName !== dataItem.SchoolTypeName) {
this
.checked =
false
;
this
.indeterminate =
false
;
//lah testing adding something here.
// me.schoolTypeChanged(e);
me.onSchoolChange(e);
}
//gmo when school names don't match
if
(eachDataItem.SchoolName !== dataItem.SchoolName) {
this
.checked =
false
;
me.onSchoolChange(e);
}
});
});
}
kendo.ui.TreeView.fn.init.call(
this
, element, options);
},
options: {
// This is what determines the name of the custom method, e.g. .kendoSchoolFilterTreeView
name:
"TreeViewSchoolFilterSingle"
,
// Declare new options with default values. Options must be declared here in order to be accepted and passed through to init().
userName:
""
,
districtId: 0,
schoolCodes:
function
() {
return
""
},
// Anything else you pass in options will get passed to the base widget
dataTextField: [
"text"
,
"SchoolTypeName"
,
"SchoolName"
],
checkboxes:
true
},
getSelectedSchoolType:
function
() {
var
me =
this
;
return
_(
this
.element.find(
"input:checked"
).closest(
".k-item"
))
.chain()
// .map(function (item) { return ktvSchoolFilter.dataItem(item).SchoolType; })
.map(
function
(item) {
return
me.dataItem(item).SchoolType; })
.filter(
function
(item) {
return
item; })
.value()[0];
},
// This is how to get the selected school from the radio group
getSelectedSchoolCodes:
function
() {
var
me =
this
;
return
_(
this
.element.find(
"input:checked"
).closest(
".k-item"
))
.chain()
// .map(function (item) { return ktvSchoolFilter.dataItem(item).SchoolCode; })
.map(
function
(item) {
return
me.dataItem(item).SchoolCode; })
.filter(
function
(item) {
return
item; })
.value()
.join(
","
);
},
onSchoolChange:
function
(e) {
return
;
},
schoolTypeChanged:
function
(e) {
return
;
}
});
// This is what registers the custom widget and adds the kendo* method to the jQuery object
kendo.ui.plugin(TreeView);
});
ktvSchoolFilter = $(
"#schoolFilterTree"
).kendoTreeViewSchoolFilterSingle({
userName: WSIPCContext.UserName,
districtId: WSIPCContext.DistrictId,
schoolCodes: WSIPCContext.SchoolCodes,
onSchoolChange: schoolCodeChanged,
change: schoolCodeChanged,
schoolTypeChanged: schoolCodeChanged,
checkbox: {
onClick: schoolCodeChanged
}
}).data(
"kendoTreeViewSchoolFilterSingle"
);
//This code allows the grade level and risk categories to change when a checkbox
//is selected, not just the label.
ktvSchoolFilter.dataSource.bind(
"change"
, schoolCodeChanged);
ktvSchoolFilter.dataSource.bind(
"select"
, schoolCodeChanged);
ktvSchoolFilter.dataSource.bind(
"selecting"
, schoolCodeChanged);
ktvSchoolFilter.dataSource.bind(
"navigate"
, schoolCodeChanged);
ktvSchoolFilter.bind(
"change"
, schoolCodeChanged);
ktvSchoolFilter.bind(
"select"
, schoolCodeChanged);
ktvSchoolFilter.bind(
"selecting"
, schoolCodeChanged);
ktvSchoolFilter.bind(
"navigate"
, schoolCodeChanged