kendo.mobile.navbar.js
6.88 KB
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
/**
* Kendo UI v2016.1.112 (http://www.telerik.com/kendo-ui)
* Copyright 2016 Telerik AD. All rights reserved.
*
* Kendo UI commercial licenses may be obtained at
* http://www.telerik.com/purchase/license-agreement/kendo-ui-complete
* If you do not own a commercial license, this file shall be governed by the trial license terms.
*/
(function (f, define) {
define('kendo.mobile.navbar', ['kendo.core'], f);
}(function () {
var __meta__ = {
id: 'mobile.navbar',
name: 'NavBar',
category: 'mobile',
description: 'The Kendo mobile NavBar widget is used inside a mobile View or Layout Header element to display an application navigation bar.',
depends: ['core']
};
(function ($, undefined) {
var kendo = window.kendo, mobile = kendo.mobile, ui = mobile.ui, Widget = ui.Widget;
function createContainer(align, element) {
var items = element.find('[' + kendo.attr('align') + '=' + align + ']');
if (items[0]) {
return $('<div class="km-' + align + 'item" />').append(items).prependTo(element);
}
}
function toggleTitle(centerElement) {
var siblings = centerElement.siblings(), noTitle = !!centerElement.children('ul')[0], showTitle = !!siblings[0] && $.trim(centerElement.text()) === '', android = !!(kendo.mobile.application && kendo.mobile.application.element.is('.km-android'));
centerElement.prevAll().toggleClass('km-absolute', noTitle);
centerElement.toggleClass('km-show-title', showTitle);
centerElement.toggleClass('km-fill-title', showTitle && !$.trim(centerElement.html()));
centerElement.toggleClass('km-no-title', noTitle);
centerElement.toggleClass('km-hide-title', android && !siblings.children().is(':visible'));
}
var NavBar = Widget.extend({
init: function (element, options) {
var that = this;
Widget.fn.init.call(that, element, options);
element = that.element;
that.container().bind('show', $.proxy(this, 'refresh'));
element.addClass('km-navbar').wrapInner($('<div class="km-view-title km-show-title" />'));
that.leftElement = createContainer('left', element);
that.rightElement = createContainer('right', element);
that.centerElement = element.find('.km-view-title');
},
options: { name: 'NavBar' },
title: function (value) {
this.element.find(kendo.roleSelector('view-title')).text(value);
toggleTitle(this.centerElement);
},
refresh: function (e) {
var view = e.view;
this.title(view.options.title);
},
destroy: function () {
Widget.fn.destroy.call(this);
kendo.destroy(this.element);
}
});
ui.plugin(NavBar);
}(window.kendo.jQuery));
return window.kendo;
}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {
(a3 || a2)();
}));