Created
April 24, 2012 17:20
-
-
Save joshpangell/2481668 to your computer and use it in GitHub Desktop.
Cargo's project methods
This file contains 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
/** | |
* Cargo's project methods | |
* Manipulating projects | |
*/ | |
/* | |
* Close a project | |
* This will also remove any nav/thumb highlights | |
*/ | |
Cargo.Projects.CloseProject(); | |
/* | |
* Removes the open project, removes the URL, adds a spot in history | |
*/ | |
Cargo.History.Unload(); | |
/* | |
* Load a project from a pid | |
*/ | |
Projects.AjaxLoadByPid( 12345 ); | |
/* | |
* Load a project from a url | |
* Note: The url must be exact, so you might want to use pid instead | |
*/ | |
Projects.AjaxLoadByPurl( 'My-project' ); | |
/* | |
* Overwrites the close project method with a custom version | |
* Useful if you want the project close to do something special | |
* Included in this definition are some helpful actions inside (none are needed) | |
*/ | |
Projects.CustomCloseProject = function() { | |
// Fire the opening Cargo event | |
$(document).trigger("projectClose", [ $("#maincontainer") ] ); | |
// Unload the history | |
Cargo.History.Unload(); | |
// Scroll to the top | |
Projects.Helper.ScrollToTop() | |
// Remove active states | |
$('#pr_contain_item_'+pid).attr("class", ""); | |
if($("#o_thumb_nav").val() == "yes") { | |
$("#page_"+$("#current_page").val()).css("display","block"); | |
} | |
$(".project_thumb, .project_feed_thumb").removeClass("active").removeClass("selected"); | |
$(".nav_active").removeClass("nav_active"); | |
// Fire the closing Cargo event | |
$(document).trigger("projectCloseComplete", [pid, $("#maincontainer")]); | |
}; | |
/* | |
* Overwrites the opening / write project method | |
* This is useful if you want to do something different then default | |
* with the return value from ajax | |
* the "this.Data" value holds most of the important pieces of info | |
* Values : | |
* "Data" : { | |
* "pid" : "", // The current pid | |
* "purl" : "", // purl when parsing the URL | |
* "slideheight" : "", // Returned from Ajax opening | |
* "slidecount" : "", // Returned from Ajax opening | |
* "content" : "", // The full content returned from Ajax | |
* "project_title" : "", // Title of the project, returned from Ajax | |
* } | |
*/ | |
Projects.CustomWriteProject = function() { | |
// Figure out which container to load into | |
container = Projects.Helper.GetContainer(); | |
// Print the project to the container | |
$(container).html( this.Data.content ); | |
// Trigger post load helpers | |
Projects.TriggerPostloadHelpers(); | |
// Scroll to the top of the page | |
Projects.Helper.ScrollToTop(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment