PHP Classes

File: public/assets/local/js/require.min.js

Recommend this page to a friend!
  Classes of Aby Dahana  >  Aksara  >  public/assets/local/js/require.min.js  >  Download  
File: public/assets/local/js/require.min.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Aksara
A CodeIgniter based API and CRUD generator
Author: By
Last change: Initial commit for update 4.2.8

1. Refine addons views;
2. Refine grid view;
3. Refine require.js;
4. Add the capability to reload the page after CRUD action from outside the data table
Initial commit for update 4.2.8

This commit replace the dependent configuration with newest CodeIgniter configuration (path /aksara/Config);

Changes for database migrations: Adds seeder to seeds the dummy data instead of writing it under migration.

Core and Model: Updating the missing placement for case insensitive query parameter;

String helper: remove unused parameter;

Touching the core javascript: /public/assets/local/require.min.js (add the missing array usage for css);

Minor updates for the core module
Date: 7 days ago
Size: 1,883 bytes
 

Contents

Class file image Download
/**
 * require
 *
 * A script library to import the javascript / css file
 *
 * @author		Aby Dahana
 * @profile		abydahana.github.io
 *
 * Property of Aksara Laboratory
 * www.aksaracms.com
 */

"use strict";

var loaded_script									= [],
	loaded_style									= [];

var require											= (function()
{
	return {
		js: function(scripts, callback)
		{
			if(!$.isArray(scripts))
			{
				scripts								= [scripts];
			}
			
			var length								= scripts.length,
				deferred							= new $.Deferred(),
				pipe								= deferred;
			
			$.each(scripts, function(i, script)
			{
				if($.inArray(script, loaded_script) === -1)
				{
					/* push previous rendered file to history */
					loaded_script.push(script);
					
					pipe							= pipe.pipe(function()
					{
						if((i + 1) === length)
						{
							/* is final import, run callback (if any) after finish */
							$.getScript(script, function()
							{
								if(callback)
								{
									return callback();
								}
							})
						}
						else
						{
							/* continue looping to import script */
							return $.getScript(script)
						}
					});
				}
				else
				{
					/* all required file is already loaded, return the callback instead */
					if(callback)
					{
						return callback()
					}
				}
			}),
			
			/* resolve deferred */
			deferred.resolve()
		},
		
		css: function(styles, callback)
		{
			if(!$.isArray(styles))
			{
				styles								= [styles];
			}
			
			$.each(styles, function(i, style)
			{
				if($.inArray(style, loaded_style) === -1)
				{
					/* push previous rendered file to history */
					loaded_style.push(style),
					
					/* append stylesheet to head */
					$('<link rel="stylesheet" type="text/css" href="' + style + '" />').appendTo('head')
				}
			});
			
			if(callback)
			{
				/* return the callback if any */
				return callback();
			}
		}
	}
})();
For more information send a message to info at phpclasses dot org.