Skip to content

Commit

Permalink
adding missing list-plugin.js file (not yet used) and altered mapCb t…
Browse files Browse the repository at this point in the history
…o accept strings or functions as callback parameter
  • Loading branch information
pollen8 committed May 22, 2013
1 parent 635972f commit a616ad5
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 2 deletions.
2 changes: 1 addition & 1 deletion media/com_fabrik/js/fabrik-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion media/com_fabrik/js/fabrik.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,13 @@ var Loader = new Class({

Fabrik.cbQueue = {'google': []};

/**
* Load the google maps API once
*
* @param bool s Sensor
* @param mixed cb Callback method function or function name (assinged to window)
*
*/
Fabrik.loadGoogleMap = function (s, cb) {

var prefix = document.location.protocol === 'https:' ? 'https:' : 'http:';
Expand Down Expand Up @@ -314,8 +321,15 @@ var Loader = new Class({
*/
Fabrik.mapCb = function () {
Fabrik.googleMap = true;
var fn;
for (var i = 0; i < Fabrik.cbQueue.google.length; i ++) {
window[Fabrik.cbQueue.google[i]]();
fn = Fabrik.cbQueue.google[i];
if (typeOf(fn) === 'function') {
fn();
} else {
window[fn]();
}

}
Fabrik.cbQueue.google = [];
};
Expand Down
103 changes: 103 additions & 0 deletions media/com_fabrik/js/list-plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/**
* @author Robert
*/

/* jshint mootools: true */
/*
* global Fabrik:true, fconsole:true, Joomla:true, CloneObject:true,
* $H:true,unescape:true,head:true,FbListActions:true,FbGroupedToggler:true,FbListKeys:true
*/

var FbListPlugin = new Class({
Implements: [Events, Options],
options: {
requireChecked: true
},

initialize: function (options) {
this.setOptions(options);
this.result = true; // set this to false in window.fireEvents to stop
// current action (eg stop ordering when
// fabrik.list.order run)
this.listform = this.getList().getForm();
var l = this.listform.getElement('input[name=listid]');
// in case its in a viz
if (typeOf(l) === 'null') {
return;
}
this.listid = l.value;
this.watchButton();
},

/**
* get the list object that the plugin is assigned to
*/

getList: function () {
return Fabrik.blocks['list_' + this.options.ref];
},

/**
* get a html nodes row id - so you can pass in td or tr for example
* presumes each row has a fabrik_row class and its id is in a string 'list_listref_rowid'
*/

getRowId: function (node) {
if (!node.hasClass('fabrik_row')) {
node = node.getParent('.fabrik_row');
}
return node.id.split('_').getLast();
},

clearFilter: Function.from(),

watchButton: function () {
// Do relay for floating menus
if (typeOf(this.options.name) === 'null') {
return;
}
// Might need to be this.listform and not document
document.addEvent('click:relay(.' + this.options.name + ')', function (e, element) {
if (e.rightClick) {
return;
}
e.stop();

// Check that the button clicked belongs to this this.list
if (element.get('data-list') !== this.list.options.listRef) {
return;
}
e.preventDefault();
var row, chx;
// if the row button is clicked check its associated checkbox
if (e.target.getParent('.fabrik_row')) {
row = e.target.getParent('.fabrik_row');
if (row.getElement('input[name^=ids]')) {
chx = row.getElement('input[name^=ids]');
this.listform.getElements('input[name^=ids]').set('checked', false);
chx.set('checked', true);
}
}

// check that at least one checkbox is checked
var ok = false;
this.listform.getElements('input[name^=ids]').each(function (c) {
if (c.checked) {
ok = true;
}
});
if (!ok && this.options.requireChecked) {
alert(Joomla.JText._('COM_FABRIK_PLEASE_SELECT_A_ROW'));
return;
}
var n = this.options.name.split('-');
this.listform.getElement('input[name=fabrik_listplugin_name]').value = n[0];
this.listform.getElement('input[name=fabrik_listplugin_renderOrder]').value = n.getLast();
this.buttonAction();
}.bind(this));
},

buttonAction: function () {
this.list.submit('list.doPlugin');
}
});

0 comments on commit a616ad5

Please sign in to comment.