-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:keithnlarsen/nodification
- Loading branch information
Showing
5 changed files
with
272 additions
and
161 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
|
||
function bindData( obj, data ){ | ||
var mappedTypes = $.map ( data, function( item ) { | ||
return new obj( item ); | ||
}); | ||
return mappedTypes; | ||
} | ||
|
||
|
||
function displayMessage ( msg, error ) { | ||
$( '#feedbackMessage span' ).html( msg ); | ||
if ( error ) { | ||
$( '#feedbackMessage' ).addClass( 'error' ).fadeIn( 'slow', function(){ | ||
$(this).fadeOut(2000); | ||
}); | ||
} else { | ||
$( '#feedbackMessage' ).removeClass( 'error' ).fadeIn( 'slow', function(){ | ||
$(this).fadeOut(2000); | ||
}); | ||
} | ||
} | ||
|
||
function findObjectInArray( item, item_id, array ) { | ||
|
||
var foundObj = null; | ||
for ( i in array ) { | ||
var tmpObj = array[i]; | ||
if( tmpObj[item_id] === item ){ | ||
foundObj = tmpObj; | ||
return foundObj; | ||
} | ||
} | ||
} | ||
|
||
function getNotifcationTypes ( self, callback ) { | ||
$.ajax( { | ||
type: 'GET', | ||
url: '/notificationTypes', | ||
contentType: 'application/json; charset=utf-8', | ||
success: function ( data ) { | ||
var mappedTypes = bindData ( notificationType, data ); | ||
self.notificationTypes( mappedTypes ); | ||
callback(); | ||
}, | ||
error: function () { | ||
_displayMessage( "An error occurred while retrieving the Notification Types.", true ); | ||
} | ||
} ); | ||
} |
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
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
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
Oops, something went wrong.