public function imageFormFields($opts = NULL) { if (is_array($opts)) { extract($opts); } $this->accelJS()->requireFile('jqueryConfirm'); $this->accelJS()->requireFile('jquery.imgareaselect'); //$this->accelJS()->requireFile('jquery-ui-1.7.1.custom.min'); $this->accelJS()->requireFile('jquery.ui.all.js'); // $this->accelJS()->requireFile('jquery-ui-sortable'); $this->accelJS()->requireFile('jeditable'); $imageLimit = $this->obj->imageCount() ? $this->obj->imageCount() : $this->obj->displayMaxImages(); $jQueryReadyCode .= "\n \$('.deleteImage').click(function(){\n\n \$(this).html('" . str_replace('\'', '\\\'', FormBuilder::AdminIcon('activeToggleLoader')) . "');\n\n var imageFileName = \$(this).attr('title');\n \$.ajax({\n url: '?ajax=true&adminLayout=empty&ado=imagemgrDeleteImage&fileName=' + imageFileName,\n success: function(data){\n if(\$('#' + 'image_edit_info_' + data).css('visible')){\n custom_field_next_index_gallery--;\n }\n \$('#' + 'image_edit_info_' + data).remove();\n \$('#' + 'cropperDiv_' + data).remove();\n \$('#img_' + data.replace(new RegExp('_', 'g'), '" . self::WEB_SAFE_DELIM . "')).hide('slow').remove();\n }\n });\n });\n \$('.deleteImage').confirm();\n\n \$('.image-edit-link').click(function(){\n var myID = \$(this).attr('id').replace('edit_image_', '');\n var me = \$(this);\n\n var infoForm =\$('#image_edit_info_' + myID);\n if(infoForm.is(':visible')){\n infoForm.hide('fast', function(){ \$(this).html(''); });\n } else {\n \$(this).html('" . str_replace('\'', '\\\'', FormBuilder::AdminIcon('activeToggleLoader')) . "');\n infoForm.load('?ado=imagemgrEditForm&ajax=true&adminLayout=empty&imageID=' + myID, function(){\n \$(this).show();\n me.html('" . str_replace('\'', '\\\'', FormBuilder::AdminIcon('file_edit')) . "');\n });\n }\n\n });\n\n\n var cropperVisible = false;\n\n \$('.photoCropperLink').click(function(){\n\n \$(this).html('" . str_replace('\'', '\\\'', FormBuilder::AdminIcon('activeToggleLoader')) . "');\n\n \$('#thumbnail').imgAreaSelect({ hide: true});\n\n var fileName = \$(this).attr('title');\n var fileID = \$(this).attr('id').replace('cropperLink_', '');\n\n // close all\n if(cropperVisible) {\n \$('.cropperDivs').hide('slow').html('');\n \$('#thumbnail').imgAreaSelect({ hide: true});\n }\n\n var me = \$(this);\n\n if(cropperVisible == fileID) {\n cropperVisible = false;\n me.html('" . str_replace('\'', '\\\'', FormBuilder::AdminIcon('crop')) . "');\n\n } else {\n \$('#cropperDiv_' + fileID).load('?ado=imagemgrCropperForm&ajax=true&adminLayout=empty&cropperForm=' + fileName, function(){\n me.html('" . str_replace('\'', '\\\'', FormBuilder::AdminIcon('crop')) . "');\n }).show('slow');\n cropperVisible = fileID;\n }\n });\n\n \$('#images_ul').sortable({\n update : function(){\n \$.get('?ado=imagemgrReorderImage&ajax=true&adminLayout=empty&' + \$('#images_ul').sortable('serialize', {}));\n var i = 0;\n \$('.image-i').each(function(){\n var h = (i == 0) ? '0' : i;\n \$(this).html(h);\n i++;\n });\n }\n });\n\n \$('li.sortable-image').hover(function(){\n \$(this).addClass('image-hover');\n }, function(){\n \$(this).removeClass('image-hover');\n });\n\n \$('.image-caption').editable('?ado=imagemgrChangeCaption&adminLayout=empty&ajax=true', {\n type : 'text',\n cancel : 'Cancel',\n submit : 'OK',\n indicator : 'Updating. . .',\n tooltip : 'Double click to edit...',\n cssclass : 'image-caption-popup',\n event : 'dblclick'\n });"; $this->accelJS()->ready($jQueryReadyCode); // images if ($maxImages = $this->obj->maxImages()) { $form .= "<h3>Images</h3>"; if ($instructions) { $form .= $instructions; } $i = 0; $alreadyHasImage = $this->obj->getImage(); if ($alreadyHasImage) { $form .= "<ul id='images_ul'>"; } for ($i; $i < $maxImages && $i < $imageLimit; $i++) { $image = $this->obj->getImage($i); if (!$image) { $image = new Image(); } // smart front end/ back end $imageFormMethod = $this->contentID ? 'frontForm' : 'form'; if ($alreadyHasImage) { $form .= "<li id='img_" . str_replace("_", self::WEB_SAFE_DELIM, $image->getID()) . "' class='sortable-image'>"; } $form .= $image->{$imageFormMethod}(); if ($alreadyHasImage) { $form .= "</li>"; } } if ($alreadyHasImage) { $form .= "</ul>"; } $form .= "<div class='clear'></div>"; if ($i < $maxImages) { $form .= $this->addAJAXLink(0, $maxImages - 1, 'image'); } } return $form; }