11. a').hasClass('md_fullpage')) {
// alert('clicked section is current section AND fullpage mode is active; teaser should load');
// Minimize
jQuery('#md_tabs_navigation a').removeClass('md_fullpage');
jQuery('.md_body').hide();
jQuery('#md_feature').slideDown('normal',function(){
var bodyContent = jQuery('#md_body_'+ section);
bodyContent.fadeOut('normal',function(){
jQuery('#md_tabs_navigation a').each(function(){
var thisSection = jQuery(this).html().replace('<span<','').replace('</span<','');
var thisSection_comp = thisSection.toLowerCase().replace(' ','_');
jQuery('#md_body_'+ thisSection_comp).load(
'/app/modules/info/loadTeaser.php?sect='+ thisSection_comp,
function(){
tb_init('.md_body a.thickbox, .md_body area.thickbox, .md_body input.thickbox');
bodyContent.animate({ height: 'toggle', opacity: 'toggle' },"slow");
}
);
});
});
});
jQuery('#expandtabs span').empty().append('Expand Tabs');
} else {
// if the clicked section is NOT the current section OR we're NOT in full page mode
// then let's go to full page mode and show the whole tab
// Maximize
// alert('clicked section is not the current section OR full page mode is not active; full section should
load');
jQuery('#md_tabs_navigation li').removeClass('current');
jQuery('#md_tab_'+ section).addClass('current');
jQuery('#md_tabs_navigation a').addClass('md_fullpage');
jQuery('.md_body').hide();
jQuery('#md_feature').slideUp('normal',function(){
var bodyContent = jQuery('#md_body_'+ section);
bodyContent.fadeOut('normal',function(){
bodyContent.empty();
var pageLoader = 'info/loadSection.php?sect='+ section;
if (section == 'contact_us') {
pageLoader = 'contact/loadContactForm.php?form_id=1';
}
bodyContent.load('/app/modules/'+ pageLoader,function(){
// ADD THICKBOXES
tb_init('.md_body a.thickbox, .md_body area.thickbox, .md_body input.thickbox');
$recent_news_links = jQuery('ul.md_news li a.recent_news_link');
$recent_news_links
.unbind('click')
.each(function(){
var hrefMod = this.href;
hrefMod = hrefMod.replace(/article/,'loadNews').replace(/storyid/,'id');
this.href = hrefMod;
})
.click(function(){
Thursday, April 26, 12 var t = this.title || this.name || null;
24. views display data, announce user interaction,
and await further instruction
models & collections manage application
state and communicate with the server
controllers set up views, transport messages
from views to models & collections
Thursday, April 26, 12
25. app/views/searchForm app/views/recentSearches
app/views/results
Thursday, April 26, 12
27. searches collection keeps track of recent
search terms
search data collection fetches results from
the server for a given search term
app model keeps track of general application
state, including the current search
search model for representing individual
searches
Thursday, April 26, 12
28. app/views/searchForm
search controller
server search data searches collection
app model
app/views/recentSearches
app/views/results
Thursday, April 26, 12
30. app/views/searchForm
search controller
server search data searches collection
app model
app/views/recentSearches
app/views/results
Thursday, April 26, 12
32. searchForm.on('search', update);
function update(t) {
var term = $.trim(t),
existing = searches.where({ term : term }),
dfd = $.Deferred(),
search;
app.set('currentSearch', term);
if (term) {
if (existing.length) {
search = existing[0];
search.update();
} else {
search = new Search({ term : term });
searches.add(search);
}
searchData.fetch({ data : { term : term } })
.then(dfd.resolve, dfd.reject)
.always(searchForm.release);
app.router.navigate('search/' + term);
} else {
dfd.resolve();
}
return dfd;
}
Thursday, April 26, 12
33. it("should announce the form submission", function() {
var t;
sf.on('search', function(term) {
t = term;
});
el.find('.js-input').val('searchterm');
el.find('.search-form').submit();
expect(t).to.be('searchterm');
});
Thursday, April 26, 12
34. it("should update the page when the search form announces a search", function(done) {
var searchFormEl = $('.component.search-form').parent(),
searchForm = _.filter(s.views, function(v) {
return v.$el[0] === searchFormEl[0];
})[0];
s.searchData.on('change', function() {
expect($('.component.results').html()).to.contain('srchr');
expect($('.component.recent-searches').html()).to.contain('srchr');
expect(navigatedTo).to.be('search/srchr');
done();
});
searchForm.trigger('search', 'srchr');
});
Thursday, April 26, 12
35. app/views/searchForm
search controller
server search data searches collection
app model
app/views/recentSearches
app/views/results
Thursday, April 26, 12
36. function update(t) {
var term = $.trim(t),
existing = searches.where({ term : term }),
dfd = $.Deferred(),
search;
app.set('currentSearch', term);
if (term) {
if (existing.length) {
search = existing[0];
search.update();
} else {
search = new Search({ term : term });
searches.add(search);
}
searchData.fetch({ data : { term : term } })
.then(dfd.resolve, dfd.reject)
.always(searchForm.release);
app.router.navigate('search/' + term);
} else {
dfd.resolve();
}
return dfd;
}
Thursday, April 26, 12
39. function update(t) {
var term = $.trim(t),
existing = searches.where({ term : term }),
search;
app.set('currentSearch', term);
if (existing.length) {
search = existing[0];
search.update();
} else {
search = new Search({ term : term });
searches.add(search);
}
searchData.fetch({ data : { term : term } })
.always(searchForm.release);
app.router.navigate('search/' + term);
}
Thursday, April 26, 12
40. describe("#update", function() {
it("should update the time", function(done) {
var search = new Search(),
oldTime = search.get('time');
setTimeout(function() {
search.update();
expect(search.get('time')).to.be.greaterThan(oldTime);
done();
}, 1000);
});
});
Thursday, April 26, 12
41. it("should update when there is a new search", function() {
expect(el.html()).not.to.contain('baz');
rs.currentSearch = function() { return 'baz'; };
rs.searches.add({ term : 'baz' });
expect(el.html()).to.contain('baz');
expect(el.find('.active').html()).to.contain('baz');
});
Thursday, April 26, 12
42. memory management
requirejs builds for production
multi-page apps w/history api
Thursday, April 26, 12