PageRenderTime 1298ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/administrator/components/com_breezingforms/admin/easymode-js.php

https://bitbucket.org/izubizarreta/https-bitbucket.org-bityvip-alpes
PHP | 3662 lines | 3095 code | 507 blank | 60 comment | 666 complexity | a9d5ee4a14e508d3483117b31da48a2f MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause, LGPL-2.1, MIT, LGPL-3.0, LGPL-2.0, JSON
  1. <?php
  2. /**
  3. * BreezingForms - A Joomla Forms Application
  4. * @version 1.8
  5. * @package BreezingForms
  6. * @copyright (C) 2008-2012 by Markus Bopp
  7. * @license Released under the terms of the GNU General Public License
  8. **/
  9. defined('_JEXEC') or die('Direct Access to this location is not allowed.');
  10. JHTML::_('behavior.modal');
  11. ?>
  12. <script>var moobackup = $;</script>
  13. <script>var moobackup2 = $$;</script>
  14. <script
  15. type="text/javascript"
  16. src="<?php echo JURI::root() . 'administrator/components/com_breezingforms/libraries/jquery/' ;?>jq.js"></script>
  17. <script
  18. type="text/javascript"
  19. src="<?php echo JURI::root() . 'administrator/components/com_breezingforms/libraries/jquery/' ;?>jq-ui.min.js"></script>
  20. <script
  21. type="text/javascript"
  22. src="<?php echo JURI::root() . 'administrator/components/com_breezingforms/libraries/jquery/plugins/' ;?>base64.js"></script>
  23. <script
  24. type="text/javascript"
  25. src="<?php echo JURI::root() . 'administrator/components/com_breezingforms/libraries/jquery/plugins/' ;?>json.js"></script>
  26. <script
  27. type="text/javascript"
  28. src="<?php echo JURI::root() . 'administrator/components/com_breezingforms/libraries/jquery/plugins/' ;?>md5.js"></script>
  29. <script>$ = moobackup;</script>
  30. <script>$$ = moobackup2;</script>
  31. <script type="text/javascript">
  32. var app = null;
  33. String.prototype.bfendsWith = function(suffix) {
  34. return this.match(suffix+"$") == suffix;
  35. };
  36. function BF_EasyModeApp()
  37. {
  38. JQuery("link").each(function(){
  39. // jquery easy workaround
  40. var _xj = 'j';
  41. var _xq = 'q';
  42. var _xu = 'u';
  43. var _xe = 'e';
  44. var _xr = 'r';
  45. var _xy = 'y';
  46. if( JQuery(this).attr('href').bfendsWith(_xj+_xq+_xu+_xe+_xr+_xy+'-ui.css') ){
  47. JQuery(this).attr('disabled', 'disabled');
  48. JQuery(this).remove();
  49. }
  50. });
  51. // to app scope
  52. var appScope = this;
  53. // the opacity for each draggable element
  54. this.opacity = 0.5;
  55. // the areaList contains all elements into all available areas. Structure: [ { area : droppableArea_instance, elements : [ Object_instance , ... ] } , ... ]
  56. this.areaList = [];
  57. // temp area list for the trashcan
  58. this.trashcanAreaList = [];
  59. // the actually selected element to change its options for
  60. this.optionElement = null;
  61. // all available element scripts
  62. this.elementScripts = <?php echo Zend_Json::encode($elementScripts)?>
  63. this.captchaAdded = 0;
  64. this.pixelRaster = 1;
  65. this.setElementResizable = function(element){
  66. JQuery('#'+element.id).resizable({
  67. grid: [appScope.pixelRaster,appScope.pixelRaster],
  68. //knobHandles : true,
  69. handles: "se",
  70. //minWidth: 5,
  71. //minHeight: 5,
  72. //ghost: true,
  73. //transparent: true
  74. start: function(){
  75. if(JQuery('#'+element.id).parent().attr('class') == 'ui-wrapper'){
  76. JQuery('#'+element.id).parent().css('padding-bottom', '0px');
  77. if(JQuery('#'+element.id).parent().children('.ui-resizable-se')[0]){
  78. JQuery(JQuery('#'+element.id).parent().children('.ui-resizable-se')[0]).click(appScope.resizableElement);
  79. }
  80. }
  81. JQuery(this).css('border', '1px dotted #000');
  82. },
  83. stop: function(){
  84. //alert(JQuery(this).attr('class'));
  85. JQuery(this).css('border', 'none');
  86. }
  87. });
  88. if(JQuery('#'+element.id).parent().attr('class') == 'ui-wrapper'){
  89. JQuery('#'+element.id).parent().css('padding-bottom', '0px');
  90. if(JQuery('#'+element.id).parent().children('.ui-resizable-se')[0]){
  91. JQuery(JQuery('#'+element.id).parent().children('.ui-resizable-se')[0]).click(appScope.resizableElement);
  92. }
  93. }
  94. };
  95. this.refreshTemplateBox = function(){
  96. JQuery('#bfTemplateBox').val( JQuery.trim(JQuery('#bfTemplate').get(0).innerHTML) );
  97. };
  98. // first turn all pages on sucht that they can be initially processed by jquery
  99. JQuery('.bfPage').css('display','');
  100. <?php if(isset($callbackParams['areas']) && trim($callbackParams['areas']) != ''){ ?>
  101. var tmpAreas = <?php echo $callbackParams['areas'] ?>;
  102. for(var i = 0; i < tmpAreas.length;i++){
  103. if(JQuery("#"+tmpAreas[i].id).get(0)){
  104. if(!tmpAreas[i].pixelRaster){ // compat 686
  105. tmpAreas[i]['pixelRaster'] = 1;
  106. }
  107. if(i == 0){
  108. appScope.pixelRaster = tmpAreas[i].pixelRaster;
  109. JQuery('#bfPixelRaster').val(appScope.pixelRaster);
  110. }
  111. this.areaList.push( { area: JQuery("#"+tmpAreas[i].id).get(0), elements : tmpAreas[i].elements, pixelRaster: tmpAreas[i].pixelRaster } );
  112. }
  113. }
  114. for(var i = 0; i < appScope.areaList.length; i++){
  115. for(var j = 0; j < appScope.areaList[i].elements.length;j++){
  116. var element = appScope.areaList[i].elements[j];
  117. JQuery('#'+element.id).get(0).removeAttribute('onclick');
  118. JQuery('#'+element.id).get(0).removeAttribute('onblur');
  119. JQuery('#'+element.id).get(0).removeAttribute('onchange');
  120. JQuery('#'+element.id).get(0).removeAttribute('onfocus');
  121. JQuery('#'+element.id).get(0).removeAttribute('onselect');
  122. JQuery('#'+element.id).get(0).removeAttribute('onmouseover');
  123. JQuery('#'+element.id).get(0).removeAttribute('onmouseout');
  124. JQuery('#'+element.id).get(0).removeAttribute('tabindex');
  125. JQuery('#'+element.id).get(0).removeAttribute('checked');
  126. if(typeof element.tabIndex == 'undefined'){ // compat 687
  127. element.tabIndex = -1;
  128. }
  129. JQuery('#'+element.id).css('border','none');
  130. if(element.internalType == 'bfCaptcha'){
  131. appScope.captchaAdded++;
  132. }
  133. var prevm = JQuery('#'+element.id).css('margin');
  134. var prevp = JQuery('#'+element.id).css('padding');
  135. var prevElementWidth = JQuery('#'+element.id).css('width');
  136. var prevElementHeight = JQuery('#'+element.id).css('height');
  137. if(element.internalType != 'bfHidden'){
  138. appScope.setElementResizable(element);
  139. }
  140. JQuery('#'+element.id).css('margin', prevm);
  141. JQuery('#'+element.id).css('padding', prevp);
  142. JQuery('#'+element.id).css('width', prevElementWidth);
  143. JQuery('#'+element.id).css('height', prevElementHeight);
  144. if(element.internalType == 'bfIcon'){
  145. JQuery( JQuery('#'+element.id).children('img')[0] ).get(0).removeAttribute('onmouseover');
  146. JQuery( JQuery('#'+element.id).children('img')[0] ).get(0).removeAttribute('onmouseout');
  147. }
  148. var labelsResult = JQuery('#'+element.id).parent().parent().children('.ff_label');
  149. if(labelsResult.length != 0){
  150. for(var k = 0; k < labelsResult.length;k++){
  151. prevm = JQuery('#'+labelsResult[k].id).css('margin');
  152. prevp = JQuery('#'+labelsResult[k].id).css('padding');
  153. prevElementWidth = JQuery('#'+labelsResult[k].id).css('width');
  154. prevElementHeight = JQuery('#'+labelsResult[k].id).css('height');
  155. appScope.setElementResizable(labelsResult[k]);
  156. JQuery('#'+labelsResult[k].id).css('margin', prevm);
  157. JQuery('#'+labelsResult[k].id).css('padding', prevp);
  158. JQuery('#'+labelsResult[k].id).css('width', prevElementWidth);
  159. JQuery('#'+labelsResult[k].id).css('height', prevElementHeight);
  160. var batchLabel = document.createElement('option');
  161. JQuery(batchLabel).val(labelsResult[k].id);
  162. JQuery(batchLabel).text(stripHTML( JQuery('#'+labelsResult[k].id).html() ) );
  163. JQuery('#bfBatchLabels').append(batchLabel);
  164. }
  165. }
  166. labelsResult = JQuery('#'+element.id).parent().children('.ff_label');
  167. if(labelsResult.length != 0){
  168. for(var k = 0; k < labelsResult.length;k++){
  169. prevm = JQuery('#'+labelsResult[k].id).css('margin');
  170. prevp = JQuery('#'+labelsResult[k].id).css('padding');
  171. prevElementWidth = JQuery('#'+labelsResult[k].id).css('width');
  172. prevElementHeight = JQuery('#'+labelsResult[k].id).css('height');
  173. appScope.setElementResizable(labelsResult[k]);
  174. JQuery('#'+labelsResult[k].id).css('margin', prevm);
  175. JQuery('#'+labelsResult[k].id).css('padding', prevp);
  176. JQuery('#'+labelsResult[k].id).css('width', prevElementWidth);
  177. JQuery('#'+labelsResult[k].id).css('height', prevElementHeight);
  178. var batchLabel = document.createElement('option');
  179. JQuery(batchLabel).val(labelsResult[k].id);
  180. JQuery(batchLabel).text(stripHTML( JQuery('#'+labelsResult[k].id).html() ) );
  181. JQuery('#bfBatchLabels').append(batchLabel);
  182. }
  183. }
  184. if(element.internalType != 'bfHidden'){
  185. var batchElement = document.createElement('option');
  186. JQuery(batchElement).val(element.id);
  187. JQuery(batchElement).text(element.name);
  188. JQuery('#bfBatchElements').append(batchElement);
  189. }
  190. }
  191. }
  192. <?php } ?>
  193. appScope.refreshTemplateBox();
  194. if(parseInt(document.adminForm.page.value) < 1){
  195. document.adminForm.page.value = 1;
  196. }
  197. JQuery('#bfCurrentPage').get(0).innerHTML = document.adminForm.page.value + "/" + (parseInt(document.adminForm.pages.value) == 0 ? 1 : document.adminForm.pages.value);
  198. JQuery('.bfPage').css('display','none');
  199. JQuery('#bfPage'+document.adminForm.page.value).css('display','');
  200. for(var i = 1; i <= parseInt(document.adminForm.pages.value);i++){
  201. var option = document.createElement('option');
  202. JQuery(option).val(i);
  203. JQuery(option).text(i);
  204. var option2 = document.createElement('option');
  205. JQuery(option2).val(i);
  206. JQuery(option2).text(i);
  207. JQuery('#bfGoToPage').append(option);
  208. JQuery('#bfMoveThisPageTo').append(option2);
  209. }
  210. this.populateHiddenFieldsOptions = function(){
  211. JQuery('#bfHiddenFieldsOptions').empty();
  212. var element = null;
  213. var br = null;
  214. var hiddenFields = appScope.getElementsByType('bfHidden');
  215. for(var i=0;i < hiddenFields.length;i++){
  216. // element name header
  217. element = document.createElement('span');
  218. element.innerHTML = '<?php echo BFText::_('COM_BREEZINGFORMS_NAME') ?>:';
  219. JQuery('#bfHiddenFieldsOptions').append(element);
  220. br = document.createElement('br');
  221. JQuery('#bfHiddenFieldsOptions').append(br);
  222. // element name
  223. element = document.createElement('input');
  224. element.setAttribute('type', 'text');
  225. element.setAttribute('id', 'name__HIDDEN__' + hiddenFields[i].id);
  226. element.setAttribute('class', 'bfHiddenOptionsName');
  227. element.setAttribute('value', hiddenFields[i].name);
  228. element.style.width = '100%';
  229. br = document.createElement('br');
  230. JQuery('#bfHiddenFieldsOptions').append(element);
  231. JQuery('#bfHiddenFieldsOptions').append(br);
  232. // element title header
  233. element = document.createElement('span');
  234. element.innerHTML = 'Title:';
  235. JQuery('#bfHiddenFieldsOptions').append(element);
  236. br = document.createElement('br');
  237. JQuery('#bfHiddenFieldsOptions').append(br);
  238. // element title
  239. element = document.createElement('input');
  240. element.setAttribute('type', 'text');
  241. element.setAttribute('id', 'title__HIDDEN__' + hiddenFields[i].id);
  242. element.setAttribute('class', 'bfHiddenOptionsTitle');
  243. element.setAttribute('value', hiddenFields[i].title);
  244. element.style.width = '100%';
  245. br = document.createElement('br');
  246. JQuery('#bfHiddenFieldsOptions').append(element);
  247. JQuery('#bfHiddenFieldsOptions').append(br);
  248. // element value header
  249. element = document.createElement('span');
  250. element.innerHTML = 'Value:';
  251. JQuery('#bfHiddenFieldsOptions').append(element);
  252. br = document.createElement('br');
  253. JQuery('#bfHiddenFieldsOptions').append(br);
  254. // element value
  255. element = document.createElement('input');
  256. element.setAttribute('type', 'text');
  257. element.setAttribute('id', 'value__HIDDEN__' + hiddenFields[i].id);
  258. element.setAttribute('class', 'bfHiddenOptionsValue');
  259. element.setAttribute('value', hiddenFields[i].options.value);
  260. element.style.width = '100%';
  261. br = document.createElement('br');
  262. JQuery('#bfHiddenFieldsOptions').append(element);
  263. JQuery('#bfHiddenFieldsOptions').append(br);
  264. element = document.createElement('span');
  265. element.innerHTML = 'Remove? ';
  266. JQuery('#bfHiddenFieldsOptions').append(element);
  267. element = document.createElement('input');
  268. element.setAttribute('type', 'checkbox');
  269. element.setAttribute('id', 'remove__HIDDEN__' + hiddenFields[i].id);
  270. element.setAttribute('class', 'bfHiddenOptionsDelete');
  271. //element.style.width = '100%';
  272. JQuery('#bfHiddenFieldsOptions').append(element);
  273. br = document.createElement('hr');
  274. JQuery('#bfHiddenFieldsOptions').append(br);
  275. }
  276. if(hiddenFields.length != 0){
  277. // update button
  278. br = document.createElement('br');
  279. JQuery('#bfHiddenFieldsOptions').append(br);
  280. element = document.createElement('input');
  281. element.setAttribute('type', 'submit');
  282. element.setAttribute('value', 'update');
  283. element.style.width = '100%';
  284. JQuery(element).click(
  285. function(){
  286. var children = JQuery('#bfHiddenFieldsOptions').children('.bfHiddenOptionsValue');
  287. for( var i = 0; i < children.length; i++ ){
  288. var id = children[i].id.split('__HIDDEN__');
  289. if(id.length == 2){
  290. var element = appScope.getElementById(id[1]);
  291. element.options.value = JQuery('#value__HIDDEN__'+id[1]).val();
  292. JQuery('#'+element.id).get(0).setAttribute('value', element.options.value);
  293. }
  294. }
  295. var children = JQuery('#bfHiddenFieldsOptions').children('.bfHiddenOptionsTitle');
  296. for( var i = 0; i < children.length; i++ ){
  297. var id = children[i].id.split('__HIDDEN__');
  298. if(id.length == 2){
  299. var element = appScope.getElementById(id[1]);
  300. element.title = JQuery('#title__HIDDEN__'+id[1]).val();
  301. }
  302. }
  303. children = JQuery('#bfHiddenFieldsOptions').children('.bfHiddenOptionsName');
  304. for( var i = 0; i < children.length; i++ ){
  305. var id = children[i].id.split('__HIDDEN__');
  306. if(id.length == 2){
  307. var element = appScope.getElementById(id[1]);
  308. element.name = JQuery('#name__HIDDEN__'+id[1]).val();
  309. }
  310. }
  311. var children = JQuery('#bfHiddenFieldsOptions').children('.bfHiddenOptionsDelete');
  312. for( var i = 0; i < children.length; i++ ){
  313. if(children[i].checked){
  314. var id = children[i].id.split('__HIDDEN__');
  315. if(id.length == 2){
  316. var element = appScope.getElementById(id[1]);
  317. JQuery('#'+id[1]).remove();
  318. appScope.removeElementFromAreaList(element);
  319. }
  320. }
  321. }
  322. appScope.populateHiddenFieldsOptions();
  323. JQuery('#bfHiddenFieldsOptions').get(0).innerHTML = '<?php echo BFText::_('COM_BREEZINGFORMS_OPTIONS_SAVED_TO_FINALLY_SAVE_YOUR_FORM_CLICK_SAVE_ON_THE_TOP_RIGHT_BUTTON') ?><br/><br/>' + JQuery('#bfHiddenFieldsOptions').get(0).innerHTML;
  324. }
  325. );
  326. JQuery('#bfHiddenFieldsOptions').append(element);
  327. }
  328. }
  329. /**
  330. * Return the elements of a droppableArea
  331. */
  332. this.getElementsArray = function (area){
  333. for(var i = 0; i < appScope.areaList.length; i++){
  334. if(appScope.areaList[i].area && appScope.areaList[i].area == area){
  335. return appScope.areaList[i].elements;
  336. }
  337. }
  338. return null;
  339. };
  340. /**
  341. * Checks if the droppableArea exists
  342. */
  343. this.hasArea = function (area){
  344. for(var i = 0; i < appScope.areaList.length; i++){
  345. if(appScope.areaList[i].area && appScope.areaList[i].area == area){
  346. return true;
  347. }
  348. }
  349. return false;
  350. };
  351. this.getElementById = function(id) {
  352. for(var i = 0; i < appScope.areaList.length; i++){
  353. for(var j = 0; j < appScope.areaList[i].elements.length; j++){
  354. if(id == appScope.areaList[i].elements[j].id){
  355. return appScope.areaList[i].elements[j];
  356. }
  357. }
  358. }
  359. return null;
  360. };
  361. this.getElementsByType = function(type) {
  362. var foundElements = new Array();
  363. for(var i = 0; i < appScope.areaList.length; i++){
  364. for(var j = 0; j < appScope.areaList[i].elements.length; j++){
  365. if(type == appScope.areaList[i].elements[j].internalType){
  366. foundElements.push(appScope.areaList[i].elements[j]);
  367. }
  368. }
  369. }
  370. return foundElements;
  371. };
  372. this.removeElementFromAreaList = function(element){
  373. for(var i = 0; i < appScope.areaList.length; i++){
  374. var newElements = new Array();
  375. for(var j = 0; j < appScope.areaList[i].elements.length; j++){
  376. if(element.id != appScope.areaList[i].elements[j].id){
  377. newElements.push(appScope.areaList[i].elements[j]);
  378. }
  379. }
  380. appScope.areaList[i].elements = newElements;
  381. }
  382. };
  383. this.removeElementFromTrashcanAreaList = function(element){
  384. var newElements = new Array();
  385. for(var i = 0; i < appScope.trashcanAreaList.length; i++){
  386. if(element.id != appScope.trashcanAreaList[i].id){
  387. newElements.push(appScope.trashcanAreaList[i]);
  388. }
  389. }
  390. appScope.trashcanAreaList = newElements;
  391. };
  392. /**
  393. * prepares the data for the form before the submit
  394. */
  395. this.prepareForSave = function(){
  396. if(appScope.captchaAdded > 1){
  397. alert('<?php echo BFText::_('COM_BREEZINGFORMS_ADDED_MORE_THAN_ONE_CAPTCHA') ?>');
  398. return;
  399. }
  400. JQuery('.calCode').remove();
  401. JQuery('ui-resizable-handle').remove();
  402. var areas = new Array();
  403. for(var i = 0; i < appScope.areaList.length; i++){
  404. areas.push( { id : appScope.areaList[i].area.id, elements: appScope.areaList[i].elements, pixelRaster: appScope.pixelRaster } );
  405. for(var j = 0; j < appScope.areaList[i].elements.length;j++){
  406. var element = appScope.areaList[i].elements[j];
  407. if( (element.internalType == 'bfTextfield' || element.internalType == 'bfSelect') && element.options && !element.options.mailback){ // compat 690
  408. element.options['mailback'] = false;
  409. }
  410. if(element.internalType == 'bfFile' && element.options && !element.options.allowedFileExtensions){ // compat 690
  411. element.options['allowedFileExtensions'] = '';
  412. element.data2 = '';
  413. } else {
  414. if(element.internalType == 'bfFile' && element.options){
  415. element.data2 = element.options.allowedFileExtensions.toLowerCase();
  416. }
  417. }
  418. if(element.internalType == 'bfFile' && element.options && !element.options.attachToAdminMail){ // compat 691
  419. element.options['attachToAdminMail'] = false;
  420. }
  421. if(element.internalType == 'bfFile' && element.options && !element.options.attachToUserMail){ // compat 691
  422. element.options['attachToUserMail'] = false;
  423. }
  424. if(!element.mailbackfile){
  425. element['mailbackfile'] = '';
  426. }
  427. if(!element.orderNumber){
  428. element['orderNumber'] = -1;
  429. }
  430. if(!element.tabIndex){ // compat 687
  431. element['tabIndex'] = -1;
  432. }
  433. if(!element.mailbackAccept){ // compat 686
  434. element['mailbackAccept'] = false;
  435. }
  436. if(!element.mailbackAcceptConnectWith){ // compat 686
  437. element['mailbackAcceptConnectWith'] = '';
  438. }
  439. if(!element.mailbackAsSender){ // compat 687
  440. element['mailbackAsSender'] = false;
  441. }
  442. if(element.internalType == 'bfFile' && element.options.attachToAdminMail){
  443. var attachToAdminMail = document.createElement('input');
  444. attachToAdminMail.setAttribute('type', 'hidden');
  445. attachToAdminMail.setAttribute('id', 'attachToAdminMail_'+element.name);
  446. attachToAdminMail.setAttribute('name', 'attachToAdminMail['+element.name+']');
  447. attachToAdminMail.setAttribute('class', 'attachToAdminMail');
  448. attachToAdminMail.setAttribute('value', 'true');
  449. JQuery('#bfTemplate').append(attachToAdminMail);
  450. }
  451. if(element.internalType == 'bfFile' && element.options.attachToUserMail){
  452. var attachToUserMail = document.createElement('input');
  453. attachToUserMail.setAttribute('type', 'hidden');
  454. attachToUserMail.setAttribute('id', 'attachToUserMail_'+element.name);
  455. attachToUserMail.setAttribute('name', 'attachToUserMail['+element.name+']');
  456. attachToUserMail.setAttribute('class', 'attachToUserMail');
  457. attachToUserMail.setAttribute('value', 'true');
  458. JQuery('#bfTemplate').append(attachToUserMail);
  459. }
  460. if(element.internalType == 'bfTextfield' && element.mailbackAsSender){
  461. var mailbackSender = document.createElement('input');
  462. mailbackSender.setAttribute('type', 'hidden');
  463. mailbackSender.setAttribute('id', 'mailbackSender_'+element.name);
  464. mailbackSender.setAttribute('name', 'mailbackSender['+element.name+']');
  465. mailbackSender.setAttribute('class', 'mailbackSender');
  466. mailbackSender.setAttribute('value', 'true');
  467. JQuery('#bfTemplate').append(mailbackSender);
  468. }
  469. if(element.internalType == 'bfCheckbox'){
  470. if(element.options.checked){
  471. JQuery('#'+element.id).get(0).setAttribute('checked','checked');
  472. }
  473. if(element.mailbackAccept){
  474. var connectWith = document.createElement('input');
  475. connectWith.setAttribute('type', 'hidden');
  476. connectWith.setAttribute('id', 'mailbackConnectWith_'+element.mailbackAcceptConnectWith);
  477. connectWith.setAttribute('name', 'mailbackConnectWith['+element.mailbackAcceptConnectWith+']');
  478. connectWith.setAttribute('class', 'mailbackConnectWith');
  479. connectWith.setAttribute('value', 'true_'+element.name);
  480. JQuery('#bfTemplate').append(connectWith);
  481. }
  482. }
  483. if(element.internalType == 'bfRadio'){
  484. if(element.options.checked){
  485. JQuery('#'+element.id).get(0).setAttribute('checked','checked');
  486. }
  487. }
  488. if(element.internalType == 'bfCalendar' || element.internalType == 'bfCaptcha' || element.internalType == 'bfHidden' || element.internalType == 'bfStaticText' || element.internalType == 'bfIcon'){
  489. // leave out, only necessary for input elements
  490. } else {
  491. // move input elements out of their ui-wrappers
  492. JQuery('#'+element.id).parent().before(JQuery(JQuery('#'+element.id).parent().prev()).get(0)); // moving the label
  493. JQuery('#'+element.id).parent().before(JQuery('#'+element.id).get(0)); // moving the element itself
  494. }
  495. if(element.script2flag1 == 1){
  496. var payment = "";
  497. if(element.internalType == 'bfPayPal'){
  498. payment = "document.getElementById('bfPaymentMethod').value='PayPal';";
  499. }
  500. else if(element.internalType == 'bfSofortueberweisung'){
  501. payment = "document.getElementById('bfPaymentMethod').value='Sofortueberweisung';";
  502. }
  503. JQuery('#'+element.id).get(0).setAttribute('onclick', payment + element.functionNameScript2 + '(this,\'click\');');
  504. }
  505. if(element.script2flag2 == 1){
  506. JQuery('#'+element.id).get(0).setAttribute('onblur', element.functionNameScript2 + '(this,\'onblur\')');
  507. }
  508. if(element.script2flag3 == 1){
  509. JQuery('#'+element.id).get(0).setAttribute('onchange', element.functionNameScript2 + '(this,\'onchange\')');
  510. }
  511. if(element.script2flag4 == 1){
  512. JQuery('#'+element.id).get(0).setAttribute('onfocus', element.functionNameScript2 + '(this,\'onfocus\')');
  513. }
  514. if(element.script2flag5 == 1){
  515. JQuery('#'+element.id).get(0).setAttribute('onselect', element.functionNameScript2 + '(this,\'onselect\')');
  516. }
  517. if(element.internalType == 'bfTooltip'){
  518. JQuery('#'+element.id).get(0).setAttribute('onmouseover', "return overlib('"+expstring(element.options.text)+"',CAPTION,'"+element.name+"',BELOW,RIGHT)");
  519. JQuery('#'+element.id).get(0).setAttribute('onmouseout', "return nd()");
  520. } else
  521. if(element.internalType == 'bfIcon'){
  522. JQuery(JQuery('#'+element.id).children('img')[0]).get(0).setAttribute('onmouseover', "this.src='"+element.data3+"'");
  523. JQuery(JQuery('#'+element.id).children('img')[0]).get(0).setAttribute('onmouseout', "this.src='"+element.data1+"'");
  524. JQuery('#'+element.id).get(0).setAttribute('onmouseover',"this.style.cursor = 'pointer'");
  525. JQuery('#'+element.id).get(0).setAttribute('onmouseout',"this.style.cursor = ''");
  526. } else
  527. if(element.internalType == 'bfCalendar'){
  528. var calCode ='<script class="calCode" type="text/javascript">if(typeof Calendar != "undefined"){Calendar.setup({inputField : ff_getElementByName("'+element.options.connectWith+'").id, ifFormat : "'+element.options.format+'", button : "'+element.id+'", align : "Bl", singleClick : true });}<\/script>';
  529. JQuery('.droppableArea').get(0).innerHTML += calCode;
  530. }
  531. if(JQuery('#'+element.id).parents('.bfPage')[0]){
  532. var elPage = JQuery('#'+element.id).parents('.bfPage')[0].id.split('bfPage');
  533. element.page = parseInt(elPage[1]);
  534. } else {
  535. element.page = 1;
  536. }
  537. if(element.internalType != 'bfHidden' && parseInt(element.tabIndex) != -1){
  538. JQuery('#'+element.id).get(0).setAttribute('tabindex', element.tabIndex);
  539. }
  540. }
  541. }
  542. JQuery('.ff_div').css('border','');
  543. JQuery('.ff_elem').css('border','');
  544. JQuery('.ff_label').css('border','');
  545. JQuery('.ff_div').css('border-left','');
  546. JQuery('.ff_elem').css('border-left','');
  547. JQuery('.ff_label').css('border-left','');
  548. JQuery('.ff_div').children('.ui-wrapper').remove();
  549. JQuery('.ff_div').children('.ui-resizable-handle').remove();
  550. JQuery('.ff_div').children('.ff_label').children('.ui-resizable-handle').remove();
  551. JQuery('.ff_div').children('.ff_elem').children('.ui-resizable-handle').remove();
  552. JQuery('.ff_label').removeClass('ui-resizable');
  553. JQuery('.ff_label').removeClass('ui-resizable-disabled');
  554. JQuery('.ff_label').removeClass('ui-state-disabled');
  555. JQuery('.ff_elem').removeClass('ui-resizable');
  556. JQuery('.ff_elem').removeClass('ui-resizable-disabled');
  557. JQuery('.ff_elem').removeClass('ui-state-disabled');
  558. JQuery('.droppableArea').removeClass('ui-sortable');
  559. JQuery('.droppableArea').removeClass('ui-droppable');
  560. JQuery('#bfTemplate').children('.ui-wrapper').remove();
  561. JQuery('.bfPage').css('display','none');
  562. JQuery('#bfPage1').css('display','');
  563. var rep = JQuery('#bfTemplate').get(0).innerHTML.replace(/border-width: initial; /g,"");
  564. rep = rep.replace(/border-color: initial; /g,"");
  565. var result =
  566. {
  567. templateCode : JQuery.base64Encode(rep),
  568. areas : JQuery.base64Encode(JQuery.toJSON(areas))
  569. };
  570. return result;
  571. };
  572. this.createElementBeside = function(element, type){
  573. var elements = appScope.getElementsArray(JQuery('#'+element.area).get(0));
  574. if(elements != null && type != ''){
  575. var ffListItem = null;
  576. if(JQuery('#' + element.id).parent().parent().parent().hasClass('ff_listItem')){
  577. ffListItem = JQuery('#' + element.id).parent().parent().parent();
  578. } else if(JQuery('#' + element.id).parent().parent().hasClass('ff_listItem')){
  579. ffListItem = JQuery('#' + element.id).parent().parent();
  580. } else {
  581. return;
  582. }
  583. JQuery(ffListItem).children('.ff_appender').remove();
  584. var info = appScope.getElementById(element.id);
  585. var rndId = JQuery.md5(Math.random() + info.appElementOrderId + info.appElementId + info.area);
  586. var besideElement = null;
  587. var wrapper = document.createElement('div');
  588. wrapper.setAttribute('id', 'ff_div' + rndId);
  589. wrapper.setAttribute('class', 'ff_div');
  590. if(type != 'bfStaticText'){
  591. var label = document.createElement('div');
  592. label.setAttribute('id', 'ff_elemLabel' + rndId);
  593. label.setAttribute('class', 'ff_label');
  594. label.style.verticalAlign = 'top';
  595. label.style.width = '50px';
  596. label.style.height = '10px';
  597. JQuery(label).css('float', 'left');
  598. label.innerHTML = 'Label...';
  599. JQuery(label).click(appScope.resizableElement);
  600. JQuery(wrapper).append(label);
  601. var mybr = document.createElement('div');
  602. mybr.setAttribute('id', 'ff_break' + rndId);
  603. mybr.setAttribute('class', 'ff_break');
  604. JQuery(mybr).css('display','none');
  605. JQuery(wrapper).append(mybr);
  606. }
  607. besideElement = appScope.createElementByType(type, rndId);
  608. if(besideElement != null){
  609. JQuery(wrapper).append(besideElement.element);
  610. ffListItem.append(wrapper);
  611. var appender = document.createElement('div');
  612. appender.setAttribute('class', 'ff_appender');
  613. JQuery(appender).css('clear','both');
  614. JQuery(ffListItem).append(appender);
  615. elements.push(
  616. {
  617. id : besideElement.element.id,
  618. dbId : 0,
  619. rndId : rndId,
  620. name : rndId, // default name until changed by user
  621. title : 'title_' + besideElement.element.id, // default title until changed by user
  622. type : besideElement.element.type ? besideElement.element.type : '',
  623. internalType : type,
  624. bfType : besideElement.bfType,
  625. elementType : besideElement.elementType,
  626. area : element.area,
  627. appElementId : type,
  628. appElementOrderId : elements.length,
  629. wrapperId : wrapper.id,
  630. labelId : label ? label.id : '',
  631. listItemId : element.listItemId,
  632. data1 : besideElement.data1,
  633. data2 : besideElement.data2,
  634. data3 : besideElement.data3,
  635. script1cond : besideElement.script1cond,
  636. script1id : besideElement.script1id,
  637. script1code : besideElement.script1code,
  638. script1flag1 : besideElement.script1flag1,
  639. script1flag2 : besideElement.script1flag2,
  640. script2cond : besideElement.script2cond,
  641. script2id : besideElement.script2id,
  642. script2code : besideElement.script2code,
  643. script2flag1 : besideElement.script2flag1,
  644. script2flag2 : besideElement.script2flag2,
  645. script2flag3 : besideElement.script2flag3,
  646. script2flag4 : besideElement.script2flag4,
  647. script2flag5 : besideElement.script2flag5,
  648. script3cond : besideElement.script3cond,
  649. script3id : besideElement.script3id,
  650. script3code : besideElement.script3code,
  651. script3msg : besideElement.script3msg,
  652. functionNameScript1: besideElement.functionNameScript1,
  653. functionNameScript2: besideElement.functionNameScript2,
  654. functionNameScript3: besideElement.functionNameScript3,
  655. flag1 : besideElement.flag1,
  656. flag2 : besideElement.flag2,
  657. mailback : besideElement.mailback,
  658. mailbackfile : besideElement.mailbackfile,
  659. mailbackAsSender : false,
  660. mailbackAccept : false,
  661. mailbackAcceptConnectWith: '',
  662. orderNumber : -1,
  663. tabIndex : -1,
  664. page : parseInt(document.adminForm.page.value),
  665. options : besideElement.options
  666. }
  667. );
  668. if(type == 'bfCaptcha'){
  669. appScope.captchaAdded++;
  670. }
  671. appScope.populateHiddenFieldsOptions();
  672. if(type != 'bfHidden'){
  673. appScope.setElementResizable(besideElement.element);
  674. }
  675. var labelsResult = JQuery('#'+besideElement.element.id).parent().parent().children('.ff_label');
  676. if(labelsResult.length != 0){
  677. for(var k = 0; k < labelsResult.length;k++){
  678. appScope.setElementResizable(labelsResult[k]);
  679. }
  680. }
  681. labelsResult = JQuery('#'+besideElement.element.id).parent().children('.ff_label');
  682. if(labelsResult.length != 0){
  683. for(var k = 0; k < labelsResult.length;k++){
  684. appScope.setElementResizable(labelsResult[k]);
  685. }
  686. }
  687. appScope.initMouseOvers();
  688. }
  689. }
  690. };
  691. this.createElementBesideByType = function(element, selector){
  692. this.createElementBeside( element, JQuery(selector).val() );
  693. };
  694. this.disableElementsDetails = function(){
  695. JQuery('.bfOptionsWrapper').css('display','none');
  696. JQuery('.bfOptions').css('display','none');
  697. JQuery('.bfOptions').css('visibility','hidden');
  698. JQuery('#bfActions').css('display','none');
  699. JQuery('#bfActions').css('visibility','hidden');
  700. JQuery('#bfGlobalOptions').css('display','none');
  701. JQuery('#bfGlobalOptions').css('visibility','hidden');
  702. JQuery('#bfSaveOptionsButton').css('display','none');
  703. JQuery('#bfSaveOptionsButton').css('visibility','hidden');
  704. JQuery('#bfRemoveLabelButton').css('display','none');
  705. JQuery('#bfRemoveLabelButton').css('visibility','hidden');
  706. JQuery('#bfOptionsSaveMessage').css('display','none');
  707. JQuery('#bfOptionsSaveMessage').css('visibility','hidden');
  708. JQuery('#bfBesideCreationButton').css('display','none');
  709. JQuery('#bfBesideCreationButton').css('visibility','hidden');
  710. JQuery('#bfElementRemoveButton').css('display','none');
  711. JQuery('#bfElementRemoveButton').css('visibility','hidden');
  712. JQuery('#bfElementMoveLeft').css('display','none');
  713. JQuery('#bfElementMoveRight').css('display','none');
  714. JQuery('#bfInitScript').css('display','none');
  715. JQuery('#bfInitScript').css('visibility','hidden');
  716. JQuery('#bfActionScript').css('display','none');
  717. JQuery('#bfActionScript').css('visibility','hidden');
  718. JQuery('#bfValidationScript').css('display','none');
  719. JQuery('#bfValidationScript').css('visibility','hidden');
  720. JQuery('.bfScriptsSaveMessage').css('display','none');
  721. };
  722. this.handleLabel = function (label){
  723. appScope.disableElementsDetails();
  724. appScope.optionElement = label;
  725. if(appScope.optionElement != null){
  726. JQuery('#bfOptionsWrapper').css('display','');
  727. JQuery('#bfGlobalOptions').css('display','');
  728. JQuery('#bfGlobalOptions').css('visibility','visible');
  729. JQuery('#bfSaveOptionsButton').css('display','');
  730. JQuery('#bfSaveOptionsButton').css('visibility','visible');
  731. JQuery('#bfRemoveLabelButton').css('display','');
  732. JQuery('#bfRemoveLabelButton').css('visibility','visible');
  733. JQuery('#bfLabelOptions').css('display','');
  734. JQuery('#bfLabelOptions').css('visibility','visible');
  735. JQuery(label).resizable('destroy');
  736. JQuery('#bfLabelContent').get(0).value = JQuery(label).get(0).innerHTML;
  737. appScope.setElementResizable(JQuery(label).get(0));
  738. if(JQuery(label).parent().children('.ff_break')[0].style.display != 'none'){
  739. JQuery('#bfLabelOnTop').attr('checked', true);
  740. } else {
  741. JQuery('#bfLabelOnTop').attr('checked', false);
  742. }
  743. JQuery('#bfLabelWidth').get(0).value = JQuery(label).get(0).style.width;
  744. JQuery('#bfLabelHeight').get(0).value = JQuery(label).get(0).style.height;
  745. JQuery('#bfOptionsPadding').get(0).value = JQuery(label).get(0).style.padding;
  746. JQuery('#bfOptionsMargin').get(0).value = JQuery(label).get(0).style.margin;
  747. }
  748. };
  749. this.populateElementValidationScript = function(){
  750. JQuery('#bfValidationScript').css('display','');
  751. JQuery('#bfValidationScript').css('visibility','visible');
  752. JQuery('#bfValidationScriptSelection').empty();
  753. for(var i = 0; i < appScope.elementScripts.validation.length;i++){
  754. var option = document.createElement('option');
  755. JQuery(option).val(appScope.elementScripts.validation[i].id);
  756. JQuery(option).text(appScope.elementScripts.validation[i].package + '::' + appScope.elementScripts.validation[i].name);
  757. if(appScope.elementScripts.validation[i].id == appScope.optionElement.script3id){
  758. //JQuery(option).attr('selected', 'selected');
  759. JQuery(option).get(0).setAttribute('selected', 'selected');
  760. }
  761. JQuery('#bfValidationScriptSelection').append(option);
  762. }
  763. JQuery('#script3msg').val(appScope.optionElement.script3msg);
  764. JQuery('#script3code').val(appScope.optionElement.script3code);
  765. switch(appScope.optionElement.script3cond){
  766. case 1:
  767. JQuery('.bfValidationType').attr('checked','');
  768. JQuery('#bfValidationTypeLibrary').attr('checked','checked');
  769. JQuery('#bfValidationScriptLibrary').css('display','');
  770. JQuery('#bfValidationScriptCustom').css('display','none');
  771. JQuery('#bfValidationScriptFlags').css('display','');
  772. JQuery('#bfValidationScriptLibrary').css('display','');
  773. JQuery('#bfValidationScriptCustom').css('display','none');
  774. break;
  775. case 2:
  776. JQuery('.bfValidationType').attr('checked','');
  777. JQuery('#bfValidationTypeCustom').attr('checked','checked');
  778. JQuery('#bfValidationScriptFlags').css('display','');
  779. JQuery('#bfValidationScriptLibrary').css('display','none');
  780. JQuery('#bfValidationScriptCustom').css('display','');
  781. break;
  782. default:
  783. JQuery('.bfValidationType').attr('checked','');
  784. JQuery('#bfValidationTypeNone').attr('checked','checked');
  785. JQuery('#bfValidationScriptFlags').css('display','none');
  786. JQuery('#bfValidationScriptLibrary').css('display','none');
  787. JQuery('#bfValidationScriptCustom').css('display','none');
  788. }
  789. };
  790. this.populateElementInitScript = function(){
  791. JQuery('#bfInitScript').css('display','');
  792. JQuery('#bfInitScript').css('visibility','visible');
  793. JQuery('#bfInitScriptSelection').empty();
  794. for(var i = 0; i < appScope.elementScripts.init.length;i++){
  795. var option = document.createElement('option');
  796. JQuery(option).val(appScope.elementScripts.init[i].id);
  797. JQuery(option).text(appScope.elementScripts.init[i].package + '::' + appScope.elementScripts.init[i].name);
  798. if(appScope.elementScripts.init[i].id == appScope.optionElement.script1id){
  799. //JQuery(option).attr('selected', 'selected');
  800. JQuery(option).get(0).setAttribute('selected', 'selected');
  801. }
  802. JQuery('#bfInitScriptSelection').append(option);
  803. }
  804. if(appScope.optionElement.script1flag1 == 1){
  805. JQuery('#script1flag1').get(0).checked = true;
  806. } else {
  807. JQuery('#script1flag1').get(0).checked = false;
  808. }
  809. if(appScope.optionElement.script1flag2 == 1){
  810. JQuery('#script1flag2').get(0).checked = true;
  811. } else {
  812. JQuery('#script1flag2').get(0).checked = false;
  813. }
  814. JQuery('#script1code').val(appScope.optionElement.script1code);
  815. switch(appScope.optionElement.script1cond){
  816. case 1:
  817. JQuery('.bfInitType').attr('checked','');
  818. JQuery('#bfInitTypeLibrary').attr('checked','checked');
  819. JQuery('#bfInitScriptLibrary').css('display','');
  820. JQuery('#bfInitScriptCustom').css('display','none');
  821. JQuery('#bfInitScriptFlags').css('display','');
  822. JQuery('#bfInitScriptLibrary').css('display','');
  823. JQuery('#bfInitScriptCustom').css('display','none');
  824. break;
  825. case 2:
  826. JQuery('.bfInitType').attr('checked','');
  827. JQuery('#bfInitTypeCustom').attr('checked','checked');
  828. JQuery('#bfInitScriptFlags').css('display','');
  829. JQuery('#bfInitScriptLibrary').css('display','none');
  830. JQuery('#bfInitScriptCustom').css('display','');
  831. break;
  832. default:
  833. JQuery('.bfInitType').attr('checked','');
  834. JQuery('#bfInitTypeNone').attr('checked','checked');
  835. JQuery('#bfInitScriptFlags').css('display','none');
  836. JQuery('#bfInitScriptLibrary').css('display','none');
  837. JQuery('#bfInitScriptCustom').css('display','none');
  838. }
  839. };
  840. this.populateElementActionScript = function(){
  841. JQuery('#bfActionScript').css('display','');
  842. JQuery('#bfActionScript').css('visibility','visible');
  843. if(appScope.optionElement.internalType == 'bfSofortueberweisung' || appScope.optionElement.internalType == 'bfPayPal' || appScope.optionElement.internalType == 'bfIcon' || appScope.optionElement.internalType == 'bfImageButton' || appScope.optionElement.internalType == 'bfSubmitButton'){
  844. JQuery('.script2flag').css('display','none');
  845. JQuery('.script2flagLabel').css('display','none');
  846. JQuery('#script2flag1').css('display','');
  847. JQuery('#script2flag1Label').css('display','');
  848. } else {
  849. JQuery('.script2flag').css('display','');
  850. JQuery('.script2flagLabel').css('display','');
  851. }
  852. JQuery('#bfActionsScriptSelection').empty();
  853. for(var i = 0; i < appScope.elementScripts.action.length;i++){
  854. var option = document.createElement('option');
  855. JQuery(option).val(appScope.elementScripts.action[i].id);
  856. JQuery(option).text(appScope.elementScripts.action[i].package + '::' + appScope.elementScripts.action[i].name);
  857. if(appScope.elementScripts.action[i].id == appScope.optionElement.script2id){
  858. JQuery(option).get(0).setAttribute('selected', 'selected');
  859. }
  860. JQuery('#bfActionsScriptSelection').append(option);
  861. }
  862. if(appScope.optionElement.script2flag1 == 1){
  863. JQuery('#script2flag1').get(0).checked = true;
  864. } else {
  865. JQuery('#script2flag1').get(0).checked = false;
  866. }
  867. if(appScope.optionElement.script2flag2 == 1){
  868. JQuery('#script2flag2').get(0).checked = true;
  869. } else {
  870. JQuery('#script2flag2').get(0).checked = false;
  871. }
  872. if(appScope.optionElement.script2flag3 == 1){
  873. JQuery('#script2flag3').get(0).checked = true;
  874. } else {
  875. JQuery('#script2flag3').get(0).checked = false;
  876. }
  877. if(appScope.optionElement.script2flag4 == 1){
  878. JQuery('#script2flag4').get(0).checked = true;
  879. } else {
  880. JQuery('#script2flag4').get(0).checked = false;
  881. }
  882. if(appScope.optionElement.script2flag5 == 1){
  883. JQuery('#script2flag5').get(0).checked = true;
  884. } else {
  885. JQuery('#script2flag5').get(0).checked = false;
  886. }
  887. JQuery('#script2code').val(appScope.optionElement.script2code);
  888. switch(appScope.optionElement.script2cond){
  889. case 1:
  890. JQuery('.bfActionType').attr('checked','');
  891. JQuery('#bfActionTypeLibrary').attr('checked','checked');
  892. JQuery('#bfActionScriptLibrary').css('display','');
  893. JQuery('#bfActionScriptCustom').css('display','none');
  894. JQuery('#bfActionScriptFlags').css('display','');
  895. JQuery('#bfActionScriptLibrary').css('display','');
  896. JQuery('#bfActionScriptCustom').css('display','none');
  897. break;
  898. case 2:
  899. JQuery('.bfActionType').attr('checked','');
  900. JQuery('#bfActionTypeCustom').attr('checked','checked');
  901. JQuery('#bfActionScriptFlags').css('display','');
  902. JQuery('#bfActionScriptLibrary').css('display','none');
  903. JQuery('#bfActionScriptCustom').css('display','');
  904. break;
  905. default:
  906. JQuery('.bfActionType').attr('checked','');
  907. JQuery('#bfActionTypeNone').attr('checked','checked');
  908. JQuery('#bfActionScriptFlags').css('display','none');
  909. JQuery('#bfActionScriptLibrary').css('display','none');
  910. JQuery('#bfActionScriptCustom').css('display','none');
  911. }
  912. };
  913. /**
  914. * handles the selected element to show its options in the accordion menu
  915. */
  916. this.handleElement = function(element){
  917. appScope.disableElementsDetails();
  918. if(element != null){
  919. appScope.optionElement = element;
  920. JQuery('#bfOptionsWrapper').css('display','');
  921. JQuery('#bfActions').css('display','');
  922. JQuery('#bfActions').css('visibility','visible');
  923. JQuery('#bfGlobalOptions').css('display','');
  924. JQuery('#bfGlobalOptions').css('visibility','visible');
  925. JQuery('#bfSaveOptionsButton').css('display','');
  926. JQuery('#bfSaveOptionsButton').css('visibility','visible');
  927. JQuery('#bfElementRemoveButton').css('display','');
  928. JQuery('#bfElementRemoveButton').css('visibility','visible');
  929. JQuery('#bfElementMoveLeft').css('display','');
  930. JQuery('#bfElementMoveLeft').css('visibility','visible');
  931. JQuery('#bfElementMoveRight').css('display','');
  932. JQuery('#bfElementMoveRight').css('visibility','visible');
  933. JQuery('#bfBesideCreationButton').css('display','');
  934. JQuery('#bfBesideCreationButton').css('visibility','visible');
  935. switch(element.internalType){
  936. case 'bfStaticText':
  937. JQuery('#bfStaticTextOptions').css('display','');
  938. JQuery('#bfStaticTextOptions').css('visibility','visible');
  939. JQuery('#bfStaticTextTitle').get(0).value = element.title;
  940. JQuery('#bfStaticTextWidth').get(0).value = JQuery('#'+element.id).get(0).style.width;
  941. JQuery('#bfStaticTextHeight').get(0).value = JQuery('#'+element.id).get(0).style.height;
  942. JQuery('#'+element.id).resizable('destroy');
  943. JQuery('#bfStaticTextContent').get(0).value = JQuery('#'+element.id).get(0).innerHTML;
  944. appScope.setElementResizable(JQuery('#'+element.id).get(0));
  945. break;
  946. case 'bfIcon':
  947. JQuery('#bfIconOptions').css('display','');
  948. JQuery('#bfIconOptions').css('visibility','visible');
  949. JQuery('#bfIconCaption').get(0).value = JQuery('#'+element.id).children('#ff_iconCaption'+element.rndId)[0].innerHTML;
  950. JQuery('#bfIconWidth').get(0).value = JQuery('#'+element.id).get(0).style.width;
  951. JQuery('#bfIconHeight').get(0).value = JQuery('#'+element.id).get(0).style.height;
  952. JQuery('#bfIconImage').get(0).value = JQuery('#'+element.id).attr('src');
  953. JQuery('#bfIconImage').get(0).value = element.data1;
  954. JQuery('#bfIconImageOver').get(0).value = element.data3;
  955. appScope.populateElementActionScript();
  956. break;
  957. case 'bfCalendar':
  958. JQuery('#bfCalendarOptions').css('display','');
  959. JQuery('#bfCalendarOptions').css('visibility','visible');
  960. JQuery('#bfCalendarFormat').get(0).value = element.options.format;
  961. JQuery('#bfCalendarConnectWith').get(0).value = element.options.connectWith;
  962. JQuery('#'+element.id).resizable('destroy');
  963. JQuery('#bfCalendarText').get(0).value = JQuery('#'+element.id).get(0).innerHTML.replace('','');
  964. appScope.setElementResizable(JQuery('#'+element.id).get(0));
  965. break;
  966. case 'bfCaptcha':
  967. JQuery('#bfCaptchaOptions').css('display','');
  968. JQuery('#bfCaptchaOptions').css('visibility','visible');
  969. JQuery('#bfCaptchaWidth').get(0).value = JQuery('.ff_captcha')[0].style.width;
  970. JQuery('#bfCaptchaHeight').get(0).value = JQuery('.ff_captcha')[0].style.height;
  971. break;
  972. case 'bfTextfield':
  973. JQuery('#bfTextfieldOptions').css('display','');
  974. JQuery('#bfTextfieldOptions').css('visibility','visible');
  975. JQuery('#bfTextfieldTitle').get(0).value = element.title;
  976. JQuery('#bfTextfieldName').get(0).value = element.name;
  977. JQuery('#bfTextfieldValue').get(0).value = element.options.value;
  978. JQuery('#bfTextfieldWidth').get(0).value = JQuery('#'+element.id).get(0).style.width;
  979. JQuery('#bfTextfieldHeight').get(0).value = JQuery('#'+element.id).get(0).style.height;
  980. JQuery('#bfTextfieldMaxlength').get(0).value = JQuery('#'+element.id).attr('maxlength') > -1 ? JQuery('#'+element.id).attr('maxlength') : '';
  981. if(element.options.readonly){
  982. JQuery('#bfTextfieldDisable').attr('checked', true);
  983. JQuery('#'+element.id).get(0).setAttribute('readonly','readonly');
  984. } else {
  985. JQuery('#bfTextfieldDisable').attr('checked', false);
  986. JQuery('#'+element.id).get(0).setAttribute('readonly','');
  987. JQuery('#'+element.id).get(0).removeAttribute('readonly');
  988. }
  989. if(element.options.password){
  990. JQuery('#bfTextfieldPassword').attr('checked', true);
  991. JQuery('#'+element.id).get(0).setAttribute('type','password');
  992. } else {
  993. JQuery('#bfTextfieldPassword').attr('checked', false);
  994. JQuery('#'+element.id).get(0).setAttribute('type', 'text');
  995. }
  996. if(element.options.mailback){
  997. JQuery('#bfTextfieldMailback').attr('checked', true);
  998. } else {
  999. JQuery('#bfTextfieldMailback').attr('checked', false);
  1000. }
  1001. if(element.mailbackAsSender){
  1002. JQuery('#bfTextfieldMailbackAsSender').attr('checked', true);
  1003. } else {
  1004. JQuery('#bfTextfieldMailbackAsSender').attr('checked', false);
  1005. }
  1006. JQuery('#bfTextfieldMailbackfile').get(0).value = element.mailbackfile;
  1007. appScope.populateElementActionScript();
  1008. appScope.populateElementInitScript();
  1009. appScope.populateElementValidationScript();
  1010. break;
  1011. case 'bfTextarea':
  1012. JQuery('#bfTextareaOptions').css('display','');
  1013. JQuery('#bfTextareaOptions').css('visibility','visible');
  1014. JQuery('#bfTextareaTitle').get(0).value = element.title;
  1015. JQuery('#bfTextareaName').get(0).value = element.name;
  1016. JQuery('#bfTextareaValue').get(0).value = element.options.value;
  1017. JQuery('#bfTextareaWidth').get(0).value = JQuery('#'+element.id).get(0).style.width;
  1018. JQuery('#bfTextareaHeight').get(0).value = JQuery('#'+element.id).get(0).style.height;
  1019. if(element.options.readonly){
  1020. JQuery('#bfTextareaDisable').attr('checked', true);
  1021. JQuery('#'+element.id).get(0).setAttribute('readonly','readonly');
  1022. } else {
  1023. JQuery('#bfTextareaDisable').attr('checked', false);
  1024. JQuery('#'+element.id).get(0).setAttribute('readonly','');
  1025. JQuery('#'+element.id).get(0).removeAttribute('readonly');
  1026. }
  1027. appScope.populateElementInitScript();
  1028. appScope.populateElementActionScript();
  1029. appScope.populateElementValidationScript();
  1030. break;
  1031. case 'bfCheckbox':
  1032. JQuery('#bfCheckboxOptions').css('display','');
  1033. JQuery('#bfCheckboxOptions').css('visibility','visible');
  1034. JQuery('#bfCheckboxChecked').get(0).checked = element.options.checked;
  1035. JQuery('#bfCheckboxValue').get(0).value = element.options.value;
  1036. JQuery('#bfCheckboxValue').get(0).setAttribute('value', element.options.value);
  1037. JQuery('#bfCheckboxTitle').get(0).value = element.title;
  1038. JQuery('#bfCheckboxName').get(0).value = element.name;
  1039. JQuery('#bfCheckboxWidth').get(0).value = JQuery('#'+element.id).get(0).style.width;
  1040. JQuery('#bfCheckboxHeight').get(0).value = JQuery('#'+element.id).get(0).style.height;
  1041. if(element.options.readonly){
  1042. JQuery('#bfCheckboxDisable').attr('checked', true);
  1043. JQuery('#'+element.id).get(0).setAttribute('readonly','readonly');
  1044. } else {
  1045. JQuery('#bfCheckboxDisable').attr('checked', false);
  1046. JQuery('#'+element.id).get(0).setAttribute('readonly','');
  1047. JQuery('#'+element.id).get(0).removeAttribute('readonly');
  1048. }
  1049. if(element.mailbackAccept){
  1050. JQuery('#bfCheckboxMailbackAccept').attr('checked', true);
  1051. } else {
  1052. JQuery('#bfCheckboxMailbackAccept').attr('checked', false);
  1053. }
  1054. JQuery('#bfCheckboxMailbackAcceptConnectWith').get(0).value = element.mailbackAcceptConnectWith;
  1055. appScope.populateElementInitScript();
  1056. appScope.populateElementActionScript();
  1057. appScope.populateElementValidationScript();
  1058. break;
  1059. case 'bfRadio':
  1060. JQuery('#bfRadioOptions').css('display','');
  1061. JQuery('#bfRadioOptions').css('visibility','visible');
  1062. JQuery('#bfRadioChecked').get(0).checked = element.options.checked;
  1063. JQuery('#bfRadioValue').get(0).value = element.options.value;
  1064. JQuery('#bfRadioValue').get(0).setAttribute('value', element.options.value);
  1065. JQuery('#bfRadioTitle').get(0).value = element.title;
  1066. JQuery('#bfRadioName').get(0).value = element.name;
  1067. JQuery('#bfRadioWidth').get(0).value = JQuery('#'+element.id).get(0).style.width;
  1068. JQuery('#bfRadioHeight').get(0).value = JQuery('#'+element.id).get(0).style.height;
  1069. if(element.options.readonly){
  1070. JQuery('#bfRadioDisable').attr('checked', true);
  1071. JQuery('#'+element.id).get(0).setAttribute('readonly','readonly');
  1072. } else {
  1073. JQuery('#bfRadioDisable').attr('checked', false);
  1074. JQuery('#'+element.id).get(0).setAttribute('readonly','');
  1075. JQuery('#'+element.id).get(0).removeAttribute('readonly');
  1076. }
  1077. appScope.populateElementInitScript();
  1078. appScope.populateElementActionScript();
  1079. appScope.populateElementValidationScript();
  1080. break;
  1081. case 'bfSelect':
  1082. JQuery('#bfSelectOptions').css('display','');
  1083. JQuery('#bfSelectOptions').css('visibility','visible');
  1084. JQuery('#bfSelectTitle').get(0).value = element.title;
  1085. JQuery('#bfSelectName').get(0).value = element.name;
  1086. if(element.options.multiple){
  1087. JQuery('#bfSelectMultipleYes').attr('checked', true);
  1088. JQuery('#bfSelectMultipleNo').attr('checked', false);
  1089. } else {
  1090. JQuery('#bfSelectMultipleNo').attr('checked', true);
  1091. JQuery('#bfSelectMultipleYes').attr('checked', false);
  1092. }
  1093. JQuery('#bfSelectOpts').get(0).value = element.options.options;
  1094. JQuery('#bfSelectWidth').get(0).value = JQuery('#'+element.id).get(0).style.width;
  1095. JQuery('#bfSelectHeight').get(0).value = JQuery('#'+element.id).get(0).style.height;
  1096. if(element.options.readonly){
  1097. JQuery('#bfSelectDisable').attr('checked', true);
  1098. JQuery('#'+element.id).get(0).setAttribute('readonly','readonly');
  1099. } else {
  1100. JQuery('#bfTextfieldDisable').attr('checked', false);
  1101. JQuery('#'+element.id).get(0).setAttribute('readonly','');
  1102. JQuery('#'+element.id).get(0).removeAttribute('readonly');
  1103. }
  1104. if(element.options.mailback){
  1105. JQuery('#bfSelectMailback').attr('checked', true);
  1106. } else {
  1107. JQuery('#bfSelectMailback').attr('checked', false);
  1108. }
  1109. appScope.populateElementInitScript();
  1110. appScope.populateElementActionScript();
  1111. appScope.populateElementValidationScript();
  1112. break;
  1113. case 'bfFile':
  1114. JQuery('#bfFileOptions').css('display','');
  1115. JQuery('#bfFileOptions').css('visibility','visible');
  1116. JQuery('#bfFileTitle').get(0).value = element.title;
  1117. JQuery('#bfFileName').get(0).value = element.name;
  1118. if(element.options.timestamp){
  1119. JQuery('#bfFileTimestamp').attr('checked', true);
  1120. } else {
  1121. JQuery('#bfFileTimestamp').attr('checked', false);
  1122. }
  1123. if(element.options.attachToAdminMail){
  1124. JQuery('#bfFileAttachToAdminMail').attr('checked', true);
  1125. } else {
  1126. JQuery('#bfFileAttachToAdminMail').attr('checked', false);
  1127. }
  1128. if(element.options.attachToUserMail){
  1129. JQuery('#bfFileAttachToUserMail').attr('checked', true);
  1130. } else {
  1131. JQuery('#bfFileAttachToUserMail').attr('checked', false);
  1132. }
  1133. JQuery('#bfFileUploadDirectory').get(0).value = element.options.uploadDirectory;
  1134. if(!element.options.allowedFileExtensions) element.options['allowedFileExtensions'] = -1; // compat 690
  1135. JQuery('#bfFileAllowedFileExtensions').get(0).value = element.options.allowedFileExtensions;
  1136. JQuery('#bfFileWidth').get(0).value = JQuery('#'+element.id).get(0).style.width;
  1137. JQuery('#bfFileHeight').get(0).value = JQuery('#'+element.id).get(0).style.height;
  1138. if(element.options.readonly){
  1139. JQuery('#bfFileDisable').attr('checked', true);
  1140. JQuery('#'+element.id).get(0).setAttribute('readonly','readonly');
  1141. } else {
  1142. JQuery('#bfFileDisable').attr('checked', false);
  1143. JQuery('#'+element.id).get(0).setAttribute('readonly','');
  1144. JQuery('#'+element.id).get(0).removeAttribute('readonly');
  1145. }
  1146. appScope.populateElementInitScript();
  1147. appScope.populateElementActionScript();
  1148. appScope.populateElementValidationScript();
  1149. break;
  1150. case 'bfImageButton':
  1151. JQuery('#bfImageButtonOptions').css('display','');
  1152. JQuery('#bfImageButtonOptions').css('visibility','visible');
  1153. JQuery('#bfImageButtonTitle').get(0).value = element.title;
  1154. JQuery('#bfImageButtonName').get(0).value = element.name;
  1155. JQuery('#bfImageButtonValue').get(0).value = element.options.value;
  1156. JQuery('#bfImageButtonWidth').get(0).value = JQuery('#'+element.id).get(0).style.width;
  1157. JQuery('#bfImageButtonHeight').get(0).value = JQuery('#'+element.id).get(0).style.height;
  1158. JQuery('#bfImageButtonImage').get(0).value = JQuery('#'+element.id).get(0).getAttribute('src');
  1159. if(element.options.readonly){
  1160. JQuery('#bfImageButtonDisable').attr('checked', true);
  1161. JQuery('#'+element.id).get(0).setAttribute('readonly','readonly');
  1162. } else {
  1163. JQuery('#bfImageButtonDisable').attr('checked', false);
  1164. JQuery('#'+element.id).get(0).setAttribute('readonly','');
  1165. JQuery('#'+element.id).get(0).removeAttribute('readonly');
  1166. }
  1167. appScope.populateElementActionScript();
  1168. break;
  1169. case 'bfSubmitButton':
  1170. JQuery('#bfSubmitButtonOptions').css('display','');
  1171. JQuery('#bfSubmitButtonOptions').css('visibility','visible');
  1172. JQuery('#bfSubmitButtonTitle').get(0).value = element.title;
  1173. JQuery('#bfSubmitButtonName').get(0).value = element.name;
  1174. JQuery('#bfSubmitButtonValue').get(0).value = element.options.value;
  1175. JQuery('#bfSubmitButtonWidth').get(0).value = JQuery('#'+element.id).get(0).style.width;
  1176. JQuery('#bfSubmitButtonHeight').get(0).value = JQuery('#'+element.id).get(0).style.height;
  1177. if(element.options.readonly){
  1178. JQuery('#bfSubmitButtonDisable').attr('checked', true);
  1179. JQuery('#'+element.id).get(0).setAttribute('readonly','readonly');
  1180. } else {
  1181. JQuery('#bfSubmitButtonDisable').attr('checked', false);
  1182. JQuery('#'+element.id).get(0).setAttribute('readonly','');
  1183. JQuery('#'+element.id).get(0).removeAttribute('readonly');
  1184. }
  1185. appScope.populateElementActionScript();
  1186. break;
  1187. case 'bfTooltip':
  1188. JQuery('#bfTooltipOptions').css('display','');
  1189. JQuery('#bfTooltipOptions').css('visibility','visible');
  1190. JQuery('#bfTooltipTitle').get(0).value = element.title;
  1191. JQuery('#bfTooltipName').get(0).value = element.name;
  1192. if(element.options.type == 'info'){
  1193. JQuery('#bfTooltipTypeInfo').get(0).checked = true;
  1194. JQuery('#bfTooltipTypeWarning').get(0).checked = false;
  1195. JQuery('#bfTooltipTypeCustom').get(0).checked = false;
  1196. } else if(element.options.type == 'warning'){
  1197. JQuery('#bfTooltipTypeInfo').get(0).checked = false;
  1198. JQuery('#bfTooltipTypeWarning').get(0).checked = true;
  1199. JQuery('#bfTooltipTypeCustom').get(0).checked = false;
  1200. } else if(element.options.type == 'custom'){
  1201. JQuery('#bfTooltipTypeInfo').get(0).checked = false;
  1202. JQuery('#bfTooltipTypeWarning').get(0).checked = false;
  1203. JQuery('#bfTooltipTypeCustom').get(0).checked = true;
  1204. JQuery('#bfTooltipCustomImage').get(0).value = element.options.image;
  1205. }
  1206. JQuery('#bfTooltipText').get(0).value = element.options.text;
  1207. JQuery('#bfTooltipWidth').get(0).value = JQuery('#'+element.id).get(0).style.width;
  1208. JQuery('#bfTooltipHeight').get(0).value = JQuery('#'+element.id).get(0).style.height;
  1209. break;
  1210. case 'bfPayPal':
  1211. JQuery('#bfPayPalOptions').css('display','');
  1212. JQuery('#bfPayPalOptions').css('visibility','visible');
  1213. JQuery('#bfPayPalTitle').get(0).value = element.title;
  1214. JQuery('#bfPayPalName').get(0).value = element.name;
  1215. if(element.options.testaccount){
  1216. JQuery('#bfPayPalTestaccountYes').attr('checked', 'checked');
  1217. JQuery('#bfPayPalTestaccountNo').attr('checked', '');
  1218. } else {
  1219. JQuery('#bfPayPalTestaccountYes').attr('checked', '');
  1220. JQuery('#bfPayPalTestaccountNo').attr('checked', 'checked');
  1221. }
  1222. if(element.options.downloadableFile){
  1223. JQuery('#bfPayPalDownloadableFileYes').attr('checked', 'checked');
  1224. JQuery('#bfPayPalDownloadableFileNo').attr('checked', '');
  1225. } else {
  1226. JQuery('#bfPayPalDownloadableFileYes').attr('checked', '');
  1227. JQuery('#bfPayPalDownloadableFileNo').attr('checked', 'checked');
  1228. }
  1229. if(typeof element.options.useIpn == "undefined") { // compat 730
  1230. element.options['useIpn'] = false;
  1231. }
  1232. if(element.options.useIpn){
  1233. JQuery('#bfPayPalUseIpnYes').attr('checked', 'checked');
  1234. JQuery('#bfPayPalUseIpnNo').attr('checked', '');
  1235. } else {
  1236. JQuery('#bfPayPalUseIpnYes').attr('checked', '');
  1237. JQuery('#bfPayPalUseIpnNo').attr('checked', 'checked');
  1238. }
  1239. JQuery('#bfPayPalFilepath').get(0).value = element.options.filepath;
  1240. JQuery('#bfPayPalFileDownloadTries').get(0).value = element.options.downloadTries;
  1241. JQuery('#bfPayPalBusiness').get(0).value = element.options.business;
  1242. JQuery('#bfPayPalToken').get(0).value = element.options.token;
  1243. JQuery('#bfPayPalTestBusiness').get(0).value = element.options.testBusiness;
  1244. JQuery('#bfPayPalTestToken').get(0).value = element.options.testToken;
  1245. JQuery('#bfPayPalItemname').get(0).value = element.options.itemname;
  1246. JQuery('#bfPayPalItemnumber').get(0).value = element.options.itemnumber;
  1247. JQuery('#bfPayPalAmount').get(0).value = element.options.amount;
  1248. JQuery('#bfPayPalTax').get(0).value = element.options.tax;
  1249. JQuery('#bfPayPalThankYouPage').get(0).value = element.options.thankYouPage;
  1250. JQuery('#bfPayPalLocale').get(0).value = element.options.locale;
  1251. JQuery('#bfPayPalCurrencyCode').get(0).value = element.options.currencyCode;
  1252. JQuery('#bfPayPalImage').get(0).value = JQuery('#'+element.id).attr('src');
  1253. JQuery('#bfPayPalWidth').get(0).value = JQuery('#'+element.id).get(0).style.width;
  1254. JQuery('#bfPayPalHeight').get(0).value = JQuery('#'+element.id).get(0).style.height;
  1255. appScope.populateElementActionScript();
  1256. break;
  1257. case 'bfSofortueberweisung':
  1258. JQuery('#bfSofortueberweisungOptions').css('display','');
  1259. JQuery('#bfSofortueberweisungOptions').css('visibility','visible');
  1260. JQuery('#bfSofortueberweisungTitle').get(0).value = element.title;
  1261. JQuery('#bfSofortueberweisungName').get(0).value = element.name;
  1262. if(element.options.downloadableFile){
  1263. JQuery('#bfSofortueberweisungDownloadableFileYes').attr('checked', 'checked');
  1264. JQuery('#bfSofortueberweisungDownloadableFileNo').attr('checked', '');
  1265. } else {
  1266. JQuery('#bfSofortueberweisungDownloadableFileYes').attr('checked', '');
  1267. JQuery('#bfSofortueberweisungDownloadableFileNo').attr('checked', 'checked');
  1268. }
  1269. if(element.options.mailback){
  1270. JQuery('#bfSofortueberweisungMailbackYes').attr('checked', 'checked');
  1271. JQuery('#bfSofortueberweisungMailbackNo').attr('checked', '');
  1272. } else {
  1273. JQuery('#bfSofortueberweisungMailbackYes').attr('checked', '');
  1274. JQuery('#bfSofortueberweisungMailbackNo').attr('checked', 'checked');
  1275. }
  1276. JQuery('#bfSofortueberweisungFilepath').get(0).value = element.options.filepath;
  1277. JQuery('#bfSofortueberweisungFileDownloadTries').get(0).value = element.options.downloadTries;
  1278. JQuery('#bfSofortueberweisungUserId').get(0).value = element.options.user_id;
  1279. JQuery('#bfSofortueberweisungProjectId').get(0).value = element.options.project_id;
  1280. JQuery('#bfSofortueberweisungProjectPassword').get(0).value = element.options.project_password;
  1281. JQuery('#bfSofortueberweisungReason1').get(0).value = element.options.reason_1;
  1282. JQuery('#bfSofortueberweisungReason2').get(0).value = element.options.reason_2;
  1283. JQuery('#bfSofortueberweisungAmount').get(0).value = element.options.amount;
  1284. JQuery('#bfSofortueberweisungThankYouPage').get(0).value = element.options.thankYouPage;
  1285. JQuery('#bfSofortueberweisungLanguageId').get(0).value = element.options.language_id;
  1286. JQuery('#bfSofortueberweisungCurrencyId').get(0).value = element.options.currency_id;
  1287. JQuery('#bfSofortueberweisungImage').get(0).value = JQuery('#'+element.id).attr('src');
  1288. JQuery('#bfSofortueberweisungWidth').get(0).value = JQuery('#'+element.id).get(0).style.width;
  1289. JQuery('#bfSofortueberweisungHeight').get(0).value = JQuery('#'+element.id).get(0).style.height;
  1290. appScope.populateElementActionScript();
  1291. break;
  1292. }
  1293. JQuery('#bfOptionsPadding').get(0).value = JQuery('#'+element.id).get(0).style.padding;
  1294. JQuery('#bfOptionsMargin').get(0).value = JQuery('#'+element.id).get(0).style.margin;
  1295. JQuery('#bfOptionsOrder').get(0).value = element.orderNumber;
  1296. JQuery('#bfOptionsTabIndex').get(0).value = element.tabIndex;
  1297. }
  1298. };
  1299. this.resizableElement = function(){
  1300. var internalElement = null;
  1301. var clazz = JQuery(this).attr('class');
  1302. if(clazz.substr(0, 8) != 'ff_label'){
  1303. if(clazz == 'ui-resizable-handle ui-resizable-se' || clazz == 'ui-resizable-handle ui-resizable-se '){
  1304. internalElement = appScope.getElementById( JQuery( JQuery(this).parent().children('.ff_elem')[0] ).attr('id') );
  1305. } else {
  1306. internalElement = appScope.getElementById(JQuery(this).attr('id'));
  1307. }
  1308. appScope.handleElement(internalElement);
  1309. } else {
  1310. internalElement = this;
  1311. appScope.handleLabel(internalElement);
  1312. }
  1313. };
  1314. this.cleanResizables = function(){
  1315. JQuery('.ff_elem').resizable('disable');
  1316. JQuery('.ff_label').resizable('disable');
  1317. }
  1318. this.destroyResizables = function(){
  1319. JQuery('.ff_elem').resizable('disable');
  1320. JQuery('.ff_label').resizable('disable');
  1321. JQuery('.ff_elem').resizable('destroy');
  1322. JQuery('.ff_label').resizable('destroy');
  1323. }
  1324. this.removeElement = function(element){
  1325. JQuery('.bfOptionsWrapper').css('display','none');
  1326. JQuery('.bfOptions').css('display','none');
  1327. JQuery('.bfOptions').css('visibility','hidden');
  1328. JQuery('#bfActions').css('display','none');
  1329. JQuery('#bfActions').css('visibility','hidden');
  1330. JQuery('#bfSaveOptionsButton').css('display','none');
  1331. JQuery('#bfSaveOptionsButton').css('visibility','hidden');
  1332. JQuery('#bfOptionsSaveMessage').css('display','none');
  1333. JQuery('#bfOptionsSaveMessage').css('visibility','hidden');
  1334. JQuery('#bfBesideCreationButton').css('display','none');
  1335. JQuery('#bfBesideCreationButton').css('visibility','hidden');
  1336. JQuery('#bfElementRemoveButton').css('display','none');
  1337. JQuery('#bfElementRemoveButton').css('visibility','hidden');
  1338. JQuery('#bfInitScript').css('display','none');
  1339. JQuery('#bfInitScript').css('visibility','hidden');
  1340. JQuery('#bfActionScript').css('display','none');
  1341. JQuery('#bfActionScript').css('visibility','hidden');
  1342. JQuery('#bfValidationScript').css('display','none');
  1343. JQuery('#bfValidationScript').css('visibility','hidden');
  1344. JQuery('.bfScriptsSaveMessage').css('display','none');
  1345. JQuery('#bfElementMoveLeft').css('display','none');
  1346. JQuery('#bfElementMoveRight').css('display','none');
  1347. JQuery('#'+element.wrapperId).remove();
  1348. if(element.internalType == 'bfCaptcha'){
  1349. appScope.captchaAdded--;
  1350. }
  1351. if(JQuery('#'+element.listItemId).children('.ff_div').length == 0){
  1352. JQuery('#'+element.listItemId).remove();
  1353. }
  1354. appScope.optionElement = null;
  1355. appScope.removeElementFromAreaList(element);
  1356. };
  1357. this.moveElement = function(element, direction){
  1358. if(direction != 'prev' && direction != 'next'){
  1359. return;
  1360. }
  1361. if(direction == 'next'){
  1362. if(typeof JQuery('#'+element.wrapperId + ' + .ff_div') != 'undefined'){
  1363. var nextElement = JQuery('#'+element.wrapperId + ' + .ff_div');
  1364. JQuery('#'+element.wrapperId).insertAfter(nextElement);
  1365. }
  1366. if(typeof JQuery('#'+element.wrapperId + ' + .ui-wrapper') != 'undefined'){
  1367. var nextElement = JQuery('#'+element.wrapperId + ' + .ui-wrapper');
  1368. JQuery('#'+element.wrapperId).insertAfter(nextElement);
  1369. }
  1370. } else if(direction == 'prev'){
  1371. if(typeof JQuery('#'+element.wrapperId).prev() != 'undefined' && JQuery('#'+element.wrapperId).prev().attr('class') == 'ff_div'){
  1372. var prevElement = JQuery('#'+element.wrapperId).prev();
  1373. JQuery('#'+element.wrapperId).insertBefore(prevElement);
  1374. }
  1375. }
  1376. }
  1377. this.createElementByType = function(typeName, rndId){
  1378. var element = null;
  1379. var bfType = '';
  1380. var elementType = '';
  1381. var options = {};
  1382. var data1 = '';
  1383. var data2 = '';
  1384. var data3 = '';
  1385. var script1cond = 0;
  1386. var script1id = 0;
  1387. var script1code = '';
  1388. var script1flag1 = 0;
  1389. var script1flag2 = 0;
  1390. var script2cond = 0;
  1391. var script2id = 0;
  1392. var script2code = '';
  1393. var script2flag1 = 0;
  1394. var script2flag2 = 0;
  1395. var script2flag3 = 0;
  1396. var script2flag4 = 0;
  1397. var script2flag5 = 0;
  1398. var script3cond = 0;
  1399. var script3id = 0;
  1400. var script3code = '';
  1401. var script3msg = '';
  1402. var functionNameScript1 = '';
  1403. var functionNameScript2 = '';
  1404. var functionNameScript3 = '';
  1405. var flag1 = 0;
  1406. var flag2 = 0;
  1407. var mailback = 0;
  1408. var mailbackfile = '';
  1409. switch(typeName){
  1410. case 'bfCalendar':
  1411. bfType = 'Calendar';
  1412. elementType = 'div';
  1413. element = document.createElement(elementType);
  1414. element.setAttribute('id', 'ff_elem' + rndId);
  1415. element.setAttribute('class', 'ff_elem');
  1416. element.innerHTML = 'pick date';
  1417. JQuery(element).click(appScope.resizableElement);
  1418. options = { format: '%Y-%m-%d', connectWith: '' };
  1419. break;
  1420. case 'bfCaptcha':
  1421. bfType = 'Captcha';
  1422. elementType = 'div';
  1423. element = document.createElement(elementType);
  1424. element.setAttribute('id', 'ff_elem' + rndId);
  1425. element.setAttribute('class', 'ff_elem');
  1426. var imageHolder = document.createElement('img');
  1427. imageHolder.setAttribute('id', 'ff_capimgValue');
  1428. imageHolder.setAttribute('class', 'ff_capimg');
  1429. imageHolder.setAttribute('src', 'components/com_breezingforms/images/captcha/securimage_show.php');
  1430. elementType = 'br';
  1431. var br = document.createElement(elementType);
  1432. elementType = 'input';
  1433. var cap = document.createElement(elementType);
  1434. cap.setAttribute('id', 'bfCaptchaEntry');
  1435. cap.setAttribute('name', 'bfCaptchaEntry');
  1436. cap.setAttribute('type', 'text');
  1437. cap.setAttribute('class', 'ff_captcha');
  1438. JQuery(cap).css('width','200px');
  1439. JQuery(cap).css('float','left');
  1440. var reload = document.createElement('div');
  1441. JQuery(reload).css('float','left');
  1442. JQuery(reload).css('padding-left','5px');
  1443. reload.innerHTML = '<a href="#" onclick="document.getElementById(\'bfCaptchaEntry\').value=\'\';document.getElementById(\'bfCaptchaEntry\').focus();var splitsrc = document.getElementById(\'ff_capimgValue\').src.split(\'?\'); document.getElementById(\'ff_capimgValue\').src = splitsrc[0] + \'?bfMathRandom=\' + Math.random(); return false"><img src="<?php echo JURI::root() ?>components/com_breezingforms/images/captcha/refresh-captcha.png" border="0" /></a>';
  1444. JQuery(element).append(imageHolder);
  1445. JQuery(element).append(br);
  1446. JQuery(element).append(cap);
  1447. JQuery(element).append(reload);
  1448. JQuery(element).click(appScope.resizableElement);
  1449. break;
  1450. case 'bfIcon':
  1451. var iconImage = '<?php echo JURI::root() ?>components/com_breezingforms/images/next.png';
  1452. bfType = 'Icon';
  1453. elementType = 'div';
  1454. element = document.createElement(elementType);
  1455. element.setAttribute('id', 'ff_elem' + rndId);
  1456. element.setAttribute('class', 'ff_elem');
  1457. element.setAttribute('align', 'center');
  1458. var imageHolder = document.createElement('img');
  1459. imageHolder.setAttribute('id', 'ff_icon' + rndId);
  1460. imageHolder.setAttribute('class', 'ff_icon');
  1461. imageHolder.setAttribute('src', iconImage);
  1462. var textHolder = document.createElement('div');
  1463. textHolder.setAttribute('id', 'ff_iconCaption' + rndId);
  1464. textHolder.setAttribute('class', 'ff_iconCaption');
  1465. textHolder.innerHTML = '<div align="center">Next</div>';
  1466. JQuery(element).append(imageHolder);
  1467. JQuery(element).append(textHolder);
  1468. JQuery(element).click(appScope.resizableElement);
  1469. data3 = '<?php echo JURI::root() ?>components/com_breezingforms/images/next_f2.png',
  1470. data1 = iconImage;
  1471. break;
  1472. case 'bfTextfield':
  1473. bfType = 'Text';
  1474. elementType = 'input';
  1475. element = document.createElement(elementType);
  1476. element.setAttribute('id', 'ff_elem' + rndId);
  1477. element.setAttribute('name', 'ff_nm_' + rndId + '[]');
  1478. element.setAttribute('type', 'text');
  1479. element.setAttribute('class', 'ff_elem');
  1480. JQuery(element).focus(appScope.resizableElement);
  1481. JQuery(element).css('width','170px');
  1482. JQuery(element).css('height','18px');
  1483. options = {value : '', readonly: false, password: false, mailback: false};
  1484. break;
  1485. case 'bfStaticText':
  1486. bfType = 'Static Text/HTML';
  1487. elementType = 'div';
  1488. element = document.createElement(elementType);
  1489. element.setAttribute('id', 'ff_elem' + rndId);
  1490. element.setAttribute('class', 'ff_elem');
  1491. element.innerHTML = 'Enter Text here...';
  1492. element.style.width = '150px';
  1493. element.style.height = '20px';
  1494. JQuery(element).click(appScope.resizableElement);
  1495. break;
  1496. case 'bfTextarea':
  1497. bfType = 'Textarea';
  1498. elementType = 'textarea';
  1499. element = document.createElement(elementType);
  1500. element.setAttribute('id', 'ff_elem' + rndId);
  1501. element.setAttribute('name', 'ff_nm_' + rndId + '[]');
  1502. element.setAttribute('type', 'textarea');
  1503. element.setAttribute('class', 'ff_elem');
  1504. JQuery(element).focus(appScope.resizableElement);
  1505. options = {value : '', readonly: false};
  1506. break;
  1507. case 'bfCheckbox':
  1508. bfType = 'Checkbox';
  1509. elementType = 'input';
  1510. element = document.createElement(elementType);
  1511. element.setAttribute('id', 'ff_elem' + rndId);
  1512. element.setAttribute('name', 'ff_nm_' + rndId + '[]');
  1513. element.setAttribute('type', 'checkbox');
  1514. element.setAttribute('class', 'ff_elem');
  1515. JQuery(element).click(appScope.resizableElement);
  1516. options = {checked : false, value : 'cb', readonly: false};
  1517. data1 = 'cb';
  1518. break;
  1519. case 'bfRadio':
  1520. bfType = 'Radio Button';
  1521. elementType = 'input';
  1522. element = document.createElement(elementType);
  1523. element.setAttribute('id', 'ff_elem' + rndId);
  1524. element.setAttribute('name', 'ff_nm_' + rndId + '[]');
  1525. element.setAttribute('type', 'radio');
  1526. element.setAttribute('class', 'ff_elem');
  1527. JQuery(element).click(appScope.resizableElement);
  1528. options = {checked : false, value : 'on', readonly: false};
  1529. data1 = 'on';
  1530. break;
  1531. case 'bfSelect':
  1532. bfType = 'Select List';
  1533. elementType = 'select';
  1534. element = document.createElement(elementType);
  1535. element.setAttribute('id', 'ff_elem' + rndId);
  1536. element.setAttribute('name', 'ff_nm_' + rndId + '[]');
  1537. element.setAttribute('class', 'ff_elem');
  1538. JQuery(element).focus(appScope.resizableElement);
  1539. JQuery(element).css('width','110px');
  1540. JQuery(element).css('height','25px');
  1541. options = {multiple : false, options : "1;Select Color;\n0;Red;red\n0;Green;green\n0;Blue;blue", readonly: false, mailback: false};
  1542. data1 = 1;
  1543. data2 = "1;Select Color;\n0;Red;red\n0;Green;green\n0;Blue;blue";
  1544. break;
  1545. case 'bfFile':
  1546. bfType = 'File Upload';
  1547. elementType = 'input';
  1548. element = document.createElement(elementType);
  1549. element.setAttribute('id', 'ff_elem' + rndId);
  1550. element.setAttribute('name', 'ff_nm_' + rndId + '[]');
  1551. element.setAttribute('type', 'file');
  1552. element.setAttribute('class', 'ff_elem');
  1553. JQuery(element).css('height','25px');
  1554. JQuery(element).click(appScope.resizableElement);
  1555. options = {
  1556. uploadDirectory: '{ff_uploads}',
  1557. timestamp: false,
  1558. readonly: false,
  1559. allowedFileExtensions: 'zip,rar,pdf,doc,xls,ppt,jpg,jpeg,gif,png',
  1560. attachToUserMail: false,
  1561. attachToAdminMail: false
  1562. };
  1563. data1 = '{ff_uploads}';
  1564. break;
  1565. case 'bfSubmitButton':
  1566. bfType = 'Regular Button';
  1567. elementType = 'input';
  1568. element = document.createElement(elementType);
  1569. element.setAttribute('id', 'ff_elem' + rndId);
  1570. element.setAttribute('name', 'ff_nm_' + rndId + '[]');
  1571. element.setAttribute('type', 'submit');
  1572. element.setAttribute('class', 'ff_elem');
  1573. JQuery(element).click(appScope.resizableElement);
  1574. JQuery(element).css('padding','0');
  1575. JQuery(element).css('width','176px');
  1576. JQuery(element).css('height','26px');
  1577. options = { readonly: false, value : '' };
  1578. break;
  1579. case 'bfImageButton':
  1580. var iconImage = '<?php echo JURI::root() ?>components/com_breezingforms/images/next.png';
  1581. bfType = 'Graphic Button';
  1582. elementType = 'input';
  1583. element = document.createElement(elementType);
  1584. element.setAttribute('id', 'ff_elem' + rndId);
  1585. element.setAttribute('name', 'ff_nm_' + rndId + '[]');
  1586. element.setAttribute('type', 'image');
  1587. element.setAttribute('class', 'ff_elem');
  1588. element.setAttribute('src', iconImage);
  1589. data1 = iconImage;
  1590. JQuery(element).click(appScope.resizableElement);
  1591. options = { readonly: false, value : '' };
  1592. break;
  1593. case 'bfHidden':
  1594. bfType = 'Hidden Input';
  1595. elementType = 'input';
  1596. element = document.createElement(elementType);
  1597. element.setAttribute('id', 'ff_elem' + rndId);
  1598. element.setAttribute('name', 'ff_nm_' + rndId + '[]');
  1599. element.setAttribute('type', 'hidden');
  1600. element.setAttribute('class', 'ff_elem');
  1601. options = { value: '' };
  1602. break;
  1603. case 'bfTooltip':
  1604. bfType = 'Tooltip';
  1605. elementType = 'img';
  1606. element = document.createElement(elementType);
  1607. element.setAttribute('id', 'ff_elem' + rndId);
  1608. element.setAttribute('name', 'ff_nm_' + rndId + '[]');
  1609. element.setAttribute('class', 'ff_elem');
  1610. element.setAttribute('src', '<?php echo JURI::root() ?>/components/com_breezingforms/images/tooltip.png');
  1611. JQuery(element).click(appScope.resizableElement);
  1612. options = { text: 'Some <em>hint</em> or <strong/>warning</strong> for the user', image: '<?php echo JURI::root() ?>/components/com_breezingforms/images/tooltip.png', type: 'info' };
  1613. data2 = 'Some <em>hint</em> or <strong/>warning</strong> for the user';
  1614. break;
  1615. case 'bfPayPal':
  1616. var iconImage = 'http://www.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif';
  1617. bfType = 'PayPal';
  1618. elementType = 'input';
  1619. element = document.createElement(elementType);
  1620. element.setAttribute('id', 'ff_elem' + rndId);
  1621. element.setAttribute('name', 'ff_nm_' + rndId + '[]');
  1622. element.setAttribute('type', 'image');
  1623. element.setAttribute('class', 'ff_elem');
  1624. element.setAttribute('src', iconImage);
  1625. JQuery(element).css('width','144px');
  1626. JQuery(element).css('height','47px');
  1627. data1 = iconImage;
  1628. JQuery(element).click(appScope.resizableElement);
  1629. options = {
  1630. testaccount: false,
  1631. downloadableFile: false,
  1632. filepath: '',
  1633. downloadTries: 1,
  1634. business: '',
  1635. token: '',
  1636. useIpn: false,
  1637. testBusiness: '',
  1638. testToken: '',
  1639. itemname: '',
  1640. itemnumber: '',
  1641. amount: '',
  1642. tax: '',
  1643. thankYouPage: '<?php echo JURI::root()?>',
  1644. locale: 'us',
  1645. currencyCode: 'USD',
  1646. image: iconImage
  1647. };
  1648. break;
  1649. case 'bfSofortueberweisung':
  1650. var iconImage = '<?php echo JURI::root()?>components/com_breezingforms/images/200x65px.png';
  1651. bfType = 'Sofortueberweisung';
  1652. elementType = 'input';
  1653. element = document.createElement(elementType);
  1654. element.setAttribute('id', 'ff_elem' + rndId);
  1655. element.setAttribute('name', 'ff_nm_' + rndId + '[]');
  1656. element.setAttribute('type', 'image');
  1657. element.setAttribute('class', 'ff_elem');
  1658. element.setAttribute('src', iconImage);
  1659. JQuery(element).css('width','144px');
  1660. JQuery(element).css('height','47px');
  1661. data1 = iconImage;
  1662. JQuery(element).click(appScope.resizableElement);
  1663. options = {
  1664. downloadableFile: false,
  1665. filepath: '',
  1666. downloadTries: 1,
  1667. user_id: '',
  1668. project_id: '',
  1669. project_password: '',
  1670. reason_1: '',
  1671. reason_2: '',
  1672. amount: '',
  1673. thankYouPage: '<?php echo JURI::root()?>',
  1674. language_id: 'DE',
  1675. currency_id: 'EUR',
  1676. image: iconImage,
  1677. mailback : false
  1678. };
  1679. break;
  1680. }
  1681. JQuery(element).css('border','none');
  1682. return { element: element,
  1683. bfType: bfType,
  1684. elementType: elementType,
  1685. data1: data1,
  1686. data2: data2,
  1687. data3: data3,
  1688. script1cond: script1cond,
  1689. script1id: script1id,
  1690. script1code: script1code,
  1691. script1flag1: script1flag1,
  1692. script1flag2: script1flag2,
  1693. script2cond: script2cond,
  1694. script2id: script2id,
  1695. script2code: script2code,
  1696. script2flag1: script2flag1,
  1697. script2flag2: script2flag2,
  1698. script2flag3: script2flag3,
  1699. script2flag4: script2flag4,
  1700. script2flag5: script2flag5,
  1701. script3cond: script3cond,
  1702. script3id: script3id,
  1703. script3code: script3code,
  1704. script3msg: script3msg,
  1705. functionNameScript1: functionNameScript1,
  1706. functionNameScript2: functionNameScript2,
  1707. functionNameScript3: functionNameScript3,
  1708. flag1 : flag1,
  1709. flag2 : flag2,
  1710. mailback: mailback,
  1711. mailbackfile: mailbackfile,
  1712. options: options
  1713. };
  1714. };
  1715. this.initMouseOvers = function(){
  1716. JQuery('.ff_div').mouseover(function(){
  1717. JQuery('.ff_div').css('border','none');
  1718. JQuery(this).css('border', '1px dotted #000');
  1719. JQuery('.ff_div').children('.ff_label').children('.ui-resizable-se').css('display', 'none');
  1720. JQuery('.ff_div').children('.ui-wrapper').children('.ui-resizable-se').css('display', 'none');
  1721. JQuery('.ff_div').children('.ff_elem').children('.ui-resizable-se').css('display', 'none');
  1722. if(JQuery(this).children('.ff_label').length != 0){
  1723. var label = JQuery(JQuery(this).children('.ff_label')[0]);
  1724. var labres = JQuery(label.children('.ui-resizable-se')[0]);
  1725. labres.css('display', '');
  1726. }
  1727. if(JQuery(this).children('.ui-wrapper').length != 0){
  1728. var wrapper = JQuery(JQuery(this).children('.ui-wrapper')[0]);
  1729. var res = JQuery(wrapper.children('.ui-resizable-se')[0]);
  1730. res.css('display', 'block');
  1731. wrapper.css('padding-bottom', '-13px');
  1732. if(wrapper.children('.ff_elem').length != 0){
  1733. var elem = JQuery(wrapper.children('.ff_elem')[0]);
  1734. //elem.css('padding','0');
  1735. elem.css('border','none');
  1736. }
  1737. } else if(JQuery(this).children('.ff_elem').length != 0){
  1738. var elem = JQuery(JQuery(this).children('.ff_elem')[0]);
  1739. elem.children('.ui-resizable-se').css('display', '');
  1740. elem.css('border','none');
  1741. }
  1742. });
  1743. JQuery('.ff_div').bind('mouseleave',function(){
  1744. JQuery(this).css('border', 'none');
  1745. if(JQuery(this).children('.ff_label').length != 0){
  1746. var label = JQuery(JQuery(this).children('.ff_label')[0]);
  1747. var labres = JQuery(label.children('.ui-resizable-se')[0]);
  1748. labres.css('display', 'none');
  1749. }
  1750. if(JQuery(this).children('.ui-wrapper').length != 0){
  1751. var wrapper = JQuery(JQuery(this).children('.ui-wrapper')[0]);
  1752. var res = JQuery(wrapper.children('.ui-resizable-se')[0]);
  1753. res.css('display', 'none');
  1754. wrapper.css('padding-bottom', '0px');
  1755. if(wrapper.children('.ff_elem').length != 0){
  1756. var elem = JQuery(wrapper.children('.ff_elem')[0]);
  1757. //elem.css('padding','0');
  1758. elem.css('border','none');
  1759. }
  1760. } else if(JQuery(this).children('.ff_elem').length != 0){
  1761. var elem = JQuery(JQuery(this).children('.ff_elem')[0]);
  1762. elem.children('.ui-resizable-se').css('display', 'none');
  1763. elem.css('border','none');
  1764. }
  1765. });
  1766. JQuery('.ui-wrapper').mouseover(function(){
  1767. JQuery(this).css('border', '1px dotted #000');
  1768. });
  1769. JQuery('.ui-wrapper').mouseout(function(){
  1770. JQuery(this).css('border', 'none');
  1771. });
  1772. JQuery('.ff_label').mouseover(function(){
  1773. JQuery(this).css('border', '1px dotted #000');
  1774. });
  1775. JQuery('.ff_label').mouseout(function(){
  1776. JQuery(this).css('border', 'none');
  1777. });
  1778. };
  1779. this.refreshBatchOptions = function(){
  1780. JQuery('#bfBatchLabels').empty();
  1781. JQuery('#bfBatchElements').empty();
  1782. for(var i = 0; i < appScope.areaList.length; i++){
  1783. for(var j = 0; j < appScope.areaList[i].elements.length;j++){
  1784. var element = appScope.areaList[i].elements[j]
  1785. var labelsResult = JQuery('#'+element.id).parent().parent().children('.ff_label');
  1786. if(labelsResult.length != 0){
  1787. for(var k = 0; k < labelsResult.length;k++){
  1788. var batchLabel = document.createElement('option');
  1789. JQuery(batchLabel).val(labelsResult[k].id);
  1790. JQuery(batchLabel).text(stripHTML( JQuery('#'+labelsResult[k].id).html() ) );
  1791. JQuery('#bfBatchLabels').append(batchLabel);
  1792. }
  1793. }
  1794. labelsResult = JQuery('#'+element.id).parent().children('.ff_label');
  1795. if(labelsResult.length != 0){
  1796. for(var k = 0; k < labelsResult.length;k++){
  1797. var batchLabel = document.createElement('option');
  1798. JQuery(batchLabel).val(labelsResult[k].id);
  1799. JQuery(batchLabel).text(stripHTML( JQuery('#'+labelsResult[k].id).html() ) );
  1800. JQuery('#bfBatchLabels').append(batchLabel);
  1801. }
  1802. }
  1803. if(element.internalType != 'bfHidden'){
  1804. var batchElement = document.createElement('option');
  1805. JQuery(batchElement).val(element.id);
  1806. JQuery(batchElement).text(element.name);
  1807. JQuery('#bfBatchElements').append(batchElement);
  1808. }
  1809. }
  1810. }
  1811. };
  1812. /**
  1813. * JQuery initalizations
  1814. */
  1815. appScope.initMouseOvers();
  1816. JQuery('.attachToAdminMail').remove();
  1817. JQuery('.attachToUserMail').remove();
  1818. JQuery('.mailbackConnectWith').remove();
  1819. JQuery('.mailbackSender').remove();
  1820. JQuery('#bfUpdateTemplateButton').click(function(){
  1821. JQuery('#bfTemplate').get(0).innerHTML = JQuery.trim(JQuery('#bfTemplateBox').val());
  1822. submitbutton('save');
  1823. });
  1824. JQuery('.ff_elem').css('border','none');
  1825. JQuery('.ff_div').children('.ff_label').children('.ui-resizable-se').css('display', 'none');
  1826. JQuery('.ff_div').children('.ui-wrapper').children('.ui-resizable-se').css('display', 'none');
  1827. JQuery('.ff_div').children('.ff_elem').children('.ui-resizable-se').css('display', 'none');
  1828. JQuery('.ff_div').children('.ui-wrapper').css('padding-bottom','0px');
  1829. JQuery('.ff_elem').click(this.resizableElement);
  1830. JQuery('.ff_elem').focus(this.resizableElement);
  1831. JQuery('.ui-resizable-se').click(this.resizableElement);
  1832. JQuery('.ff_label').click(this.resizableElement);
  1833. JQuery("#menutab").tabs( { select: function(e, ui){ } } );
  1834. JQuery("#nestedaccordion").accordion({autoHeight:false, collapsible: true, change: function(e, ui){
  1835. appScope.refreshTemplateBox();
  1836. }});
  1837. JQuery("#nestedaccordion2").accordion({autoHeight:false, collapsible: true, change: function(e, ui){
  1838. appScope.refreshTemplateBox();
  1839. }});
  1840. JQuery("#nestedaccordion3").accordion({autoHeight:false, collapsible: true, change: function(e, ui){
  1841. appScope.refreshTemplateBox();
  1842. }});
  1843. JQuery('#bfBatchButton').click(function(){
  1844. var width = JQuery.trim(JQuery('#bfBatchWidth').val());
  1845. var height = JQuery.trim(JQuery('#bfBatchHeight').val());
  1846. var padding = JQuery.trim(JQuery('#bfBatchPadding').val());
  1847. var margin = JQuery.trim(JQuery('#bfBatchMargin').val());
  1848. JQuery('#bfBatchLabels :selected').each(function(i, selected){
  1849. var label = JQuery('#'+JQuery(selected).val());
  1850. if(width != ''){
  1851. label.css('width', width);
  1852. }
  1853. if(height != ''){
  1854. label.css('height', height);
  1855. }
  1856. if(padding != ''){
  1857. label.css('padding', padding);
  1858. }
  1859. if(margin != ''){
  1860. label.css('margin', margin);
  1861. }
  1862. });
  1863. JQuery('#bfBatchElements :selected').each(function(i, selected){
  1864. var element = JQuery('#'+JQuery(selected).val());
  1865. if(width != ''){
  1866. element.css('width', width);
  1867. }
  1868. if(height != ''){
  1869. element.css('height', height);
  1870. }
  1871. if(padding != ''){
  1872. element.css('padding', padding);
  1873. }
  1874. if(margin != ''){
  1875. element.css('margin', margin);
  1876. }
  1877. if(JQuery('#'+JQuery(selected).val()).parent().attr('class') == 'ui-wrapper'){
  1878. element = JQuery('#'+JQuery(selected).val()).parent();
  1879. if(width != ''){
  1880. element.css('width', width);
  1881. }
  1882. if(height != ''){
  1883. element.css('height', height);
  1884. }
  1885. if(padding != ''){
  1886. element.css('padding', padding);
  1887. }
  1888. if(margin != ''){
  1889. element.css('margin', margin);
  1890. }
  1891. }
  1892. });
  1893. });
  1894. JQuery('#bfUpdatePixelRaster').click(
  1895. function(){
  1896. appScope.pixelRaster = parseInt(JQuery('#bfPixelRaster').val());
  1897. submitbutton('save');
  1898. }
  1899. );
  1900. JQuery('#bfGoToPage').change(
  1901. function(){
  1902. if(parseInt(JQuery(this).val()) > 0){
  1903. document.adminForm.page.value = JQuery(this).val();
  1904. submitbutton('save');
  1905. }
  1906. }
  1907. );
  1908. JQuery('#bfMoveThisPageTo').change(
  1909. function(){
  1910. if(parseInt(JQuery(this).val()) > 0){
  1911. if(parseInt(JQuery(this).val()) == 1){
  1912. JQuery('#bfPage'+JQuery(this).val()).before( JQuery('#bfPage'+document.adminForm.page.value).get(0) );
  1913. } else {
  1914. JQuery('#bfPage'+JQuery(this).val()).after( JQuery('#bfPage'+document.adminForm.page.value).get(0) );
  1915. }
  1916. var children = JQuery('#bfTemplate').children('.bfPage');
  1917. var clength = children.length;
  1918. for(var i = 0; i < clength;i++){
  1919. JQuery(children[i]).get(0).setAttribute('id', 'bfPage' + (i+1));
  1920. }
  1921. var idbag = {};
  1922. for(var i = 0; i < JQuery('#bfTemplate').children('.bfPage').length;i++){
  1923. var page = JQuery('#bfTemplate').children('.bfPage')[i];
  1924. for(var j = 0; j < JQuery(page).find('.ff_elem').length;j++){
  1925. idbag[JQuery(page).find('.ff_elem')[j].id] = (i+1);
  1926. }
  1927. }
  1928. for(var i = 0; i < appScope.areaList.length; i++){
  1929. for(var j = 0; j < appScope.areaList[i].elements.length;j++){
  1930. if( idbag[appScope.areaList[i].elements[j].id] ){
  1931. appScope.areaList[i].elements[j].page = idbag[appScope.areaList[i].elements[j].id];
  1932. break;
  1933. }
  1934. }
  1935. }
  1936. document.adminForm.page.value = parseInt(JQuery(this).val());
  1937. submitbutton('save');
  1938. };
  1939. }
  1940. );
  1941. JQuery('#bfDeleteThisPage').click(
  1942. function(){
  1943. if(!confirm('<?php echo BFText::_('COM_BREEZINGFORMS_ARE_YOU_SURE_TO_DELETE_THIS_PAGE') ?>')){
  1944. return;
  1945. }
  1946. var areaToRemove = null;
  1947. for(var i = 0; i < appScope.areaList.length; i++){
  1948. for(var j = 0; j < appScope.areaList[i].elements.length;j++){
  1949. if(appScope.areaList[i].elements[j].page == document.adminForm.page.value){
  1950. areaToRemove = appScope.areaList[i];
  1951. break;
  1952. }
  1953. }
  1954. }
  1955. if(areaToRemove != null){
  1956. var newAreaList = new Array();
  1957. for(var i = 0; i < appScope.areaList.length; i++){
  1958. if(areaToRemove.area.id != appScope.areaList[i].area.id){
  1959. newAreaList.push(appScope.areaList[i]);
  1960. }
  1961. }
  1962. appScope.areaList = newAreaList;
  1963. }
  1964. JQuery('#bfPage'+document.adminForm.page.value).remove();
  1965. var children = JQuery('#bfTemplate').children('.bfPage');
  1966. var clength = children.length;
  1967. for(var i = 0; i < clength;i++){
  1968. JQuery(children[i]).get(0).setAttribute('id', 'bfPage' + (i+1));
  1969. }
  1970. var idbag = {};
  1971. for(var i = 0; i < JQuery('#bfTemplate').children('.bfPage').length;i++){
  1972. var page = JQuery('#bfTemplate').children('.bfPage')[i];
  1973. for(var j = 0; j < JQuery(page).find('.ff_elem').length;j++){
  1974. idbag[JQuery(page).find('.ff_elem')[j].id] = (i+1);
  1975. }
  1976. }
  1977. for(var i = 0; i < appScope.areaList.length; i++){
  1978. for(var j = 0; j < appScope.areaList[i].elements.length;j++){
  1979. if( idbag[appScope.areaList[i].elements[j].id] ){
  1980. appScope.areaList[i].elements[j].page = idbag[appScope.areaList[i].elements[j].id];
  1981. break;
  1982. }
  1983. }
  1984. }
  1985. document.adminForm.page.value = 1;
  1986. document.adminForm.pages.value = parseInt(document.adminForm.pages.value) - 1;
  1987. submitbutton('save');
  1988. }
  1989. );
  1990. JQuery('#bfCreatePage').click(
  1991. function(){
  1992. if(JQuery('#bfTemplate').children('.bfPage').length == 0){
  1993. var page = document.createElement('span');
  1994. page.setAttribute('class', 'bfPage');
  1995. page.setAttribute('id', 'bfPage1');
  1996. if(JQuery('#bfTemplate').children('*').length == 0){
  1997. var area = document.createElement('ul');
  1998. area.setAttribute('class', 'droppableArea');
  1999. area.setAttribute('id', 'drop1');
  2000. JQuery(page).append(area);
  2001. JQuery('#bfTemplate').append(page);
  2002. appScope.areaList.push( { area : JQuery(area).get(0), elements : [] } );
  2003. document.adminForm.pages.value = 1;
  2004. submitbutton('save');
  2005. } else {
  2006. var children = JQuery('#bfTemplate').children('*');
  2007. var tlength = children.length;
  2008. for(var i = 0; i<tlength;i++ ){
  2009. JQuery(page).append(children[i]);
  2010. }
  2011. JQuery('#bfTemplate').append(page);
  2012. document.adminForm.pages.value = 1;
  2013. }
  2014. } else {
  2015. //rearranging the page numbers
  2016. var children = JQuery('#bfTemplate').children('.bfPage');
  2017. var clength = children.length;
  2018. for(var i = 0; i < clength;i++){
  2019. JQuery(children[i]).get(0).setAttribute('id', 'bfPage' + (i+1));
  2020. }
  2021. var page = document.createElement('span');
  2022. page.setAttribute('class', 'bfPage');
  2023. page.setAttribute('id', 'bfPage'+(clength+1));
  2024. var area = document.createElement('ul');
  2025. appScope.areaList.push( { area : JQuery(area).get(0), elements : [] } );
  2026. area.setAttribute('class', 'droppableArea');
  2027. if(!JQuery('#'+'drop'+(JQuery('.droppableArea').length + 1)).get(0)){
  2028. area.setAttribute('id', 'drop'+(JQuery('.droppableArea').length + 1));
  2029. } else {
  2030. // trying random drop name if the id already exists
  2031. var rndId = JQuery.md5("rnd" + Math.random() + (clength+1));
  2032. area.setAttribute('id', 'drop'+rndId);
  2033. }
  2034. JQuery(page).append(area);
  2035. JQuery('#bfTemplate').append(page);
  2036. document.adminForm.pages.value = clength + 1;
  2037. submitbutton('save');
  2038. }
  2039. }
  2040. );
  2041. JQuery('#bfRemoveLabelButton').click(
  2042. function(){
  2043. JQuery(JQuery('#'+appScope.optionElement.id).parent().children('.ff_break')[0]).remove();
  2044. JQuery('#'+appScope.optionElement.id).remove();
  2045. appScope.disableElementsDetails();
  2046. }
  2047. );
  2048. JQuery('#bfInitButton').click(
  2049. function(){
  2050. if(JQuery('#script1flag1').get(0).checked){
  2051. appScope.optionElement.script1flag1 = 1;
  2052. } else {
  2053. appScope.optionElement.script1flag1 = 0;
  2054. }
  2055. if(JQuery('#script1flag2').get(0).checked){
  2056. appScope.optionElement.script1flag2 = 1;
  2057. } else {
  2058. appScope.optionElement.script1flag2 = 0;
  2059. }
  2060. appScope.optionElement.script1id = JQuery('#bfInitScriptSelection').val();
  2061. appScope.optionElement.script1code = JQuery('#script1code').val();
  2062. if(JQuery('#bfInitTypeLibrary').get(0).checked){
  2063. appScope.optionElement.script1cond = 1;
  2064. for(var i = 0; i < appScope.elementScripts.init.length;i++){
  2065. if(appScope.elementScripts.init[i].id == JQuery('#bfInitScriptSelection').val()){
  2066. appScope.optionElement.functionNameScript1 = appScope.elementScripts.init[i].name;
  2067. break;
  2068. }
  2069. }
  2070. } else if(JQuery('#bfInitTypeCustom').get(0).checked){
  2071. appScope.optionElement.script1cond = 2;
  2072. appScope.optionElement.functionNameScript1 = 'ff_' + appScope.optionElement.name + '_init';
  2073. } else {
  2074. appScope.optionElement.script1cond = 0;
  2075. }
  2076. JQuery('.bfScriptsSaveMessage').css('display','');
  2077. JQuery('.bfScriptsSaveMessage').empty().append('<?php echo BFText::_('COM_BREEZINGFORMS_SCRIPT_SAVED_TO_FINALLY_SAVE_YOUR_FORM_CLICK_SAVE_ON_THE_TOP_RIGHT_BUTTON') ?><br/><br/>');
  2078. }
  2079. );
  2080. JQuery('#bfActionButton').click(
  2081. function(){
  2082. if(JQuery('#script2flag1').get(0).checked){
  2083. appScope.optionElement.script2flag1 = 1;
  2084. } else {
  2085. appScope.optionElement.script2flag1 = 0;
  2086. }
  2087. if(JQuery('#script2flag2').get(0).checked){
  2088. appScope.optionElement.script2flag2 = 1;
  2089. } else {
  2090. appScope.optionElement.script2flag2 = 0;
  2091. }
  2092. if(JQuery('#script2flag3').get(0).checked){
  2093. appScope.optionElement.script2flag3 = 1;
  2094. } else {
  2095. appScope.optionElement.script2flag3 = 0;
  2096. }
  2097. if(JQuery('#script2flag4').get(0).checked){
  2098. appScope.optionElement.script2flag4 = 1;
  2099. } else {
  2100. appScope.optionElement.script2flag4 = 0;
  2101. }
  2102. if(JQuery('#script2flag5').get(0).checked){
  2103. appScope.optionElement.script2flag5 = 1;
  2104. } else {
  2105. appScope.optionElement.script2flag5 = 0;
  2106. }
  2107. appScope.optionElement.script2id = JQuery('#bfActionsScriptSelection').val();
  2108. appScope.optionElement.script2code = JQuery('#script2code').val();
  2109. if(JQuery('#bfActionTypeLibrary').get(0).checked){
  2110. appScope.optionElement.script2cond = 1;
  2111. for(var i = 0; i < appScope.elementScripts.action.length;i++){
  2112. if(appScope.elementScripts.action[i].id == JQuery('#bfActionsScriptSelection').val()){
  2113. appScope.optionElement.functionNameScript2 = appScope.elementScripts.action[i].name;
  2114. break;
  2115. }
  2116. }
  2117. } else if(JQuery('#bfActionTypeCustom').get(0).checked){
  2118. appScope.optionElement.script2cond = 2;
  2119. appScope.optionElement.functionNameScript2 = 'ff_' + appScope.optionElement.name + '_action';
  2120. } else {
  2121. appScope.optionElement.script2cond = 0;
  2122. }
  2123. JQuery('.bfScriptsSaveMessage').css('display','');
  2124. JQuery('.bfScriptsSaveMessage').empty().append('<?php echo BFText::_('COM_BREEZINGFORMS_SCRIPT_SAVED_TO_FINALLY_SAVE_YOUR_FORM_CLICK_SAVE_ON_THE_TOP_RIGHT_BUTTON') ?><br/><br/>');
  2125. }
  2126. );
  2127. JQuery('#bfValidationButton').click(
  2128. function(){
  2129. appScope.optionElement.script3id = JQuery('#bfValidationScriptSelection').val();
  2130. appScope.optionElement.script3code = JQuery('#script3code').val();
  2131. appScope.optionElement.script3msg = JQuery('#script3msg').val();
  2132. if(JQuery('#bfValidationTypeLibrary').get(0).checked){
  2133. appScope.optionElement.script3cond = 1;
  2134. for(var i = 0; i < appScope.elementScripts.validation.length;i++){
  2135. if(appScope.elementScripts.validation[i].id == JQuery('#bfValidationScriptSelection').val()){
  2136. appScope.optionElement.functionNameScript3 = appScope.elementScripts.validation[i].name;
  2137. break;
  2138. }
  2139. }
  2140. } else if(JQuery('#bfValidationTypeCustom').get(0).checked){
  2141. appScope.optionElement.script3cond = 2;
  2142. appScope.optionElement.functionNameScript3 = 'ff_' + appScope.optionElement.name + '_validation';
  2143. } else {
  2144. appScope.optionElement.script3cond = 0;
  2145. }
  2146. JQuery('.bfScriptsSaveMessage').css('display','');
  2147. JQuery('.bfScriptsSaveMessage').empty().append('<?php echo BFText::_('COM_BREEZINGFORMS_SCRIPT_SAVED_TO_FINALLY_SAVE_YOUR_FORM_CLICK_SAVE_ON_THE_TOP_RIGHT_BUTTON') ?><br/><br/>');
  2148. }
  2149. );
  2150. JQuery('#bfSaveOptionsButton').click(
  2151. function(){
  2152. var error = '';
  2153. if(appScope.optionElement.internalType){
  2154. switch(appScope.optionElement.internalType){
  2155. case 'bfCalendar':
  2156. appScope.optionElement.options.format = JQuery.trim(JQuery('#bfCalendarFormat').get(0).value);
  2157. appScope.optionElement.options.connectWith = JQuery.trim(JQuery('#bfCalendarConnectWith').get(0).value);
  2158. JQuery('#'+appScope.optionElement.id).resizable('destroy');
  2159. JQuery('#'+appScope.optionElement.id).get(0).innerHTML = JQuery.trim(JQuery('#bfCalendarText').get(0).value);
  2160. appScope.setElementResizable(JQuery('#'+appScope.optionElement.id).get(0));
  2161. break;
  2162. case 'bfCaptcha':
  2163. JQuery('.ff_captcha')[0].style.width = JQuery.trim(JQuery('#bfCaptchaWidth').get(0).value);
  2164. JQuery('.ff_captcha')[0].style.height = JQuery.trim(JQuery('#bfCaptchaHeight').get(0).value);
  2165. break;
  2166. case 'bfStaticText':
  2167. if(JQuery.trim(JQuery('#bfStaticTextTitle').get(0).value) == ''){
  2168. error = '<?php echo BFText::_('COM_BREEZINGFORMS_TITLE_MUST_NOT_BE_EMPTY') ?>';
  2169. }
  2170. if(JQuery.trim(JQuery('#bfStaticTextContent').get(0).value) == ''){
  2171. error = 'Content must not be empty!';
  2172. }
  2173. if(error == ''){
  2174. appScope.optionElement.title = JQuery.trim(JQuery('#bfStaticTextTitle').get(0).value);
  2175. JQuery('#'+appScope.optionElement.id).resizable('destroy');
  2176. JQuery('#'+appScope.optionElement.id).get(0).innerHTML = JQuery.trim(JQuery('#bfStaticTextContent').get(0).value);
  2177. appScope.setElementResizable(JQuery('#'+appScope.optionElement.id).get(0));
  2178. JQuery('#'+appScope.optionElement.id).get(0).style.width = JQuery.trim(JQuery('#bfStaticTextWidth').get(0).value);
  2179. JQuery('#'+appScope.optionElement.id).get(0).style.height = JQuery.trim(JQuery('#bfStaticTextHeight').get(0).value);
  2180. }
  2181. break;
  2182. case 'bfIcon':
  2183. if(JQuery.trim(JQuery('#bfIconCaption').get(0).value) == ''){
  2184. error = '<?php echo BFText::_('COM_BREEZINGFORMS_CAPTION_MUST_NOT_BE_EMPTY') ?>';
  2185. }
  2186. if(JQuery.trim(JQuery('#bfIconImage').get(0).value) == ''){
  2187. error = '<?php echo BFText::_('COM_BREEZINGFORMS_ICON_IMAGE_MUST_NOT_BE_EMPTY') ?>';
  2188. }
  2189. if(JQuery.trim(JQuery('#bfIconImageOver').get(0).value) == ''){
  2190. error = '<?php echo BFText::_('COM_BREEZINGFORMS_ICON_IMAGE_OVER_MUST_NOT_BE_EMPTY') ?>';
  2191. }
  2192. if(error == ''){
  2193. appScope.optionElement.title = JQuery.trim(JQuery('#bfIconCaption').get(0).value);
  2194. JQuery('#'+appScope.optionElement.id).children('.ff_iconCaption')[0].innerHTML = JQuery.trim(JQuery('#bfIconCaption').get(0).value);
  2195. JQuery('#'+appScope.optionElement.id).get(0).style.width = JQuery.trim(JQuery('#bfIconWidth').get(0).value);
  2196. JQuery('#'+appScope.optionElement.id).get(0).style.height = JQuery.trim(JQuery('#bfIconHeight').get(0).value);
  2197. JQuery('#'+appScope.optionElement.id).children('.ff_icon')[0].setAttribute('src', JQuery.trim(JQuery('#bfIconImage').get(0).value));
  2198. }
  2199. break;
  2200. case 'bfTextfield':
  2201. if(JQuery.trim(JQuery('#bfTextfieldTitle').get(0).value) == '')
  2202. {
  2203. error = '<?php echo BFText::_('COM_BREEZINGFORMS_TITLE_MUST_NOT_BE_EMPTY') ?>';
  2204. }
  2205. if(JQuery.trim(JQuery('#bfTextfieldName').get(0).value) == '')
  2206. {
  2207. error = '<?php echo BFText::_('COM_BREEZINGFORMS_NAME_MUST_NOT_BE_EMPTY') ?>';
  2208. }
  2209. if(error == ''){
  2210. appScope.optionElement.title = JQuery.trim(JQuery('#bfTextfieldTitle').get(0).value);
  2211. appScope.optionElement.name = JQuery.trim(JQuery('#bfTextfieldName').get(0).value);
  2212. JQuery('#'+appScope.optionElement.id).get(0).setAttribute('value', JQuery.trim(JQuery('#bfTextfieldValue').get(0).value));
  2213. JQuery('#'+appScope.optionElement.id).get(0).value = JQuery.trim(JQuery('#bfTextfieldValue').get(0).value);
  2214. appScope.optionElement.options.value = JQuery.trim(JQuery('#bfTextfieldValue').get(0).value);
  2215. JQuery('#'+appScope.optionElement.id).get(0).style.width = JQuery.trim(JQuery('#bfTextfieldWidth').get(0).value);
  2216. JQuery('#'+appScope.optionElement.id).get(0).style.height = JQuery.trim(JQuery('#bfTextfieldHeight').get(0).value);
  2217. if(JQuery.trim(JQuery('#bfTextfieldMaxlength').get(0).value) == ''){
  2218. JQuery('#'+appScope.optionElement.id).get(0).removeAttribute('maxlength');
  2219. } else {
  2220. JQuery('#'+appScope.optionElement.id).get(0).setAttribute('maxlength', JQuery.trim(JQuery('#bfTextfieldMaxlength').get(0).value));
  2221. }
  2222. if(JQuery('#bfTextfieldDisable').get(0).checked){
  2223. appScope.optionElement.flag2 = 1;
  2224. JQuery('#'+appScope.optionElement.id).get(0).setAttribute('readonly', 'readonly');
  2225. appScope.optionElement.options.readonly = true;
  2226. } else {
  2227. appScope.optionElement.flag2 = 0;
  2228. JQuery('#'+appScope.optionElement.id).get(0).setAttribute('readonly', '');
  2229. JQuery('#'+appScope.optionElement.id).get(0).removeAttribute('readonly');
  2230. appScope.optionElement.options.readonly = false;
  2231. }
  2232. if(JQuery('#bfTextfieldPassword').get(0).checked){
  2233. appScope.optionElement.flag1 = 1;
  2234. appScope.optionElement.options.password = true;
  2235. JQuery('#'+appScope.optionElement.id).get(0).setAttribute('type', 'password');
  2236. } else {
  2237. appScope.optionElement.options.password = false;
  2238. appScope.optionElement.flag1 = 0;
  2239. JQuery('#'+appScope.optionElement.id).get(0).setAttribute('type', 'text');
  2240. }
  2241. if(JQuery('#bfTextfieldMailback').get(0).checked){
  2242. appScope.optionElement.mailback = 1;
  2243. appScope.optionElement.options.mailback = true;
  2244. } else {
  2245. appScope.optionElement.options.mailback = false;
  2246. appScope.optionElement.mailback = 0;
  2247. }
  2248. if(JQuery('#bfTextfieldMailbackAsSender').get(0).checked){
  2249. appScope.optionElement.mailbackAsSender = true;
  2250. } else {
  2251. appScope.optionElement.mailbackAsSender = false;
  2252. }
  2253. appScope.optionElement.mailbackfile = JQuery('#bfTextfieldMailbackfile').get(0).value;
  2254. }
  2255. break;
  2256. case 'bfTextarea':
  2257. if(JQuery.trim(JQuery('#bfTextareaTitle').get(0).value) == '')
  2258. {
  2259. error = '<?php echo BFText::_('COM_BREEZINGFORMS_TITLE_MUST_NOT_BE_EMPTY') ?>';
  2260. }
  2261. if(JQuery.trim(JQuery('#bfTextareaName').get(0).value) == '')
  2262. {
  2263. error = '<?php echo BFText::_('COM_BREEZINGFORMS_NAME_MUST_NOT_BE_EMPTY') ?>';
  2264. }
  2265. if(error == ''){
  2266. appScope.optionElement.title = JQuery.trim(JQuery('#bfTextareaTitle').get(0).value);
  2267. appScope.optionElement.name = JQuery.trim(JQuery('#bfTextareaName').get(0).value);
  2268. appScope.optionElement.options.value = JQuery.trim(JQuery('#bfTextareaValue').get(0).value);
  2269. JQuery('#'+appScope.optionElement.id).get(0).value = JQuery.trim(JQuery('#bfTextareaValue').get(0).value);
  2270. JQuery('#'+appScope.optionElement.id).get(0).defaultValue = JQuery.trim(JQuery('#bfTextareaValue').get(0).value);
  2271. JQuery('#'+appScope.optionElement.id).get(0).style.width = JQuery.trim(JQuery('#bfTextareaWidth').get(0).value);
  2272. JQuery('#'+appScope.optionElement.id).get(0).style.height = JQuery.trim(JQuery('#bfTextareaHeight').get(0).value);
  2273. if(JQuery('#bfTextareaDisable').get(0).checked){
  2274. appScope.optionElement.flag2 = 1;
  2275. JQuery('#'+appScope.optionElement.id).get(0).setAttribute('readonly', 'readonly');
  2276. appScope.optionElement.options.readonly = true;
  2277. } else {
  2278. appScope.optionElement.flag2 = 0;
  2279. JQuery('#'+appScope.optionElement.id).get(0).setAttribute('readonly', '');
  2280. JQuery('#'+appScope.optionElement.id).get(0).removeAttribute('readonly');
  2281. appScope.optionElement.options.readonly = false;
  2282. }
  2283. }
  2284. break;
  2285. case 'bfCheckbox':
  2286. if(JQuery.trim(JQuery('#bfCheckboxTitle').get(0).value) == '')
  2287. {
  2288. error = '<?php echo BFText::_('COM_BREEZINGFORMS_TITLE_MUST_NOT_BE_EMPTY') ?>';
  2289. }
  2290. if(JQuery.trim(JQuery('#bfCheckboxName').get(0).value) == '')
  2291. {
  2292. error = '<?php echo BFText::_('COM_BREEZINGFORMS_NAME_MUST_NOT_BE_EMPTY') ?>';
  2293. }
  2294. if(error == ''){
  2295. appScope.optionElement.title = JQuery.trim(JQuery('#bfCheckboxTitle').get(0).value);
  2296. appScope.optionElement.name = JQuery.trim(JQuery('#bfCheckboxName').get(0).value);
  2297. appScope.optionElement.options.checked = JQuery('#bfCheckboxChecked').get(0).checked;
  2298. JQuery('#'+appScope.optionElement.id).get(0).checked = JQuery('#bfCheckboxChecked').get(0).checked;
  2299. if(JQuery('#bfCheckboxChecked').get(0).checked){
  2300. appScope.optionElement.options.checked = true;
  2301. appScope.optionElement.flag1 = 1;
  2302. JQuery('#'+appScope.optionElement.id).attr('checked', true);
  2303. } else {
  2304. appScope.optionElement.flag1 = 0;
  2305. JQuery('#'+appScope.optionElement.id).attr('checked', false);
  2306. appScope.optionElement.options.checked = false;
  2307. }
  2308. appScope.optionElement.options.value = JQuery.trim(JQuery('#bfCheckboxValue').get(0).value);
  2309. appScope.optionElement.data1 = JQuery.trim(JQuery('#bfCheckboxValue').get(0).value);
  2310. JQuery('#'+appScope.optionElement.id).get(0).value = JQuery.trim(JQuery('#bfCheckboxValue').get(0).value);
  2311. JQuery('#'+appScope.optionElement.id).get(0).style.width = JQuery.trim(JQuery('#bfCheckboxWidth').get(0).value);
  2312. JQuery('#'+appScope.optionElement.id).get(0).style.height = JQuery.trim(JQuery('#bfCheckboxHeight').get(0).value);
  2313. if(JQuery('#bfCheckboxDisable').get(0).checked){
  2314. appScope.optionElement.flag2 = 1;
  2315. JQuery('#'+appScope.optionElement.id).get(0).setAttribute('readonly', 'readonly');
  2316. appScope.optionElement.options.readonly = true;
  2317. } else {
  2318. appScope.optionElement.flag2 = 0;
  2319. JQuery('#'+appScope.optionElement.id).get(0).setAttribute('readonly', '');
  2320. JQuery('#'+appScope.optionElement.id).get(0).removeAttribute('readonly');
  2321. appScope.optionElement.options.readonly = false;
  2322. }
  2323. if(JQuery('#bfCheckboxMailbackAccept').get(0).checked){
  2324. appScope.optionElement.mailbackAccept = true;
  2325. } else {
  2326. appScope.optionElement.mailbackAccept = false;
  2327. }
  2328. appScope.optionElement.mailbackAcceptConnectWith = JQuery('#bfCheckboxMailbackAcceptConnectWith').val();
  2329. }
  2330. break;
  2331. case 'bfRadio':
  2332. if(JQuery.trim(JQuery('#bfRadioTitle').get(0).value) == '')
  2333. {
  2334. error = '<?php echo BFText::_('COM_BREEZINGFORMS_TITLE_MUST_NOT_BE_EMPTY') ?>';
  2335. }
  2336. if(JQuery.trim(JQuery('#bfRadioName').get(0).value) == '')
  2337. {
  2338. error = '<?php echo BFText::_('COM_BREEZINGFORMS_NAME_MUST_NOT_BE_EMPTY') ?>';
  2339. }
  2340. if(error == ''){
  2341. appScope.optionElement.title = JQuery.trim(JQuery('#bfRadioTitle').get(0).value);
  2342. appScope.optionElement.name = JQuery.trim(JQuery('#bfRadioName').get(0).value);
  2343. appScope.optionElement.options.checked = JQuery('#bfRadioChecked').get(0).checked;
  2344. JQuery('#'+appScope.optionElement.id).get(0).checked = JQuery('#bfRadioChecked').get(0).checked;
  2345. if(JQuery('#bfRadioChecked').get(0).checked){
  2346. appScope.optionElement.flag1 = 1;
  2347. JQuery('#'+appScope.optionElement.id).attr('checked', true);
  2348. } else {
  2349. appScope.optionElement.flag1 = 0;
  2350. JQuery('#'+appScope.optionElement.id).attr('checked', false);
  2351. }
  2352. appScope.optionElement.options.value = JQuery.trim(JQuery('#bfRadioValue').get(0).value);
  2353. JQuery('#'+appScope.optionElement.id).get(0).value = JQuery.trim(JQuery('#bfRadioValue').get(0).value);
  2354. appScope.optionElement.data1 = JQuery.trim(JQuery('#bfRadioValue').get(0).value);
  2355. JQuery('#'+appScope.optionElement.id).get(0).style.width = JQuery.trim(JQuery('#bfRadioWidth').get(0).value);
  2356. JQuery('#'+appScope.optionElement.id).get(0).style.height = JQuery.trim(JQuery('#bfRadioHeight').get(0).value);
  2357. if(JQuery('#bfRadioDisable').get(0).checked){
  2358. appScope.optionElement.flag2 = 1;
  2359. JQuery('#'+appScope.optionElement.id).get(0).setAttribute('readonly', 'readonly');
  2360. appScope.optionElement.options.readonly = true;
  2361. } else {
  2362. appScope.optionElement.flag2 = 0;
  2363. JQuery('#'+appScope.optionElement.id).get(0).setAttribute('readonly', '');
  2364. JQuery('#'+appScope.optionElement.id).get(0).removeAttribute('readonly');
  2365. appScope.optionElement.options.readonly = false;
  2366. }
  2367. }
  2368. break;
  2369. case 'bfSelect':
  2370. if(JQuery.trim(JQuery('#bfSelectTitle').get(0).value) == '')
  2371. {
  2372. error = '<?php echo BFText::_('COM_BREEZINGFORMS_TITLE_MUST_NOT_BE_EMPTY') ?>';
  2373. }
  2374. if(JQuery.trim(JQuery('#bfSelectName').get(0).value) == '')
  2375. {
  2376. error = '<?php echo BFText::_('COM_BREEZINGFORMS_NAME_MUST_NOT_BE_EMPTY') ?>';
  2377. }
  2378. if(error == ''){
  2379. appScope.optionElement.title = JQuery.trim(JQuery('#bfSelectTitle').get(0).value);
  2380. appScope.optionElement.name = JQuery.trim(JQuery('#bfSelectName').get(0).value);
  2381. if(JQuery('#bfSelectMultipleYes').get(0).checked){
  2382. appScope.optionElement.flag1 = 1;
  2383. appScope.optionElement.options.multiple = true;
  2384. JQuery('#'+appScope.optionElement.id).get(0).setAttribute('multiple', 'multiple');
  2385. } else {
  2386. appScope.optionElement.options.multiple = false;
  2387. appScope.optionElement.flag1 = 0;
  2388. JQuery('#'+appScope.optionElement.id).get(0).removeAttribute('multiple');
  2389. }
  2390. JQuery('#'+appScope.optionElement.id).empty();
  2391. var raw = JQuery.trim(JQuery('#bfSelectOpts').get(0).value);
  2392. raw = raw.replace(/\r/g,"");
  2393. appScope.optionElement.data2 = raw;
  2394. var lines = raw.split("\n");
  2395. for(var i = 0; i < lines.length; i++){
  2396. var line = lines[i].split(';');
  2397. if(line.length == 3){
  2398. var option = document.createElement('option');
  2399. option.setAttribute('value', JQuery.trim(line[2]));
  2400. option.innerHTML = JQuery.trim(line[1]);
  2401. if(JQuery.trim(line[0]) == '1'){
  2402. option.setAttribute('selected', 'selected');
  2403. }
  2404. }
  2405. JQuery('#'+appScope.optionElement.id).append(option);
  2406. }
  2407. appScope.optionElement.options.options = JQuery.trim(JQuery('#bfSelectOpts').get(0).value);
  2408. JQuery('#'+appScope.optionElement.id).get(0).style.width = JQuery.trim(JQuery('#bfSelectWidth').get(0).value);
  2409. JQuery('#'+appScope.optionElement.id).get(0).style.height = JQuery.trim(JQuery('#bfSelectHeight').get(0).value);
  2410. if(JQuery('#bfSelectDisable').get(0).checked){
  2411. appScope.optionElement.flag2 = 1;
  2412. JQuery('#'+appScope.optionElement.id).get(0).setAttribute('readonly', 'readonly');
  2413. appScope.optionElement.options.readonly = true;
  2414. } else {
  2415. appScope.optionElement.flag2 = 0;
  2416. JQuery('#'+appScope.optionElement.id).get(0).setAttribute('readonly', '');
  2417. JQuery('#'+appScope.optionElement.id).get(0).removeAttribute('readonly');
  2418. appScope.optionElement.options.readonly = false;
  2419. }
  2420. if(JQuery('#bfSelectMailback').get(0).checked){
  2421. appScope.optionElement.mailback = 1;
  2422. appScope.optionElement.options.mailback = true;
  2423. } else {
  2424. appScope.optionElement.options.mailback = false;
  2425. appScope.optionElement.mailback = 0;
  2426. }
  2427. }
  2428. break;
  2429. case 'bfFile':
  2430. if(JQuery.trim(JQuery('#bfFileTitle').get(0).value) == '')
  2431. {
  2432. error = '<?php echo BFText::_('COM_BREEZINGFORMS_TITLE_MUST_NOT_BE_EMPTY') ?>';
  2433. }
  2434. if(JQuery.trim(JQuery('#bfFileName').get(0).value) == '')
  2435. {
  2436. error = '<?php echo BFText::_('COM_BREEZINGFORMS_NAME_MUST_NOT_BE_EMPTY') ?>';
  2437. }
  2438. if(error == ''){
  2439. appScope.optionElement.title = JQuery.trim(JQuery('#bfFileTitle').get(0).value);
  2440. appScope.optionElement.name = JQuery.trim(JQuery('#bfFileName').get(0).value);
  2441. if(!appScope.optionElement.options.allowedFileExtensions) appScope.optionElement.options['allowedFileExtensions'] = -1;
  2442. appScope.optionElement.options.allowedFileExtensions = JQuery.trim(JQuery('#bfFileAllowedFileExtensions').get(0).value);
  2443. appScope.optionElement.options.uploadDirectory = JQuery.trim(JQuery('#bfFileUploadDirectory').get(0).value);
  2444. appScope.optionElement.data1 = JQuery.trim(JQuery('#bfFileUploadDirectory').get(0).value);
  2445. appScope.optionElement.options.timestamp = JQuery('#bfFileTimestamp').get(0).checked;
  2446. if(JQuery('#bfFileTimestamp').get(0).checked){
  2447. appScope.optionElement.flag1 = 1;
  2448. JQuery('#'+appScope.optionElement.id).attr('checked', true);
  2449. } else {
  2450. appScope.optionElement.flag1 = 0;
  2451. JQuery('#'+appScope.optionElement.id).attr('checked', false);
  2452. }
  2453. if(!appScope.optionElement.options.attachToAdminMail) appScope.optionElement.options['attachToAdminMail'] = false;
  2454. if(JQuery('#bfFileAttachToAdminMail').get(0).checked){
  2455. appScope.optionElement.options.attachToAdminMail = true;
  2456. } else {
  2457. appScope.optionElement.options.attachToAdminMail = false;
  2458. }
  2459. if(!appScope.optionElement.options.attachToUserMail) appScope.optionElement.options['attachToUserMail'] = false;
  2460. if(JQuery('#bfFileAttachToUserMail').get(0).checked){
  2461. appScope.optionElement.options.attachToUserMail = true;
  2462. } else {
  2463. appScope.optionElement.options.attachToUserMail = false;
  2464. }
  2465. JQuery('#'+appScope.optionElement.id).get(0).style.width = JQuery.trim(JQuery('#bfFileWidth').get(0).value);
  2466. JQuery('#'+appScope.optionElement.id).get(0).style.height = JQuery.trim(JQuery('#bfFileHeight').get(0).value);
  2467. if(JQuery('#bfFileDisable').get(0).checked){
  2468. JQuery('#'+appScope.optionElement.id).get(0).setAttribute('readonly', 'readonly');
  2469. appScope.optionElement.options.readonly = true;
  2470. } else {
  2471. JQuery('#'+appScope.optionElement.id).get(0).setAttribute('readonly', '');
  2472. JQuery('#'+appScope.optionElement.id).get(0).removeAttribute('readonly');
  2473. appScope.optionElement.options.readonly = false;
  2474. }
  2475. }
  2476. break;
  2477. case 'bfImageButton':
  2478. if(JQuery.trim(JQuery('#bfImageButtonTitle').get(0).value) == '')
  2479. {
  2480. error = '<?php echo BFText::_('COM_BREEZINGFORMS_TITLE_MUST_NOT_BE_EMPTY') ?>';
  2481. }
  2482. if(JQuery.trim(JQuery('#bfImageButtonName').get(0).value) == '')
  2483. {
  2484. error = '<?php echo BFText::_('COM_BREEZINGFORMS_NAME_MUST_NOT_BE_EMPTY') ?>';
  2485. }
  2486. if(error == ''){
  2487. appScope.optionElement.title = JQuery.trim(JQuery('#bfImageButtonTitle').get(0).value);
  2488. appScope.optionElement.name = JQuery.trim(JQuery('#bfImageButtonName').get(0).value);
  2489. JQuery('#'+appScope.optionElement.id).get(0).style.width = JQuery.trim(JQuery('#bfImageButtonWidth').get(0).value);
  2490. JQuery('#'+appScope.optionElement.id).get(0).style.height = JQuery.trim(JQuery('#bfImageButtonHeight').get(0).value);
  2491. JQuery('#'+appScope.optionElement.id).get(0).setAttribute('src', JQuery.trim(JQuery('#bfImageButtonImage').get(0).value));
  2492. JQuery('#'+appScope.optionElement.id).get(0).setAttribute('value', JQuery.trim(JQuery('#bfImageButtonValue').get(0).value));
  2493. JQuery('#'+appScope.optionElement.id).get(0).value = JQuery.trim(JQuery('#bfImageButtonValue').get(0).value);
  2494. appScope.optionElement.options.value = JQuery.trim(JQuery('#bfImageButtonValue').get(0).value);
  2495. if(JQuery('#bfImageButtonDisable').get(0).checked){
  2496. appScope.optionElement.flag2 = 1;
  2497. JQuery('#'+appScope.optionElement.id).get(0).setAttribute('readonly', 'readonly');
  2498. appScope.optionElement.options.readonly = true;
  2499. } else {
  2500. appScope.optionElement.flag2 = 0;
  2501. JQuery('#'+appScope.optionElement.id).get(0).setAttribute('readonly', '');
  2502. JQuery('#'+appScope.optionElement.id).get(0).removeAttribute('readonly');
  2503. appScope.optionElement.options.readonly = false;
  2504. }
  2505. }
  2506. break;
  2507. case 'bfSubmitButton':
  2508. if(JQuery.trim(JQuery('#bfSubmitButtonTitle').get(0).value) == '')
  2509. {
  2510. error = '<?php echo BFText::_('COM_BREEZINGFORMS_TITLE_MUST_NOT_BE_EMPTY') ?>';
  2511. }
  2512. if(JQuery.trim(JQuery('#bfSubmitButtonName').get(0).value) == '')
  2513. {
  2514. error = '<?php echo BFText::_('COM_BREEZINGFORMS_NAME_MUST_NOT_BE_EMPTY') ?>';
  2515. }
  2516. if(error == ''){
  2517. appScope.optionElement.title = JQuery.trim(JQuery('#bfSubmitButtonTitle').get(0).value);
  2518. appScope.optionElement.name = JQuery.trim(JQuery('#bfSubmitButtonName').get(0).value);
  2519. JQuery('#'+appScope.optionElement.id).get(0).style.width = JQuery.trim(JQuery('#bfSubmitButtonWidth').get(0).value);
  2520. JQuery('#'+appScope.optionElement.id).get(0).style.height = JQuery.trim(JQuery('#bfSubmitButtonHeight').get(0).value);
  2521. JQuery('#'+appScope.optionElement.id).get(0).setAttribute('value', JQuery.trim(JQuery('#bfSubmitButtonValue').get(0).value));
  2522. JQuery('#'+appScope.optionElement.id).get(0).value = JQuery.trim(JQuery('#bfSubmitButtonValue').get(0).value);
  2523. appScope.optionElement.options.value = JQuery.trim(JQuery('#bfSubmitButtonValue').get(0).value);
  2524. if(JQuery('#bfSubmitButtonDisable').get(0).checked){
  2525. appScope.optionElement.flag2 = 1;
  2526. JQuery('#'+appScope.optionElement.id).get(0).setAttribute('readonly', 'readonly');
  2527. appScope.optionElement.options.readonly = true;
  2528. } else {
  2529. appScope.optionElement.flag2 = 0;
  2530. JQuery('#'+appScope.optionElement.id).get(0).setAttribute('readonly', '');
  2531. JQuery('#'+appScope.optionElement.id).get(0).removeAttribute('readonly');
  2532. appScope.optionElement.options.readonly = false;
  2533. }
  2534. }
  2535. break;
  2536. case 'bfTooltip':
  2537. if(JQuery.trim(JQuery('#bfTooltipTitle').get(0).value) == '')
  2538. {
  2539. error = '<?php echo BFText::_('COM_BREEZINGFORMS_TITLE_MUST_NOT_BE_EMPTY') ?>';
  2540. }
  2541. if(JQuery.trim(JQuery('#bfTooltipName').get(0).value) == '')
  2542. {
  2543. error = '<?php echo BFText::_('COM_BREEZINGFORMS_NAME_MUST_NOT_BE_EMPTY') ?>';
  2544. }
  2545. if(error == ''){
  2546. appScope.optionElement.title = JQuery.trim(JQuery('#bfTooltipTitle').get(0).value);
  2547. appScope.optionElement.name = JQuery.trim(JQuery('#bfTooltipName').get(0).value);
  2548. if(JQuery('#bfTooltipTypeInfo').get(0).checked){
  2549. appScope.optionElement.flag1 = 0;
  2550. appScope.optionElement.options.image = '<?php echo JURI::root(); ?>includes/js/ThemeOffice/tooltip.png';
  2551. appScope.optionElement.options.type = 'info';
  2552. } else if(JQuery('#bfTooltipTypeWarning').get(0).checked){
  2553. appScope.optionElement.flag1 = 1;
  2554. appScope.optionElement.options.image = '<?php echo JURI::root(); ?>includes/js/ThemeOffice/warning.png';
  2555. appScope.optionElement.options.type = 'warning';
  2556. } else if(JQuery('#bfTooltipTypeCustom').get(0).checked){
  2557. appScope.optionElement.options.image = JQuery.trim(JQuery('#bfTooltipCustomImage').get(0).value);
  2558. appScope.optionElement.options.type = 'custom';
  2559. }
  2560. JQuery('#'+appScope.optionElement.id).get(0).setAttribute('src', appScope.optionElement.options.image);
  2561. appScope.optionElement.options.text = JQuery.trim(JQuery('#bfTooltipText').get(0).value);
  2562. appScope.optionElement.data2 = JQuery.trim(JQuery('#bfTooltipText').get(0).value);
  2563. JQuery('#'+appScope.optionElement.id).get(0).style.width = JQuery.trim(JQuery('#bfTooltipWidth').get(0).value);
  2564. JQuery('#'+appScope.optionElement.id).get(0).style.height = JQuery.trim(JQuery('#bfTooltipHeight').get(0).value);
  2565. }
  2566. break;
  2567. case 'bfPayPal':
  2568. if(JQuery.trim(JQuery('#bfPayPalTitle').get(0).value) == '')
  2569. {
  2570. error = '<?php echo BFText::_('COM_BREEZINGFORMS_TITLE_MUST_NOT_BE_EMPTY') ?>';
  2571. }
  2572. if(JQuery.trim(JQuery('#bfPayPalName').get(0).value) == '')
  2573. {
  2574. error = '<?php echo BFText::_('COM_BREEZINGFORMS_NAME_MUST_NOT_BE_EMPTY') ?>';
  2575. }
  2576. if(error == ''){
  2577. appScope.optionElement.title = JQuery.trim(JQuery('#bfPayPalTitle').get(0).value);
  2578. appScope.optionElement.name = JQuery.trim(JQuery('#bfPayPalName').get(0).value);
  2579. if(JQuery('#bfPayPalTestaccountYes').get(0).checked){
  2580. appScope.optionElement.options.testaccount = true;
  2581. } else {
  2582. appScope.optionElement.options.testaccount = false;
  2583. }
  2584. if(JQuery('#bfPayPalDownloadableFileYes').get(0).checked){
  2585. appScope.optionElement.options.downloadableFile = true;
  2586. } else {
  2587. appScope.optionElement.options.downloadableFile = false;
  2588. }
  2589. if(typeof appScope.optionElement.options.useIpn == "undefined") { // compat 730
  2590. appScope.optionElement.option['useIpn'] = false;
  2591. }
  2592. if(JQuery('#bfPayPalUseIpnYes').get(0).checked){
  2593. appScope.optionElement.options.useIpn = true;
  2594. } else {
  2595. appScope.optionElement.options.useIpn = false;
  2596. }
  2597. appScope.optionElement.options.filepath = JQuery.trim(JQuery('#bfPayPalFilepath').get(0).value);
  2598. appScope.optionElement.options.downloadTries = JQuery.trim(JQuery('#bfPayPalFileDownloadTries').get(0).value);
  2599. appScope.optionElement.options.business = JQuery.trim(JQuery('#bfPayPalBusiness').get(0).value);
  2600. appScope.optionElement.options.token = JQuery.trim(JQuery('#bfPayPalToken').get(0).value);
  2601. appScope.optionElement.options.testBusiness = JQuery.trim(JQuery('#bfPayPalTestBusiness').get(0).value);
  2602. appScope.optionElement.options.testToken = JQuery.trim(JQuery('#bfPayPalTestToken').get(0).value);
  2603. appScope.optionElement.options.itemname = JQuery.trim(JQuery('#bfPayPalItemname').get(0).value);
  2604. appScope.optionElement.options.itemnumber = JQuery.trim(JQuery('#bfPayPalItemnumber').get(0).value);
  2605. appScope.optionElement.options.amount = JQuery.trim(JQuery('#bfPayPalAmount').get(0).value);
  2606. appScope.optionElement.options.tax = JQuery.trim(JQuery('#bfPayPalTax').get(0).value);
  2607. appScope.optionElement.options.thankYouPage = JQuery.trim(JQuery('#bfPayPalThankYouPage').get(0).value);
  2608. appScope.optionElement.options.locale = JQuery.trim(JQuery('#bfPayPalLocale').get(0).value);
  2609. appScope.optionElement.options.currencyCode = JQuery.trim(JQuery('#bfPayPalCurrencyCode').get(0).value);
  2610. JQuery('#'+appScope.optionElement.id).attr('src', JQuery.trim(JQuery('#bfPayPalImage').get(0).value));
  2611. JQuery('#'+appScope.optionElement.id).get(0).style.width = JQuery.trim(JQuery('#bfPayPalWidth').get(0).value);
  2612. JQuery('#'+appScope.optionElement.id).get(0).style.height = JQuery.trim(JQuery('#bfPayPalHeight').get(0).value);
  2613. }
  2614. break;
  2615. case 'bfSofortueberweisung':
  2616. if(JQuery.trim(JQuery('#bfSofortueberweisungTitle').get(0).value) == '')
  2617. {
  2618. error = '<?php echo BFText::_('COM_BREEZINGFORMS_TITLE_MUST_NOT_BE_EMPTY') ?>';
  2619. }
  2620. if(JQuery.trim(JQuery('#bfSofortueberweisungName').get(0).value) == '')
  2621. {
  2622. error = '<?php echo BFText::_('COM_BREEZINGFORMS_NAME_MUST_NOT_BE_EMPTY') ?>';
  2623. }
  2624. if(error == ''){
  2625. appScope.optionElement.title = JQuery.trim(JQuery('#bfSofortueberweisungTitle').get(0).value);
  2626. appScope.optionElement.name = JQuery.trim(JQuery('#bfSofortueberweisungName').get(0).value);
  2627. if(JQuery('#bfSofortueberweisungDownloadableFileYes').get(0).checked){
  2628. appScope.optionElement.options.downloadableFile = true;
  2629. } else {
  2630. appScope.optionElement.options.downloadableFile = false;
  2631. }
  2632. if(JQuery('#bfSofortueberweisungMailbackYes').get(0).checked){
  2633. appScope.optionElement.options.mailback = true;
  2634. } else {
  2635. appScope.optionElement.options.mailback = false;
  2636. }
  2637. appScope.optionElement.options.filepath = JQuery.trim(JQuery('#bfSofortueberweisungFilepath').get(0).value);
  2638. appScope.optionElement.options.downloadTries = JQuery.trim(JQuery('#bfSofortueberweisungFileDownloadTries').get(0).value);
  2639. appScope.optionElement.options.user_id = JQuery.trim(JQuery('#bfSofortueberweisungUserId').get(0).value);
  2640. appScope.optionElement.options.project_id = JQuery.trim(JQuery('#bfSofortueberweisungProjectId').get(0).value);
  2641. appScope.optionElement.options.project_password = JQuery.trim(JQuery('#bfSofortueberweisungProjectPassword').get(0).value);
  2642. appScope.optionElement.options.reason_1 = JQuery.trim(JQuery('#bfSofortueberweisungReason1').get(0).value);
  2643. appScope.optionElement.options.reason_2 = JQuery.trim(JQuery('#bfSofortueberweisungReason2').get(0).value);
  2644. appScope.optionElement.options.amount = JQuery.trim(JQuery('#bfSofortueberweisungAmount').get(0).value);
  2645. appScope.optionElement.options.thankYouPage = JQuery.trim(JQuery('#bfSofortueberweisungThankYouPage').get(0).value);
  2646. appScope.optionElement.options.language_id = JQuery.trim(JQuery('#bfSofortueberweisungLanguageId').get(0).value);
  2647. appScope.optionElement.options.currency_id = JQuery.trim(JQuery('#bfSofortueberweisungCurrencyId').get(0).value);
  2648. JQuery('#'+appScope.optionElement.id).attr('src', JQuery.trim(JQuery('#bfSofortueberweisungImage').get(0).value));
  2649. JQuery('#'+appScope.optionElement.id).get(0).style.width = JQuery.trim(JQuery('#bfSofortueberweisungWidth').get(0).value);
  2650. JQuery('#'+appScope.optionElement.id).get(0).style.height = JQuery.trim(JQuery('#bfSofortueberweisungHeight').get(0).value);
  2651. }
  2652. break;
  2653. }
  2654. if(JQuery('#'+appScope.optionElement.id).parent().attr('class') == 'ui-wrapper'){
  2655. element = JQuery('#'+appScope.optionElement.id).parent();
  2656. if(JQuery('#'+appScope.optionElement.id).get(0).style.width != ''){
  2657. element.css('width', JQuery('#'+appScope.optionElement.id).get(0).style.width);
  2658. }
  2659. if(JQuery('#'+appScope.optionElement.id).get(0).style.height != ''){
  2660. element.css('height', JQuery('#'+appScope.optionElement.id).get(0).style.height);
  2661. }
  2662. }
  2663. } else {
  2664. // must be a label then
  2665. JQuery(appScope.optionElement).resizable('destroy');
  2666. JQuery(appScope.optionElement).get(0).innerHTML = JQuery.trim(JQuery('#bfLabelContent').get(0).value);
  2667. appScope.setElementResizable(JQuery(appScope.optionElement).get(0));
  2668. JQuery(appScope.optionElement).get(0).style.width = JQuery.trim(JQuery('#bfLabelWidth').get(0).value);
  2669. JQuery(appScope.optionElement).get(0).style.height = JQuery.trim(JQuery('#bfLabelHeight').get(0).value);
  2670. if(JQuery('#bfLabelOnTop').get(0).checked){
  2671. JQuery(appScope.optionElement).parent().children('.ff_break')[0].style.display = '';
  2672. JQuery(appScope.optionElement).parent().children('.ff_label')[0].style.cssFloat = 'none';
  2673. } else {
  2674. JQuery(appScope.optionElement).parent().children('.ff_break')[0].style.display = 'none';
  2675. JQuery(appScope.optionElement).parent().children('.ff_label')[0].style.cssFloat = 'left';
  2676. }
  2677. }
  2678. JQuery('#'+appScope.optionElement.id).get(0).style.padding = JQuery.trim(JQuery('#bfOptionsPadding').get(0).value);
  2679. JQuery('#'+appScope.optionElement.id).get(0).style.margin = JQuery.trim(JQuery('#bfOptionsMargin').get(0).value);
  2680. appScope.optionElement.orderNumber = JQuery.trim(JQuery('#bfOptionsOrder').get(0).value);
  2681. appScope.optionElement.tabIndex = JQuery.trim(JQuery('#bfOptionsTabIndex').get(0).value);
  2682. if(error == ''){
  2683. JQuery('#bfOptionsSaveMessage').get(0).innerHTML = '<?php echo BFText::_('COM_BREEZINGFORMS_OPTIONS_SAVED_TO_FINALLY_SAVE_YOUR_FORM_CLICK_SAVE_ON_THE_TOP_RIGHT_BUTTON') ?><br/><br/>';
  2684. } else {
  2685. JQuery('#bfOptionsSaveMessage').get(0).innerHTML = error + '<br/><br/>';
  2686. }
  2687. JQuery('#bfOptionsSaveMessage').css('display','');
  2688. JQuery('#bfOptionsSaveMessage').css('visibility','visible');
  2689. }
  2690. );
  2691. this.droppableAreaSortableInit = {
  2692. cursor:"pointer",
  2693. handle : '.ff_dragBox',
  2694. tolerance : 'pointer',
  2695. connectWith : ['#trashcan', '.droppableArea'],
  2696. start: function(e, ui){
  2697. },
  2698. receive: function(e, ui){
  2699. // removing the moved element from other areas and assigning to new one.
  2700. // this keeps the internal areaList intact
  2701. var foundElements = new Array();
  2702. if(!appScope.hasArea(JQuery(this).get(0))){
  2703. appScope.areaList.push( { area : JQuery(this).get(0), elements : [] } );
  2704. }
  2705. if(appScope.hasArea(JQuery(this).get(0))){
  2706. // try to find the elements to be moved on all areas
  2707. for(var i=0;i < appScope.areaList.length;i++){
  2708. if(appScope.areaList[i].area != JQuery(this).get(0)){
  2709. for(var j=0;j < appScope.areaList[i].elements.length;j++){
  2710. for(var k=0;k < JQuery(ui.item).children('.ff_div').children('.ff_elem').length;k++){
  2711. if(appScope.areaList[i].elements[j].id == JQuery(ui.item).children('.ff_div').children('.ff_elem')[k].id){
  2712. foundElements.push(appScope.areaList[i].elements[j]);
  2713. break;
  2714. }
  2715. }
  2716. for(var k=0;k < JQuery(ui.item).children('.ff_div').children('.ui-wrapper').length;k++){
  2717. var wrappedElement = JQuery(ui.item).children('.ff_div').children('.ui-wrapper')[k];
  2718. if(JQuery(wrappedElement).children('.ff_elem').length == 1){
  2719. var id = JQuery(wrappedElement).children('.ff_elem')[0].id;
  2720. if(appScope.areaList[i].elements[j].id == id){
  2721. foundElements.push(appScope.areaList[i].elements[j]);
  2722. break;
  2723. }
  2724. }
  2725. }
  2726. }
  2727. }
  2728. }
  2729. // try to find them in the trashcan
  2730. for(var i=0;i < appScope.trashcanAreaList.length;i++){
  2731. for(var k=0;k < JQuery(ui.item).children('.ff_div').children('.ff_elem').length;k++){
  2732. if(appScope.trashcanAreaList[i].id == JQuery(ui.item).children('.ff_div').children('.ff_elem')[k].id){
  2733. foundElements.push(appScope.trashcanAreaList[i]);
  2734. break;
  2735. }
  2736. }
  2737. for(var k=0;k < JQuery(ui.item).children('.ff_div').children('.ui-wrapper').length;k++){
  2738. var wrappedElement = JQuery(ui.item).children('.ff_div').children('.ui-wrapper')[k];
  2739. if(JQuery(wrappedElement).children('.ff_elem').length == 1){
  2740. var id = JQuery(wrappedElement).children('.ff_elem')[0].id;
  2741. if(appScope.areaList[i].elements[j].id == id){
  2742. foundElements.push(appScope.trashcanAreaList[i]);
  2743. break;
  2744. }
  2745. }
  2746. }
  2747. }
  2748. if(foundElements.length > 0){
  2749. for(var i=0;i < foundElements.length ;i++){
  2750. // remove the element from all areas and the trashcan...
  2751. appScope.removeElementFromAreaList(foundElements[i]);
  2752. appScope.removeElementFromTrashcanAreaList(foundElements[i]);
  2753. // ...and add it to the newly selected area
  2754. foundElements[i].area = JQuery(this).get(0).id;
  2755. var elements = appScope.getElementsArray(JQuery(this).get(0));
  2756. elements.push(foundElements[i]);
  2757. }
  2758. }
  2759. }
  2760. }
  2761. };
  2762. JQuery(".droppableArea").sortable(appScope.droppableAreaSortableInit);
  2763. JQuery("#trashcan").sortable(
  2764. {
  2765. cursor:"pointer",
  2766. handle : '.ff_dragBox',
  2767. connectWith : ['.droppableArea'],
  2768. receive: function(e, ui){
  2769. var foundElements = new Array();
  2770. for(var i=0;i < appScope.areaList.length;i++){
  2771. if(appScope.areaList[i].area != JQuery(this).get(0)){for(var j=0;j < appScope.areaList[i].elements.length;j++){
  2772. for(var k=0;k < JQuery(ui.item).children('.ff_div').children('.ff_elem').length;k++){
  2773. if(appScope.areaList[i].elements[j].id == JQuery(ui.item).children('.ff_div').children('.ff_elem')[k].id){
  2774. foundElements.push(appScope.areaList[i].elements[j]);
  2775. break;
  2776. }
  2777. }
  2778. for(var k=0;k < JQuery(ui.item).children('.ff_div').children('.ui-wrapper').length;k++){
  2779. var wrappedElement = JQuery(ui.item).children('.ff_div').children('.ui-wrapper')[k];
  2780. if(JQuery(wrappedElement).children('.ff_elem').length == 1){
  2781. var id = JQuery(wrappedElement).children('.ff_elem')[0].id;
  2782. if(appScope.areaList[i].elements[j].id == id){
  2783. foundElements.push(appScope.areaList[i].elements[j]);
  2784. break;
  2785. }
  2786. }
  2787. }
  2788. }
  2789. }
  2790. }
  2791. if(foundElements.length > 0){
  2792. for(var i=0;i < foundElements.length ;i++){
  2793. appScope.removeElementFromAreaList(foundElements[i]);
  2794. appScope.trashcanAreaList.push(foundElements[i]);
  2795. }
  2796. }
  2797. }
  2798. }
  2799. );
  2800. JQuery(".draggableElement").draggable(
  2801. {
  2802. revert: 'invalid',
  2803. helper : 'clone',
  2804. opacity: appScope.opacity
  2805. }
  2806. );
  2807. this.droppableAreaDroppableInit = {
  2808. accept: '.draggableElement',
  2809. activeClass: 'droppable-active',
  2810. hoverClass: 'droppable-hover',
  2811. drop: function(e, ui) {
  2812. var element = null;
  2813. if(typeof JQuery(this).get(0).id == "undefined" || JQuery(this).get(0).id == ""){
  2814. alert('One of your areas has no id, please fix that!');
  2815. return;
  2816. }
  2817. if(!appScope.hasArea(JQuery(this).get(0))){
  2818. appScope.areaList.push( { area : JQuery(this).get(0), elements : [] } );
  2819. }
  2820. var elements = appScope.getElementsArray(JQuery(this).get(0));
  2821. var rndId = JQuery.md5(Math.random() + elements.length + JQuery(ui.draggable).attr('id') + JQuery(this).get(0).id);
  2822. var internalType = JQuery(ui.draggable).attr('id');
  2823. element = appScope.createElementByType(internalType, rndId);
  2824. if(element != null){
  2825. if(JQuery(ui.draggable).attr('id') != 'bfHidden'){
  2826. var wrapper = document.createElement('div');
  2827. wrapper.setAttribute('id', 'ff_div' + rndId);
  2828. wrapper.setAttribute('class', 'ff_div');
  2829. if(JQuery(ui.draggable).attr('id') != 'bfStaticText'){
  2830. var label = document.createElement('div');
  2831. label.setAttribute('id', 'ff_label' + rndId);
  2832. label.setAttribute('class', 'ff_label');
  2833. label.style.verticalAlign = 'top';
  2834. label.style.width = '50px';
  2835. label.style.height = '10px';
  2836. label.style.cssFloat = 'left';
  2837. label.innerHTML = 'Label...';
  2838. JQuery(label).click(appScope.resizableElement);
  2839. JQuery(wrapper).append(label);
  2840. var mybr = document.createElement('div');
  2841. mybr.setAttribute('id', 'ff_break' + rndId);
  2842. mybr.setAttribute('class', 'ff_break');
  2843. JQuery(mybr).css('display','none');
  2844. JQuery(wrapper).append(mybr);
  2845. }
  2846. JQuery(wrapper).append(element.element);
  2847. var listItem = document.createElement('li');
  2848. listItem.setAttribute('id', 'ff_listItem' + rndId);
  2849. listItem.setAttribute('class', 'ff_listItem');
  2850. var dragBox = document.createElement('span');
  2851. dragBox.setAttribute('id', 'ff_dragBox' + rndId);
  2852. dragBox.setAttribute('class', 'ff_dragBox');
  2853. dragBox.innerHTML = "&nbsp;";
  2854. JQuery(listItem).append(dragBox);
  2855. JQuery(listItem).append(wrapper);
  2856. var appender = document.createElement('div');
  2857. appender.setAttribute('class', 'ff_appender');
  2858. JQuery(appender).css('clear','both');
  2859. JQuery(listItem).append(appender);
  2860. JQuery(this).append(listItem);
  2861. } else {
  2862. JQuery('#bfTemplate').append(element.element);
  2863. }
  2864. // push the element into the internal representation
  2865. if(elements != null){
  2866. elements.push(
  2867. {
  2868. id : element.element.id,
  2869. dbId : 0,
  2870. rndId : rndId,
  2871. name : rndId, // default name until changed by user
  2872. title : 'title_' + element.element.id, // default title until changed by user
  2873. type : element.element.type ? element.element.type : '',
  2874. internalType : internalType,
  2875. bfType : element.bfType,
  2876. elementType : element.elementType,
  2877. area : JQuery(this).get(0).id,
  2878. appElementId : JQuery(ui.draggable).attr('id'),
  2879. appElementOrderId : elements.length,
  2880. wrapperId : wrapper ? wrapper.id : '',
  2881. labelId : label ? label.id : '',
  2882. listItemId : listItem ? listItem.id : '',
  2883. data1 : element.data1,
  2884. data2 : element.data2,
  2885. data3 : element.data3,
  2886. script1cond : element.script1cond,
  2887. script1id : element.script1id,
  2888. script1code : element.script1code,
  2889. script1flag1 : element.script1flag1,
  2890. script1flag2 : element.script1flag2,
  2891. script2cond : element.script2cond,
  2892. script2id : element.script2id,
  2893. script2code : element.script2code,
  2894. script2flag1 : element.script2flag1,
  2895. script2flag2 : element.script2flag2,
  2896. script2flag3 : element.script2flag3,
  2897. script2flag4 : element.script2flag4,
  2898. script2flag5 : element.script2flag5,
  2899. script3cond : element.script3cond,
  2900. script3id : element.script3id,
  2901. script3code : element.script3code,
  2902. script3msg : element.script3msg,
  2903. functionNameScript1: element.functionNameScript1,
  2904. functionNameScript2: element.functionNameScript2,
  2905. functionNameScript3: element.functionNameScript3,
  2906. flag1 : element.flag1,
  2907. flag2 : element.flag2,
  2908. mailback : element.mailback,
  2909. mailbackfile : element.mailbackfile,
  2910. mailbackAsSender : element.mailbackAsSender,
  2911. mailbackAccept : false,
  2912. mailbackAcceptConnectWith: '',
  2913. orderNumber : -1,
  2914. tabIndex : -1,
  2915. page : parseInt(document.adminForm.page.value),
  2916. options : element.options
  2917. }
  2918. );
  2919. if(internalType == 'bfCaptcha'){
  2920. appScope.captchaAdded++;
  2921. }
  2922. appScope.populateHiddenFieldsOptions();
  2923. if(internalType != 'bfHidden'){
  2924. appScope.setElementResizable(element.element);
  2925. }
  2926. var labelsResult = JQuery('#'+element.element.id).parent().parent().children('.ff_label');
  2927. if(labelsResult.length != 0){
  2928. for(var k = 0; k < labelsResult.length;k++){
  2929. appScope.setElementResizable(labelsResult[k]);
  2930. }
  2931. }
  2932. labelsResult = JQuery('#'+element.element.id).parent().children('.ff_label');
  2933. if(labelsResult.length != 0){
  2934. for(var k = 0; k < labelsResult.length;k++){
  2935. appScope.setElementResizable(labelsResult[k]);
  2936. }
  2937. }
  2938. appScope.initMouseOvers();
  2939. }
  2940. }
  2941. }
  2942. };
  2943. JQuery(".droppableArea").droppable(appScope.droppableAreaDroppableInit);
  2944. }
  2945. JQuery(document).ready(function() {
  2946. app = new BF_EasyModeApp();
  2947. app.populateHiddenFieldsOptions();
  2948. });
  2949. var bf_submitbutton = function(pressbutton)
  2950. {
  2951. var form = document.adminForm;
  2952. switch (pressbutton) {
  2953. case 'close':
  2954. location.href="index.php?option=com_breezingforms&act=manageforms";
  2955. break;
  2956. case 'integrate':
  2957. form.task.value = 'list';
  2958. form.act.value = 'integrate';
  2959. submitform(pressbutton);
  2960. break;
  2961. case 'save':
  2962. var prepared = app.prepareForSave();
  2963. form.task.value = 'save';
  2964. form.act.value = 'easymode';
  2965. form.templateCode.value = prepared.templateCode;
  2966. form.areas.value = prepared.areas;
  2967. submitform(pressbutton);
  2968. break;
  2969. case 'editform':
  2970. SqueezeBox.initialize({});
  2971. SqueezeBox.loadModal = function(modalUrl,handler,x,y) {
  2972. this.presets.size.x = 1024;
  2973. this.initialize();
  2974. var options = JQuery.toJSON("{handler: \'" + handler + "\', size: {x: " + x +", y: " + y + "}}");
  2975. this.setOptions(this.presets, options);
  2976. this.assignOptions();
  2977. this.setContent(handler,modalUrl);
  2978. };
  2979. SqueezeBox.loadModal("index.php?option=com_breezingforms&tmpl=component&task=editform&act=editpage&form=<?php echo $formId ?>&pkg=EasyModeForms","iframe",820,400);
  2980. break;
  2981. case 'preview':
  2982. SqueezeBox.initialize({});
  2983. SqueezeBox.loadModal = function(modalUrl,handler,x,y) {
  2984. this.presets.size.x = 820;
  2985. this.initialize();
  2986. var options = JQuery.toJSON("{handler: \'" + handler + "\', size: {x: " + x +", y: " + y + "}}");
  2987. this.setOptions(this.presets, options);
  2988. this.assignOptions();
  2989. this.setContent(handler,modalUrl);
  2990. };
  2991. SqueezeBox.loadModal("<?php echo JURI::root()?>index.php?format=html&tmpl=component&option=com_breezingforms&ff_form=<?php echo $formId ?>&ff_page=<?php echo $page ?>","iframe",820,400);
  2992. break;
  2993. case 'preview_site':
  2994. SqueezeBox.initialize({});
  2995. SqueezeBox.loadModal = function(modalUrl,handler,x,y) {
  2996. this.presets.size.x = 1024;
  2997. this.initialize();
  2998. var options = JQuery.toJSON("{handler: \'" + handler + "\', size: {x: " + x +", y: " + y + "}}");
  2999. this.setOptions(this.presets, options);
  3000. this.assignOptions();
  3001. this.setContent(handler,modalUrl);
  3002. };
  3003. SqueezeBox.loadModal("<?php echo JURI::root()?>index.php?option=com_breezingforms&ff_form=<?php echo $formId ?>&ff_page=<?php echo $page ?>","iframe",1024,400);
  3004. break;
  3005. default:
  3006. break;
  3007. }
  3008. }; // submitbutton
  3009. if(typeof Joomla != "undefined"){
  3010. Joomla.submitbutton = bf_submitbutton;
  3011. }
  3012. submitbutton = bf_submitbutton;
  3013. function expstring(text)
  3014. {
  3015. text = JQuery.trim(text);
  3016. var i;
  3017. var o = '';
  3018. for(i = 0; i < text.length; i++) {
  3019. c = text.charAt(i);
  3020. switch(c) {
  3021. case '&' : o += '\\x26'; break;
  3022. case '<' : o += '\\x3C'; break;
  3023. case '>' : o += '\\x3E'; break;
  3024. case '\'': o += '\\x27'; break;
  3025. case '\\': o += '\\x5C'; break;
  3026. case '"' : o += '\\x22'; break;
  3027. case '\n': o += '\\n'; break;
  3028. case '\r': o += '\\r'; break;
  3029. default: o += c;
  3030. } // switch
  3031. } // for
  3032. return o;
  3033. } // expstring
  3034. function createActionCode(element)
  3035. {
  3036. form = document.bfForm;
  3037. name = element.name;
  3038. if (name=='') {
  3039. alert('Please enter the element name first.');
  3040. return;
  3041. } // if
  3042. if (!confirm("<?php echo BFText::_('COM_BREEZINGFORMS_ELEMENTS_CREAACTION'); ?>\n<?php echo BFText::_('COM_BREEZINGFORMS_ELEMENTS_EXISTAPP'); ?>")) return;
  3043. code =
  3044. "function ff_"+name+"_action(element, action)\n"+
  3045. "{\n"+
  3046. " switch (action) {\n";
  3047. if (form.script2flag1)
  3048. if (form.script2flag1.checked)
  3049. code +=
  3050. " case 'click':\n"+
  3051. " break;\n";
  3052. if (form.script2flag2)
  3053. if (form.script2flag2.checked)
  3054. code +=
  3055. " case 'blur':\n"+
  3056. " break;\n";
  3057. if (form.script2flag3)
  3058. if (form.script2flag3.checked)
  3059. code +=
  3060. " case 'change':\n"+
  3061. " break;\n";
  3062. if (form.script2flag4)
  3063. if (form.script2flag4.checked)
  3064. code +=
  3065. " case 'focus':\n"+
  3066. " break;\n";
  3067. if (form.script2flag5)
  3068. if (form.script2flag5.checked)
  3069. code +=
  3070. " case 'select':\n"+
  3071. " break;\n";
  3072. code +=
  3073. " default:;\n"+
  3074. " } // switch\n"+
  3075. "} // ff_"+name+"_action\n";
  3076. oldcode = form.script2code.value;
  3077. if (oldcode != '')
  3078. form.script2code.value =
  3079. code+
  3080. "\n// -------------- <?php echo BFText::_('COM_BREEZINGFORMS_ELEMENTS_OLDBELOW'); ?> --------------\n\n"+
  3081. oldcode;
  3082. else
  3083. form.script2code.value = code;
  3084. } // createActionCode
  3085. function createInitCode(element)
  3086. {
  3087. form = document.bfForm;
  3088. name = element.name;
  3089. if (name=='') {
  3090. alert('Please enter the element name first.');
  3091. return;
  3092. } // if
  3093. if (!confirm("<?php echo BFText::_('COM_BREEZINGFORMS_ELEMENTS_CREAINIT'); ?>\n<?php echo BFText::_('COM_BREEZINGFORMS_ELEMENTS_EXISTAPP'); ?>")) return;
  3094. code =
  3095. "function ff_"+name+"_init(element, condition)\n"+
  3096. "{\n"+
  3097. " switch (condition) {\n";
  3098. if (form.script1flag1.checked)
  3099. code +=
  3100. " case 'formentry':\n"+
  3101. " break;\n";
  3102. if (form.script1flag2.checked)
  3103. code +=
  3104. " case 'pageentry':\n"+
  3105. " break;\n";
  3106. code +=
  3107. " default:;\n"+
  3108. " } // switch\n"+
  3109. "} // ff_"+name+"_init\n";
  3110. oldcode = form.script1code.value;
  3111. if (oldcode != '')
  3112. form.script1code.value =
  3113. code+
  3114. "\n// -------------- <?php echo BFText::_('COM_BREEZINGFORMS_ELEMENTS_OLDBELOW'); ?> --------------\n\n"+
  3115. oldcode;
  3116. else
  3117. form.script1code.value = code;
  3118. } // createInitCode
  3119. function createValidationCode(element)
  3120. {
  3121. form = document.bfForm;
  3122. name = element.name;
  3123. if (name=='') {
  3124. alert('Please enter the element name first.');
  3125. return;
  3126. } // if
  3127. if (!confirm("<?php echo BFText::_('COM_BREEZINGFORMS_ELEMENTS_CREAVALID'); ?>\n<?php echo BFText::_('COM_BREEZINGFORMS_ELEMENTS_EXISTAPP'); ?>")) return;
  3128. code =
  3129. "function ff_"+name+"_validation(element, message)\n"+
  3130. "{\n"+
  3131. " if (element_fails_my_test) {\n"+
  3132. " if (message=='') message = element.name+\" faild in my test.\\n\"\n"+
  3133. " ff_validationFocus(element.name);\n"+
  3134. " return message;\n"+
  3135. " } // if\n"+
  3136. " return '';\n"+
  3137. "} // ff_"+name+"_validation\n";
  3138. oldcode = form.script3code.value;
  3139. if (oldcode != '')
  3140. form.script3code.value =
  3141. code+
  3142. "\n// -------------- <?php echo BFText::_('COM_BREEZINGFORMS_ELEMENTS_OLDBELOW'); ?> --------------\n\n"+
  3143. oldcode;
  3144. else
  3145. form.script3code.value = code;
  3146. } // createValidationCode
  3147. function stripHTML(string) {
  3148. return string.replace(/<(.|\n)*?>/g, '');
  3149. }
  3150. </script>