Skip to content

Commit

Permalink
#160. Added the shell for drupalgap.services.taxonomy_vocabulary.inde…
Browse files Browse the repository at this point in the history
…x, added the drupalgap.taxonomy_vocabularies variable which will eventually hold the service index result, and brought in a copy of drupalgap_jqm_page_event_script_code() that hasn't been merged in yet from another branch. Started on theme_taxonomy_term_reference() and _theme_taxonomy_term_reference_load_items().
  • Loading branch information
signalpoint committed Sep 4, 2013
1 parent 8a96a35 commit 6211115
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 0 deletions.
20 changes: 20 additions & 0 deletions drupalgap.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ var drupalgap = {
'router_path':'', /* The current menu router path. */
'services':{},
'sessid':null,
taxonomy_vocabularies:null, /* holds the services index of vocabularies */
'theme_path':'',
'themes':[],
'theme_registry':{},
Expand Down Expand Up @@ -723,6 +724,25 @@ function drupalgap_jqm_page_events() {
}
}

/**
* Given a JSON object with a page id, a jQM page event name, a callback
* function to handle the jQM page event and any page arguments, this function
* will return the inline JS code needed to handle the event.
*/
function drupalgap_jqm_page_event_script_code(options) {
try {
var script_code = '<script type="text/javascript">' +
'$("#' + options.page_id + '").on("' + options.jqm_page_event + '", drupalgap_jqm_page_event_fire("' +
options.jqm_page_event + '", "' +
options.jqm_page_event_callback + '", ' +
options.jqm_page_event_args +
'));' +
'</script>';
return script_code;
}
catch (error) { drupalgap_error(error); }
}

/**
* Show the jQueryMobile loading message.
*/
Expand Down
24 changes: 24 additions & 0 deletions modules/services/taxonomy_vocabulary.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,30 @@ drupalgap.services.taxonomy_vocabulary = {
}
},
}, // <!-- delete -->
'index':{
'options':{
'type':'get',
'path':'taxonomy_vocabulary.json',
'success':function(results){
dpm(results);
alert('index success');
},
},
'call':function(options){
try {
var api_options = drupalgap_chain_callbacks(drupalgap.services.taxonomy_vocabulary.index.options, options);
drupalgap.api.call(api_options);
}
catch (error) {
navigator.notification.alert(
error,
function(){},
'taxonomy_vocabulary Index Error',
'OK'
);
}
},
}, // <!-- index -->
'getTree':{
'options':{
'type':'post',
Expand Down
66 changes: 66 additions & 0 deletions modules/taxonomy/taxonomy.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,3 +404,69 @@ function taxonomy_vocabulary_load(vid) {
catch (error) { drupalgap_error(error); }
}

/**
*
*/
function taxonomy_vocabulary_machine_name_load(name) {
try {
var options = null;
if (arguments[1]) { options = arguments[1]; }

return entity_load('taxonomy_vocabulary', vid, options);
}
catch (error) { drupalgap_error(error); }
}

/**
*
*/
function theme_taxonomy_term_reference(variables) {
try {
dpm(variables);
var html = '';

// Make this a hidden field since the widget will just populate a value.
variables.attributes.type = 'hidden';
html += '<input ' + drupalgap_attributes(variables.attributes) + '/>';

// What vocabulary are we using?
var vocabulary = variables.field_info_field.settings.allowed_values[0].vocabulary;

// Prepare the variables for the widget and render it based on its type.
var widget_type = variables.field_info_instance.widget.type;
if (widget_type == 'options_select') { widget_type = 'select'; }
var widget_function = 'theme_' + widget_type;
var id = variables.attributes.id + '-' + widget_type;
if (drupalgap_function_exists(widget_function)) {
var fn = window[widget_function];
html += fn.call(null, {'id':id});
// Attach a pageshow handler to the current page (if it hasn't been
// already) that will load the terms into the widget.
//drupalgap.menu_links[drupalgap_router_path_get()]
var options = {
'page_id':drupalgap_get_page_id(drupalgap_path_get()),
'jqm_page_event':'pageshow',
'jqm_page_event_callback':'_theme_taxonomy_term_reference_load_items',
'jqm_page_event_args':null
};
html += drupalgap_jqm_page_event_script_code(options);
}
else {
console.log('WARNING: theme_taxonomy_term_reference() - unsupported widget type! (' + widget_type + ')');
}

console.log(html);
return html;
}
catch (error) { drupalgap_error(error); }
}

/**
*
*/
function _theme_taxonomy_term_reference_load_items() {
try {
alert('_theme_taxonomy_term_reference_load_items');
}
catch (error) { drupalgap_error(error); }
}

0 comments on commit 6211115

Please sign in to comment.