Skip to content

Commit

Permalink
tab-control live binding for tabs click
Browse files Browse the repository at this point in the history
  • Loading branch information
olton committed Jul 12, 2014
1 parent c615c53 commit 8dc327c
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 48 deletions.
6 changes: 3 additions & 3 deletions docs/js/metro.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 20 additions & 21 deletions docs/js/metro/metro-tab-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,34 @@

this.init(tabs, frames);

tabs.each(function(){
element.on("click", ".tabs > li > a", function(e){
e.preventDefault();
e.stopPropagation();

var tab = $(this).children("a");
that.options.tabclick(this);

tab.on('click', function(e){
e.preventDefault();
if ($(this).parent().hasClass('disabled')) {
return false;
}

that.options.tabclick(this);
element.children(".tabs").children("li").removeClass("active");
element.children(".frames").children(".frame").hide();

if ($(this).parent().hasClass('disabled')) {
return false;
}
$(this).parent().addClass("active");

tabs.removeClass("active");
tab.parent("li").addClass("active");
var current_frame = $($(this).attr("href"));
switch (that.options.effect) {
case 'slide': current_frame.slideDown(); break;
case 'fade': current_frame.fadeIn(); break;
default: current_frame.show();
}

frames.hide();
var current_frame = $(tab.attr("href"));
switch (that.options.effect) {
case 'slide': current_frame.slideDown(); break;
case 'fade': current_frame.fadeIn(); break;
default: current_frame.show();
}
that._trigger('change', null, current_frame);
that.options.tabchange(this);

that._trigger('change', null, current_frame);
that.options.tabchange(this);
if (element_id != undefined) window.localStorage.setItem(element_id+"-current-tab", $(this).attr("href"));

if (element_id != undefined) window.localStorage.setItem(element_id+"-current-tab", $(this).attr("href"));
});
return true;
});

if (this.options.activateStoredTab) this._activateStoredTab(tabs);
Expand Down
41 changes: 20 additions & 21 deletions js/metro-tab-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,34 @@

this.init(tabs, frames);

tabs.each(function(){
element.on("click", ".tabs > li > a", function(e){
e.preventDefault();
e.stopPropagation();

var tab = $(this).children("a");
that.options.tabclick(this);

tab.on('click', function(e){
e.preventDefault();
if ($(this).parent().hasClass('disabled')) {
return false;
}

that.options.tabclick(this);
element.children(".tabs").children("li").removeClass("active");
element.children(".frames").children(".frame").hide();

if ($(this).parent().hasClass('disabled')) {
return false;
}
$(this).parent().addClass("active");

tabs.removeClass("active");
tab.parent("li").addClass("active");
var current_frame = $($(this).attr("href"));
switch (that.options.effect) {
case 'slide': current_frame.slideDown(); break;
case 'fade': current_frame.fadeIn(); break;
default: current_frame.show();
}

frames.hide();
var current_frame = $(tab.attr("href"));
switch (that.options.effect) {
case 'slide': current_frame.slideDown(); break;
case 'fade': current_frame.fadeIn(); break;
default: current_frame.show();
}
that._trigger('change', null, current_frame);
that.options.tabchange(this);

that._trigger('change', null, current_frame);
that.options.tabchange(this);
if (element_id != undefined) window.localStorage.setItem(element_id+"-current-tab", $(this).attr("href"));

if (element_id != undefined) window.localStorage.setItem(element_id+"-current-tab", $(this).attr("href"));
});
return true;
});

if (this.options.activateStoredTab) this._activateStoredTab(tabs);
Expand Down
Loading

0 comments on commit 8dc327c

Please sign in to comment.