or
define([
'jquery'
,
'kendo'
,
'Helpers/TemplateLoader'
],
function
($, kendo, loader)
{
var
viewModel =
null
;
var
accountSession =
null
;
var
init =
function
()
{
//Create the View.
loader.loadTemplate(
"login"
);
var
template = kendo.template($(
"#login"
).html())({});
$(
"#adbrain"
).html(template);
//Create the DataSource.
accountSession =
new
kendo.data.DataSource(
{
transport: {
read: {
url:
"/accountSession"
},
create: {
url:
"/accountSession"
,
type:
"POST"
}
}
}
)
//Create the ViewModel.
viewModel = kendo.observable(
{
username:
{
value:
""
,
enabled:
true
},
password:
{
value:
""
,
enabled:
true
},
button:
{
enabled:
true
},
error:
""
,
doSubmit:
function
(event)
{
//Prevent the default action.
event.preventDefault();
//Clear the error.
this
.set(
"error"
,
""
);
//Disable all controls.
this
.set(
"username.enabled"
,
false
);
this
.set(
"password.enabled"
,
false
);
this
.set(
"button.enabled"
,
false
);
//Animate the Adbrain logo.
$(
"#login_loading_stable"
).addClass(
"hidden"
);
$(
"#login_loading"
).removeClass(
"hidden"
);
accountSession.add({UserName:
this
.username.value, Password:
this
.password.value});
accountSession.sync();
}
}
);
//Bind View and ViewModel together.
kendo.bind($(
"#login_form"
), viewModel);
}
var
doLogin =
function
()
{
alert(
"login"
);
}
return
{
init: init,
doLogin: doLogin
}
}
)
<
script
type
=
"x-kendo-template"
id
=
"login"
class
=
"template"
>
<
form
id
=
"login_form"
data-bind
=
"events: { submit: doSubmit }"
>
<
div
class
=
"group"
>
<
img
id
=
"login_loading_stable"
src
=
"../../Images/login-logo.png"
/>
<
img
id
=
"login_loading"
class
=
"hidden"
src
=
"../../Images/a-loader.gif"
/>
<
div
class
=
"entity"
>
<
div
class
=
"cell label"
>
<
label
for
=
"username_input"
>Username</
label
>
</
div
>
<
div
class
=
"cell field"
>
<
input
id
=
"username_input"
name
=
"UserName"
type
=
"text"
data-bind
=
"enabled: username.enabled, value: username.value"
/>
</
div
>
</
div
>
<
div
class
=
"entity"
>
<
div
class
=
"cell label"
>
<
label
for
=
"password_input"
>Password</
label
>
</
div
>
<
div
class
=
"cell field"
>
<
input
id
=
"password_input"
name
=
"Password"
type
=
"password"
data-bind
=
"enabled: password.enabled, value: password.value"
/>
</
div
>
</
div
>
<
input
id
=
"login_button"
type
=
"submit"
data-bind
=
"enabled: button.enabled"
value
=
"Login"
/>
</
div
>
<
p
id
=
"error_message"
class
=
"error"
data-bind
=
"text: error"
></
p
>
</
form
>
</
script
>
var ddl = $('<
input
data-bind
=
"value:' + options.field + '"
style
=
"display:none;"
/>')
.appendTo(container);
ddl.kendoDropDownList({
dataTextField: list.displayColumn,
dataValueField: list.valueColumn,
autoBind: false,
optionLabel: optionLabel,
dataSource: list.dataSource
});
@(Html.Kendo().Grid<Novus.MediaAccounting.Models.Buys.BuyModel>(Model.GridData)
.Name(Model.GridName)
.AutoBind(Model.AutoBind)
.Deferred()
.Resizable(resizing => resizing.Columns(
true
))
.Scrollable()
.Columns(columns =>
{
columns.Bound(o => o.Id)
.ClientTemplate(
"<input name='selectedBuys' id='selectedBuys' type='checkbox' value='#= Id #' onclick='gridRowSelected(this);' />"
)
.Template(
@<text>
<input name=
"selectedBuys"
type=
"checkbox"
value=
"@item.Id"
onclick=
"gridRowSelected(this);"
/>
</text>)
.HeaderTemplate(
"<input type='checkbox' title='check all records' id='checkAll' onclick='gridCheckAll(\"BuysGrid\", this);' />"
)
.Width(35)
.HeaderHtmlAttributes(
new
{ style =
"text-align:center"
})
.HtmlAttributes(
new
{ style =
"text-align:center"
})
.Title(
string
.Empty)
.Filterable(
false
)
.Sortable(
false
);
columns.Bound(o => o.Id)
.ClientTemplate(
"<div class='btn-group'><a class='btn dropdown-toggle' data-toggle='dropdown' href='javascript:void(0)'>Action<span class='caret'></span></a>"
+
"<ul class='dropdown-menu'>"
+
"# if (ClientInvoicingStatusDisplay != 'Invoiced') {#"
+
"<li><a href='"
+ Url.Action(
"EditBuy"
,
"Buy"
) +
"?buyId=#= Id #'"
+
"><i class='icon-pencil'></i> Edit Buy</a></li>"
+
"#}#"
+
"<li><a href='"
+ Url.Action(
"ViewDetails"
,
"Buy"
) +
"?buyId=#= Id #'"
+
"><i class='icon-eye-open'></i> View Details</a></li>"
+
"<li><a href='"
+ Url.Action(
"BuyHistory"
,
"Audit"
) +
"?buyId=#= Id #'"
+
"><i class='icon-tasks'></i> Audit History</a></li>"
+
"</ul></div>"
)
.Template(
@<text>
<div
class
=
"btn-group"
>
<a
class
=
"btn dropdown-toggle"
data-toggle=
"dropdown"
href=
"#"
>
Action
<span
class
=
"caret"
></span>
</a>
<ul
class
=
"dropdown-menu"
>
@
if
(item.ClientInvoicingStatusDisplay !=
"Invoiced"
)
{
<li><a href=
"@Url.Action("
EditBuy
", "
Buy
", new { buyId = @item.Id })"
><i
class
=
"icon-pencil"
></i> Edit Buy</a></li>
}
<li><a href=
"@Url.Action("
ViewDetails
", "
Buy
", new { buyId = @item.Id })"
><i
class
=
"icon-eye-open"
></i> ViewDetails</a></li>
<li><a href=
"@Url.Action("
BuyHistory
", "
Audit
", new { buyId = @item.Id })"
><i
class
=
"icon-tasks"
></i> Audit History</a></li>
</ul>
</div>
</text>)
.Title(
""
)
.Width(100)
.Filterable(
false
)
.Sortable(
false
)
.HtmlAttributes(
new
{ style =
"overflow: visible;"
});
columns.Bound(o => o.BuyId)
.Width(150);
columns.Bound(o => o.BillMonth)
.Width(80);
columns.Bound(o => o.StatusDisplay)
.Width(125);
columns.Bound(o => o.ClientInvoicingStatusDisplay)
.Width(125);
columns.Bound(o => o.Payor)
.Width(175);
columns.Bound(o => o.MediaTypeDisplay)
.Width(150);
columns.Bound(o => o.ClientNetRate)
.Width(100)
.Format(
"{0:c}"
)
.HtmlAttributes(
new
{ style =
"text-align: right;"
});
columns.Bound(o => o.PriorInvoicedAmount)
.Width(110)
.Format(
"{0:c}"
)
.HtmlAttributes(
new
{ style =
"text-align: right;"
});
columns.Bound(o => o.NovusCompany)
.Width(155);
columns.Bound(o => o.InvoiceDate)
.Width(110)
.Format(
"{0:MM/dd/yyyy}"
);
})
.Filterable()
.Sortable(sorting => sorting.SortMode(GridSortMode.MultipleColumn))
.Pageable(page => page.PageSizes(
new
[] { 50, 100, 200 }).Refresh(
true
))
.BindTo(Model.GridData)
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(Model.ServerOperation)
.Read(read => read
.Action(Model.Action, Model.Controller)
.Data(Model.JavascriptDataFunction))
//.Model(model => model.Id(p => p.Id))
.Sort(sort => sort.Add(c => c.InvoiceDate))
.PageSize(50)
)
)
@(Html.Kendo().TabStrip()
.Name("tabstripChart")
.Items(tabstrip =>
{
tabstrip.Add().Text("Chart")
.Selected(true)
.Content(
@<
text
>
<
div
id
=
"symbolChart"
data-role
=
"chart"
data-series
=
"[{ field: 'Hours' }]"
data-category-axis
=
"{ field: 'Label' }"
data-series-defaults
=
"{ type: 'line' }"
data-bind
=
"source: Activity"
>
</
div
>
<
script
type
=
"text/javascript"
>
alert("hey");
var viewModel = kendo.observable({
Activity: [
{ Label: "Jan", Hours: 10 },
{ Label: "Feb", Hours: 5 }
]
});
kendo.bind($("#symbolChart"), viewModel);
</
script
>
</
text
>
);
tabstrip.Add().Text("Realtime Chart")
.Content(@<
text
></
text
>);
})
)