forked from Fabrik/fabrik
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding missing list-plugin.js file (not yet used) and altered mapCb t…
…o accept strings or functions as callback parameter
- Loading branch information
Showing
3 changed files
with
119 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
}); |