Skip to content

Commit

Permalink
Merge branch '7.x-1.x-alpha' into 7.x-1.x-alpha-issue-160
Browse files Browse the repository at this point in the history
  • Loading branch information
signalpoint committed Oct 25, 2013
2 parents 28b8e04 + 6274698 commit 6adebe8
Show file tree
Hide file tree
Showing 19 changed files with 1,350 additions and 990 deletions.
71 changes: 50 additions & 21 deletions UPGRADE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,14 @@ version of DrupalGap to another.
| Version Change Notes for Developers |
|=====================================|

7.x-1.5-alpha => 7.x-1.6-alpha

The 'header' system block has been renamed to 'title'. In your settings.js
file, you'll need to update your "Blocks" settings to use the 'title' block
instead of the 'header' block. FYI, this block is used to display the page
title.

---

The 'navigation' and 'management' system menus have been deprecated. If you
were using these menus at all in settings.js, the menus will still work as is,
they will now just be considered a 'custom' menu instead. If you were using
either of these menus programmatically, just create an empty custom menu
in settings.js using the 'navigation' or 'management' machine name, and that
will bring these menus back for you.

---
7.x-1.6-alpha => 7.x-1.7-alpha

Loading entities from the server has changed from synchronous to asynchronous.
This means that any time you load an entity, it will be loaded asynchronously
and you must provide a success callback to retrieve and use the entity. For
and you must provide a success callback to use the retrieved entity. For
example, before you could simply use:

var node = node_load(123);
if (node) {
alert('Loaded: ' + node.title);
}

Now that it is an asynchronous call, code like this would be used instead to
retrieve a node:
Expand All @@ -66,6 +47,54 @@ version of DrupalGap to another.

---

Now that entities are loaded asynchronously, the page title_callback system
needed to be changed to asynchronous as well. For example, before we could
create a title_callback for a custom page like this:

function my_module_menu() {
var items = {
my_page:{
title:'My Page',
page_callback:'my_page_callback',
title_callback:'my_page_title_callback',
title_arguments:['Good Monkey']
}
};
return items;
}

function my_page_title_callback(my_arg) {
return my_arg.replace('Good', 'Bad');
}

Now the title_callback for the above example would be implemented like this:

function my_page_title_callback(callback, my_arg) {
callback.call(null, my_arg.replace('Good', 'Bad'));
}

As you can see, title_callback implementations now take a 'callback' argument
that needs to be called with your custom title so the page title will be
properly set.

7.x-1.5-alpha => 7.x-1.6-alpha

The 'header' system block has been renamed to 'title'. In your settings.js
file, you'll need to update your "Blocks" settings to use the 'title' block
instead of the 'header' block. FYI, this block is used to display the page
title.

---

The 'navigation' and 'management' system menus have been deprecated. If you
were using these menus at all in settings.js, the menus will still work as is,
they will now just be considered a 'custom' menu instead. If you were using
either of these menus programmatically, just create an empty custom menu
in settings.js using the 'navigation' or 'management' machine name, and that
will bring these menus back for you.

---

