Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- group = {
- /* holds name of current stage 1 opperation in progress
- */
- current_op : false,
- /* defines command aliases
- */
- aliases : {t:'Topic', d:'Delete', e:'Edit'},
- /* sends info to server to modify page content
- * runs publish command for object functions with response data
- */
- modify : function(){
- $.post(
- "<?php echo site_url('topics/groups/modify');?>",
- {id:command.subject_id,alias:this.current_op.substring(0,1),input:command.received},
- function(data){
- group[group.current_op].publish(data);
- },
- 'json'
- );
- },
- /* sends info to server to add task to group
- * runs publish command with response html
- */
- create_topic : function(){
- $.post("<?php echo site_url('topics/topic/create');?>",
- {id:command.subject_id,alias:this.current_op.substring(0,1),input:command.received},
- function(data){
- group.topic.publish(data);
- },
- 'json'
- );
- },
- /* deletes groups
- */
- delete : {
- validate : function(){
- //if 'enter' was pressed on prompt, delete group
- if(command.keycode == 13){group.modify();}
- },
- prompt : function(){
- command.prompt('Press enter to confirm delete. [note optional]');
- },
- publish : function(data){
- if(data.response == 'remove')
- {
- $('#group_'+command.subject_id).remove();
- command.prompt('group deleted');
- }
- group.conclude();
- }
- },
- /* edits groups
- */
- edit : {
- validate : function(){
- //expects new text to replace old text
- group.modify();
- },
- prompt : function(){
- command.prompt('Enter new group name');
- },
- publish : function(data){
- if(data.response == 'edit'){
- $('#group_'+command.subject_id+' li.group-title').html(data.name);
- command.prompt('group edited');
- }
- else{
- command.prompt('Error while editing group');
- }
- group.conclude();
- }
- },
- /* adds tasks to groups
- */
- topic : {
- validate : function(){
- group.create_topic();
- },
- prompt : function(){
- command.prompt('Enter topic name then press [enter]');
- },
- publish : function(data){
- if(data.response == 'add'){
- $('#group_'+command.subject_id+' .topics').append(data.html);
- //recreate sidebar topics so new topic is included
- layout.sidebar_topics();
- command.prompt('Task added');
- }
- else{
- command.prompt('Error trying to add topic');
- }
- group.conclude();
- }
- },
- close :{
- validate : function(){
- group.modify();
- },
- prompt : function(){
- command.prompt('Press enter to verify closure [note optional]');
- },
- publish : function(data){
- if(data.response == 'close'){
- command.prompt('group closed');
- //remove group from page
- $('#group_'+command.subject_id).remove();
- }
- else{
- command.prompt('An error occurred while trying to close the group');
- }
- group.conclude();
- }
- },
- conclude : function(){
- command.prompt('Ready...');
- $('.register').removeClass('marked');
- group.current_op = false;
- command.flush();
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment