Created
April 19, 2012 22:58
-
-
Save dgs700/2424752 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(['sm_lib/sm.config'], function() { | |
require(['sm_widget_mentorship_close', 'sm_widget_user_survey', | |
'views/avatar_slidetab', 'sm_default'], | |
function(widgetMentorship, userSurvey, AvatarSlideTab){ | |
var avatarSlideTab = new AvatarSlideTab(); | |
userSurvey.show(); | |
widgetMentorship.mentorship_close(".btn_mentorship_close"); | |
if($('.btn_mentorship_pending').size() > 0){ | |
require(['views/mentorship_pending'], function(MentorshipPending){ | |
var mentorshipPending = new MentorshipPending({ | |
el: $('body') | |
}); | |
}); | |
} | |
if($('#mentee_optout_dialog').size() > 0){ | |
require(['sm_widget_request_optout'], function(RequestOptOut){ | |
RequestOptOut.init(); | |
}); | |
} | |
if($('.btn_send_offer').size() > 0){ | |
require(['views/request_offer'], function(MentorMakeOfferView){ | |
var mentorOfferView = new MentorMakeOfferView({ | |
el: $('body') | |
}); | |
}); | |
} | |
require(['views/request_expand'], function(RequestExpandView){ | |
$('.mentee_match_row_details_compact_wrap').each(function(){ | |
new RequestExpandView({ | |
el : $(this) | |
}); | |
}); | |
}); | |
//request app config and bootstrp | |
window.SM = window.SM || {}; | |
window.SM.Request = window.SM.Request || {}; | |
window.SM.Request.data = window.SM.Request.data || {}; | |
if(!$.isEmptyObject(SM.Request.data)){ | |
require(['apps/requestApp'], function(requestApp){ | |
window.SM.eventDispatcher = _.clone(Backbone.Events); | |
var Request = {}; | |
window.SM.Request.config = Request.config = { | |
router: { | |
routes: {}, | |
selectors: { | |
domAttachClass: '.user_right_main_content', | |
listSectionId: '#requests-section', | |
rootPageElem: 'body', | |
categoryKeyId: '#category-key-0' | |
}, | |
pager: false | |
}, | |
history: { | |
root: '/home/', | |
pushState: true | |
}, | |
requestItem: { | |
urlRoot: '/api/requests/' | |
}, | |
requestCollection: { | |
url: '/api/requests/', | |
item: {} | |
}, | |
headerView: { | |
tagName: 'section', | |
className: null, | |
id: 'requests-section', | |
templateId: '#list-header-tpl', | |
events: { | |
createEvtTarget: 'click #create_request_btn' | |
}, | |
html: '<a title="Create a new mentorship request" class="btn_create create_request" id="create_request_btn"></a>', | |
selectors: {}, | |
text: { | |
title: 'My Mentorship Requests' | |
} | |
}, | |
listView: { | |
tagName: null, | |
className: null, | |
id: null, | |
templateId: null, | |
rowView: { | |
tagName: 'article', | |
className: 'my_request_row notepaper_bg', | |
id: null, | |
templateId: '#request-row-tpl', | |
css: { | |
expandBttnClass: 'btn_request_expand', | |
retractBttnClass: 'btn_request_excerpt', | |
retractClass: 'retract', | |
expandClass: 'expand' | |
}, | |
events: { | |
expandEvtTarget: 'click .expand', | |
retractEvtTarget: 'click .retract', | |
updateEvtTarget: 'click .update', | |
deactivateEvtTarget: 'click .deactivate', | |
reactivateEvtTarget: 'click .reactivate' | |
}, | |
selectors: { | |
descriptionId: '#description_', | |
expandId: '#expand_' | |
}, | |
text: { | |
expandTitle: 'Show mentorship request details.', | |
retractTitle: 'Hide mentorship request details.' | |
} | |
} | |
}, | |
createView: { | |
tagName: 'div', | |
className: 'user_modal', | |
id: 'request-update-modal', | |
templateId: '#request-update-tpl', | |
css: { | |
backgroundId: 'request-modal-bg', | |
backgroundClass: 'user_modal_bg', | |
categoryKeyClass: 'category-key-' | |
}, | |
events: { | |
closeEvtTarget: 'click #close-button-id', | |
saveEvtTarget: 'submit #request_form' | |
}, | |
selectors: { | |
formId: '#request_form', | |
submitId: '#request-mentor-button', | |
domAttachElem: 'body', | |
backgroundId: '#request-modal-bg', | |
backgroundClass: '.user_modal_bg', | |
titleId: '#request-title', | |
descriptionId: '#request-description', | |
categoryWrapClass: '.mentoring_cat_wrap', | |
categoryKeyElem: 'input[id^="category-key"]', | |
categoryTitleClass: '.category-title', | |
flashElem: '.user_right_main_content > section' | |
}, | |
text: { | |
flashTitle: 'Mentorship request created successfully.', | |
flashMessage: 'Click "Find Mentors" to display your matches.' | |
}, | |
// include compatable config opts obj for jquery.validate | |
validationConfig: { | |
//debug: true, | |
ignore: null, // default is ignore :hidden but we need to validate hidden fields | |
onkeyup: false, | |
errorPlacement: function(error, element){ | |
if(element.attr('id').indexOf('category-key-') != -1) { | |
element.parent().parent().parent().append(error); | |
} else { | |
element.parent().append(error); | |
} | |
}, | |
rules: { | |
'category-key-0':{ | |
required:true | |
}, | |
'request-description':{ | |
required:true, | |
minlength:200 | |
}, | |
'request-title':{ | |
required:true, | |
maxlength:100 | |
} | |
} | |
}, | |
categoryListView: { | |
tagName: 'div', | |
className: 'mentoring_cat_wrap', | |
id: 'clone-view-0', | |
templateId: '#category-list-tpl', | |
css: { | |
categoriesId: 'categories_menu0' | |
}, | |
events: { | |
addEvtTarget: 'click #add-button-id' | |
}, | |
selectors: { | |
categoriesTemplateId: '#mentoring_cats_template', | |
rootPageElem: 'body', | |
tax_idId: '#mentoring-cat-0', | |
cat_titleId: '#cat-title-0', | |
categoriesMenuId: '#categories_menu0', | |
categoriesKeyId: '#category-key-', | |
categoryCloneClass: '.mentoring_cat_wrap', | |
mcDropdownclass: '.mcdropdown_menu' | |
}, | |
text: {}, | |
categoryCloneView: { | |
tagName: 'div', | |
className: 'mentoring_cat_wrap', | |
id: 'clone-view-', | |
templateId: '#category-clone-tpl', | |
css: { | |
categoriesId: 'categories_menu' | |
}, | |
events: { | |
remove: 'click .mentoring_cat_rm' | |
}, | |
selectors: { | |
rootPageElem: 'body', | |
categoriesTemplateId: '#mentoring_cats_template', | |
categoriesMenuId: '#categories_menu', | |
categoriesKeyId: '#category-key-' | |
}, | |
text: {} | |
} | |
} | |
}, | |
updateView: { | |
text: { | |
flashTitle: 'Mentorship request updated successfully.', | |
flashMessage: 'Click "Find Mentors" to display your matches.' | |
} | |
}, | |
paginatorView: { | |
tagName: 'div', | |
className: 'paginator', | |
id: null, | |
templateId: '#request-paginator-tpl', | |
css: {}, | |
events: { | |
gotoFirstEvtTarget: 'click a.first', | |
gotoPrevEvtTarget: 'click a.prev', | |
gotoNextEvtTarget: 'click a.next', | |
gotoLastEvtTarget: 'click a.last', | |
gotoPageEvtTarget: 'click a.page', | |
changeCountEvtTarget: 'click .howmany a', | |
sortByAscendingEvtTarget: 'click a.sortAsc', | |
sortByDescendingEvtTarget: 'click a.sortDsc' | |
}, | |
selectors: { | |
sortByOptionId: '#sortByOption' | |
}, | |
text: {} | |
} | |
}; | |
// bootstrap the controller and config data | |
window.SM.Request.app = new requestApp.Router({ | |
config: Request.config | |
}); | |
Backbone.emulateHTTP = true; | |
Backbone.emulateJSON = true; | |
Backbone.history.start(Request.config.history); | |
}); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment