mirror of
				https://github.com/flynx/PortableMag.git
				synced 2025-10-31 20:10:13 +00:00 
			
		
		
		
	cleanup and refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									a0a216ed3f
								
							
						
					
					
						commit
						e19ea5b539
					
				
							
								
								
									
										111
									
								
								magazine.js
									
									
									
									
									
								
							
							
						
						
									
										111
									
								
								magazine.js
									
									
									
									
									
								
							| @ -712,7 +712,24 @@ function updatePageNumberIndicator(){ | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| /*********************************************************** state ***/ | /*********************************************************** state **** | ||||||
|  | * | ||||||
|  | *  Local state consists of: | ||||||
|  | *  	- current page | ||||||
|  | *  	- bookmarks | ||||||
|  | *  | ||||||
|  | *  Two types of store are used for local state: | ||||||
|  | *  	- #URL | ||||||
|  | *  		stores current page number | ||||||
|  | *  		is used for special URLs like #home, #next, etc. | ||||||
|  | *  	- localStorage | ||||||
|  | *  		stores current page (overriden by #URL if both are present) | ||||||
|  | *  		stores bookmarks | ||||||
|  | *  | ||||||
|  | *  NOTE: localStorage is magazine specific. | ||||||
|  | *  | ||||||
|  | * | ||||||
|  | **********************************************************************/ | ||||||
| 
 | 
 | ||||||
| // XXX make URLs magazine-specific...
 | // XXX make URLs magazine-specific...
 | ||||||
| // 		...for extrnal linking we'll need the magazine ID, or make each 
 | // 		...for extrnal linking we'll need the magazine ID, or make each 
 | ||||||
| @ -878,43 +895,52 @@ function resetState(){ | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| /********************************************** JSON serialization ***/ | /********************************************** JSON serialization **** | ||||||
| // JSON format state managers...
 | *  | ||||||
| // format:
 | * JSON is used to load/store the magazine data and state. | ||||||
| // 		{
 | * | ||||||
| // 			title: <magazine-title>,
 | * This format may also include local state, like current page number  | ||||||
| // 			bookmarks: [
 | * and bookmarks. | ||||||
| // 				<page-numer>,
 | * | ||||||
| // 				...
 | * Format: | ||||||
| // 			],
 | *  	{ | ||||||
| // 			// this is optional...
 | *  		title: <magazine-title>, | ||||||
| // 			position: <page-number>
 | *  		bookmarks: [ | ||||||
| // 			pages: [
 | *  			<page-numer>, | ||||||
| // 				// root <page>...
 | *  			... | ||||||
| // 				{
 | *  		], | ||||||
| // 					type: 'page' | 'cover',
 | *  		// this is optional...
 | ||||||
| // 					// classes set on the page element...
 | *  		position: <page-number> | ||||||
| // 					class: [...]
 | *  		pages: [ | ||||||
| // 					content: <page-content>
 | *  			// root <page>...
 | ||||||
| // 				},
 | *  			{ | ||||||
| //
 | *  				type: 'page' | 'cover', | ||||||
| // 				// article...
 | *  				// classes set on the page element...
 | ||||||
| // 				{
 | *  				class: [...] | ||||||
| // 					type: 'article',
 | *  				content: <page-content> | ||||||
| // 					// classes set on the article element...
 | *  			}, | ||||||
| // 					class: [...]
 | * | ||||||
| // 					pages: [
 | *  			// article...
 | ||||||
| // 						<page>,
 | *  			{ | ||||||
| // 						...
 | *  				type: 'article', | ||||||
| // 					]
 | *  				// classes set on the article element...
 | ||||||
| // 				]
 | *  				class: [...] | ||||||
| // 				...
 | *  				pages: [ | ||||||
| // 			]
 | *  					<page>, | ||||||
| // 		}
 | *  					... | ||||||
| //
 | *  				] | ||||||
| // NOTE: content classes are stored in the content...
 | *  			}, | ||||||
| // NOTE: at this point all page classes will be stored, but .current 
 | *  			... | ||||||
| // 		will be ignored on restore...
 | *  		] | ||||||
|  | *  	} | ||||||
|  | *  | ||||||
|  | * NOTE: content classes are stored in the content... | ||||||
|  | * NOTE: at this point all page classes will be stored, but .current  | ||||||
|  | *  		will be ignored on restore... | ||||||
|  | * | ||||||
|  | * | ||||||
|  | **********************************************************************/ | ||||||
|  | 
 | ||||||
| function buildJSON(export_bookmarks, export_position){ | function buildJSON(export_bookmarks, export_position){ | ||||||
| 	function _getContent(_, elem){ | 	function _getContent(_, elem){ | ||||||
| 		elem = $(elem) | 		elem = $(elem) | ||||||
| @ -1006,7 +1032,8 @@ function createMagazine(title, magazine_cover, article_cover){ | |||||||
| 		.append(createCoverPage(magazine_cover)) | 		.append(createCoverPage(magazine_cover)) | ||||||
| 		.append(createArticle(article_cover)) | 		.append(createArticle(article_cover)) | ||||||
| } | } | ||||||
| // XXX do we need a title here???
 | 
 | ||||||
|  | 
 | ||||||
| function createEmptyArticle(){ | function createEmptyArticle(){ | ||||||
| 	return $('<div/>') | 	return $('<div/>') | ||||||
| 		.addClass('article') | 		.addClass('article') | ||||||
| @ -1015,6 +1042,8 @@ function createArticle(template){ | |||||||
| 	return createEmptyArticle() | 	return createEmptyArticle() | ||||||
| 		.append(createCoverPage(template)) | 		.append(createCoverPage(template)) | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| function createPage(data){ | function createPage(data){ | ||||||
| 	var page = $('<div/>') | 	var page = $('<div/>') | ||||||
| 		.addClass('page') | 		.addClass('page') | ||||||
| @ -1037,13 +1066,13 @@ function createCoverPage(data){ | |||||||
| 
 | 
 | ||||||
| /************************************************ editor: magazine ***/ | /************************************************ editor: magazine ***/ | ||||||
| 
 | 
 | ||||||
| 
 | // load the data...
 | ||||||
| // NOTE: this will just load the data...
 |  | ||||||
| function loadMagazineData(mag){ | function loadMagazineData(mag){ | ||||||
| 	removeMagazine() | 	removeMagazine() | ||||||
| 	mag.appendTo($('.aligner')) | 	mag.appendTo($('.aligner')) | ||||||
| 	return mag | 	return mag | ||||||
| } | } | ||||||
|  | // load chrome elements like bookmarks and navigator....
 | ||||||
| function loadMagazineChrome(position, bookmarks){ | function loadMagazineChrome(position, bookmarks){ | ||||||
| 	setupBookmarkTouchZones() | 	setupBookmarkTouchZones() | ||||||
| 	setupNavigator() | 	setupNavigator() | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user