Skip to content

Commit

Permalink
Comments for UI elements added
Browse files Browse the repository at this point in the history
  • Loading branch information
larchanka committed Nov 13, 2013
1 parent 313cb8a commit de1bfea
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 131 deletions.
164 changes: 94 additions & 70 deletions js/xf.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/xf.min.js

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion xf/ui/xf.ui.header.js
Expand Up @@ -14,12 +14,13 @@
return;
}

// detect if we have title
// Detect if we have title
var headerTitle = jQHeader.find('h1');
if (headerTitle.length > 0) {
headerTitle.addClass('xf-header-title');
}

// Set up options
options.id = options.id || XF.utils.uniqueID();
options.title = options.title || '';
options.html = jQHeader.html();
Expand All @@ -28,10 +29,12 @@
var parentPages = $(this.selector).parents('.xf-page'),
siblingPages = $(this.selector).siblings('.xf-page');

// Add additional class for parent node
if (!_.isEmpty(parentPages) && options.isFixed) {
parentPages.addClass('xf-has-header');
}

// Add additional class for siblings
if (!_.isEmpty(siblingPages)) {
siblingPages.addClass('xf-has-header');
}
Expand Down
6 changes: 4 additions & 2 deletions xf/ui/xf.ui.list.js
Expand Up @@ -61,11 +61,13 @@
);
});

// detect headers inside of list
// Detect headers inside of list and add class
listItems.find('h1, h2, h3, h4, h5, h6').addClass('xf-li-header');

// Detect paragraphs inside of list and add class
listItems.find('p').addClass('xf-li-desc');

// Detect if list item is static
listItems.filter('.xf-li-static').each(function (){
$(this).wrapInner('<div class=xf-li-wrap />');
});
Expand All @@ -80,7 +82,7 @@
class_ += ' xf-li-' + role;
}

// use `class_` instead of `class` beacuse of IE <=8 has problems
// Use `class_` instead of `class` beacuse of IE <=8 has problems
listItemsScope.push({'html': html, 'class_': class_, 'id': id});
});

Expand Down
10 changes: 6 additions & 4 deletions xf/ui/xf.ui.loader.js
Expand Up @@ -22,6 +22,7 @@
idStack = XF.ui.checkInIsset('loader'),
newId = false;

// Check if locader with the same ID was created before
for (var i in idStack) {

if (newId) {
Expand All @@ -33,6 +34,7 @@
}
}

// If 'no', add new ID to the stack
if (!newId) {
XF.ui.issetElements.push({type : 'loader', id : id});
}
Expand All @@ -46,13 +48,13 @@
return jqLoader;
},

// show loader or create newone and show it
// Show loader or create newone and show it
show : function (jqLoader) {
jqLoader = jqLoader || this.create();
jqLoader.show();
},

// hide loader or hide all
// Hide loader or hide all
hide : function (jqLoader) {
jqLoader = jqLoader || null;
if (jqLoader === null) {
Expand All @@ -62,13 +64,13 @@
}
},

// remove loader's dom-element
// Remove loader's dom-element
remove : function (jqLoader) {
jqLoader.detach();
XF.ui.removeFromIsset('popup', jqLoader.attr('id'));
},

//add new loader to the page
// Add new loader to the page
create : function () {
var jqLoader = $('<div class="xf-loader" data-role="loader"><div class="xf-loader-content"><div class="loading"></div></div></div>');
XF.device.getViewport().append(jqLoader);
Expand Down
12 changes: 8 additions & 4 deletions xf/ui/xf.ui.popup.js
Expand Up @@ -190,36 +190,40 @@

jQButton.html(buttonDescr.text);

//Set button's attributes
// Icon
if (buttonDescr.icon && buttonDescr.icon != '') {
attrs['data-icon'] = buttonDescr.icon;
};

// Icon position
if (buttonDescr.iconpos && buttonDescr.iconpos != '') {
attrs['data-iconpos'] = buttonDescr.iconpos;
};

// Button size
if (buttonDescr.small && buttonDescr.small != '') {
attrs['data-small'] = buttonDescr.small;
};

// Button appearance
if (buttonDescr.appearance && buttonDescr.appearance != '') {
attrs['data-appearance'] = buttonDescr.appearance;
};

// Button is special or not
if (buttonDescr.special && buttonDescr.special != '') {
attrs['data-special'] = buttonDescr.special;
};

// Button is 'alert' or not
if (buttonDescr.alert && buttonDescr.alert != '') {
attrs['data-alert'] = buttonDescr.alert;
};

if (_.isFunction(buttonDescr.handler)) {
jQButton.click(buttonDescr.handler)
};

jQButton.attr(attrs);

// Set function for button pressed
if (_.isFunction(buttonDescr.handler)) {
jQButton.on('tap', buttonDescr.handler);
};
Expand Down
8 changes: 4 additions & 4 deletions xf/ui/xf.ui.scrollable.js
@@ -1,8 +1,6 @@

/**
Adds scrolling functionality
@param scrollable DOM Object
@private
Add scrolling functionality
*/
XF.ui.scrollable = {

Expand All @@ -21,7 +19,7 @@

var children = jQScrollable.children();

// always create wrapper
// Always create wrapper
if (children.length == 1 && false) {
children.addClass('xf-scrollable-content');
} else {
Expand All @@ -39,6 +37,7 @@
jQScrollable.attr({'id':wrapperId});
}

// Use iScroll
var ISItem = jQScrollable.data('iscroll', new iScroll(wrapperId));
var wrapperChanged = false;

Expand All @@ -59,6 +58,7 @@
}
};

// Bind hadlers to the scrollable element
var bindHanlders = function () {
$('#' + wrapperId + ' *')
.bind('detach', needRefreshIScroll)
Expand Down
10 changes: 7 additions & 3 deletions xf/ui/xf.ui.tabs.js
@@ -1,11 +1,10 @@

/**
Enhances footers view
@param footer DOM Object
@private
*/
XF.ui.tabs = {

// Selectors will be used to detect tabs' element on the page
selector : '[data-role=tabs]',

render : function (tabs, options) {
Expand All @@ -26,7 +25,8 @@
});

options.tabs = options.tabs || [];


// Detect buttons and count rows
var buttons = jQTabs.find(XF.ui.button.selector);
options.rowCount = Math.ceil(buttons.length / options.tabsperrow);
options.tabsClass = options.tabsclass || '';
Expand All @@ -36,6 +36,7 @@
lastRowSize = options.tabsperrow;
}

// Position buttons in rows
for (var i = 0; i < buttons.length; ++i){
var tab = buttons.eq(i),
x = i + 1,
Expand Down Expand Up @@ -76,6 +77,7 @@
options.tabs.push(tabOpts);
}

// Underscore template for tabs
var _template = _.template(
'<ul class="xf-tabs">'
+ '<% _.each(tabs, function(tab) { %>'
Expand All @@ -90,11 +92,13 @@

jQTabs.html(_template(options));

// Add tab selection' handler to buttons
jQTabs.find('a').on('tap', function () {
XF.ui.tabs.selectTab(jQTabs, $(this));
});
},

// Method to show appropriate tab
selectTab : function (parent, el) {
parent.find('a').removeClass('xf-tabs-button-active');
el.addClass('xf-tabs-button-active');
Expand Down

0 comments on commit de1bfea

Please sign in to comment.