See https://github.com/signalpoint/DrupalGap/issues/119 for information about
adjusting any custom forms you may have previously created in a module. Now,
the form and form_state will be passed to the form generation function. Your
Expand Down
89 changes: 67 additions & 22 deletions drupalgap.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ var drupalgap = {
'entity_info':{},
'field_info_fields':{},
'field_info_instances':{},
/*field_widget_info:{},*/
'form_errors':{},
'form_states':[],
loading:false, /* indicates if the loading message is shown or not */
Expand All @@ -85,7 +86,6 @@ var drupalgap = {
'router_path':'', /* The current menu router path. */
'services':{},
'sessid':null,
taxonomy_vocabularies:false, /* holds the services index of vocabularies */
'theme_path':'',
'themes':[],
'theme_registry':{},
Expand Down Expand Up @@ -198,6 +198,8 @@ function drupalgap_bootstrap() {
drupalgap_menus_load();
// Initialize the theme registry.
drupalgap_theme_registry_build();
// Initialize field widgets.
//drupalgap_field_widgets_load();
// Attach device back button handler (Android).
document.addEventListener("backbutton", drupalgap_back, false);
}
Expand Down Expand Up @@ -400,6 +402,31 @@ function drupalgap_empty(value) {
return (typeof value === "undefined" || value === null || value == '');
}

/**
*
*/
/*function drupalgap_field_widgets_load() {
try {
var modules = module_implements('field_widget_info');
if (!modules) { return null; }
$.each(modules, function(i, module){
var field_widgets = module_invoke(module, 'field_widget_info');
if (!field_widgets) { return; }
$.each(field_widgets, function(name, field_widget){
$.each(field_widget.field_types, function(j, field_type){
drupalgap.field_widget_info[field_type] = {
'module':module,
'field_widget':name
};
});
});
});
}
catch (error) {
alert('drupalgap_field_widgets_load - ' + error);
}
}*/

/**
* Checks if a given file exists, returns true or false.
* @param {string} path
Expand Down Expand Up @@ -1080,6 +1107,16 @@ function drupalgap_prepare_argument_entities(page_arguments, args) {
}
}

/**
* Given a page id, this will remove it from the DOM.
*/
function drupalgap_remove_page_from_dom(page_id) {
try {
$('#' + page_id).empty().remove();
}
catch (error) { drupalgap_error(error); }
}

/**
* Implementation of drupal_set_title().
*/
Expand Down Expand Up @@ -1231,16 +1268,7 @@ function drupalgap_onload() {

/*
* Given a drupal permission machine name, this function returns true if the
* current user has that permission, false otherwise. Here is example input
* that checks to see if the current user has the 'access content' permission.
* Example Usage:
* var has_access = user_access('access content');
* if (has_access) {
* alert("You have the 'access content' permission.");
* }
* else {
* alert("You do not have the 'access content' permission.");
* }
* current user has that permission, false otherwise.
*/
function user_access(permission) {
try {
Expand Down Expand Up @@ -1304,13 +1332,30 @@ function variable_get(name, default_value) {
}

/**
* Given an JSON object, this will output it to the console.
* Given an JSON object, this will output it to the console. It accepts an
* optional boolean as second argument, if it is false the output sent to the
* console will not use pretty printing in a Chrome/Ripple environment.
*/
function dpm(data) {
try {
var name = arguments.callee.caller.name;
if (name && name != '') { console.log(); }
if (data) { console.log(JSON.stringify(data)); }
if (data) {
// If we're in ripple we can output it directly to the console and it will
// have pretty printing, otherwise we'll stringify it first.
// TODO - be careful, when just using console.log() with ripple, it will
// always print out the final value of data (because of pass by reference)
// this can be very misleading for debugging things.
if (typeof parent.window.ripple === 'function') {
if (typeof arguments[1] !== 'undefined' && arguments[1] == false) {
console.log(JSON.stringify(data));
}
else {
console.log(data);
}
}
else {
console.log(JSON.stringify(data));
}
}
}
catch (error) {
alert('dpm - ' + error);
Expand All @@ -1322,13 +1367,13 @@ function dpm(data) {
* http://tylerfrankenstein.com/code/javascript-date-time-yyyy-mm-dd-hh-mm-ss
*/
function js_yyyy_mm_dd_hh_mm_ss () {
now = new Date();
year = "" + now.getFullYear();
month = "" + (now.getMonth() + 1); if (month.length == 1) { month = "0" + month; }
day = "" + now.getDate(); if (day.length == 1) { day = "0" + day; }
hour = "" + now.getHours(); if (hour.length == 1) { hour = "0" + hour; }
minute = "" + now.getMinutes(); if (minute.length == 1) { minute = "0" + minute; }
second = "" + now.getSeconds(); if (second.length == 1) { second = "0" + second; }
var now = new Date();
var year = "" + now.getFullYear();
var month = "" + (now.getMonth() + 1); if (month.length == 1) { month = "0" + month; }
var day = "" + now.getDate(); if (day.length == 1) { day = "0" + day; }
var hour = "" + now.getHours(); if (hour.length == 1) { hour = "0" + hour; }
var minute = "" + now.getMinutes(); if (minute.length == 1) { minute = "0" + minute; }
var second = "" + now.getSeconds(); if (second.length == 1) { second = "0" + second; }
return year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second;
}

Expand Down
Loading

0 comments on commit 6adebe8

Please sign in to comment.