Permalink
Browse files

First commit, unstable

  • Loading branch information...
0 parents commit 17c6a9a5449cffd3ae92cf2fce52d869f21944c7 @ClementGautier committed Oct 25, 2011
7 README
@@ -0,0 +1,7 @@
+Add some features to forms using jQuery and jQuery UI :
+ * autocomplete
+ * datepicker
+ * File Upload Ajax
+ * and much if we have time
+
+Actually in development stage
@@ -0,0 +1,9 @@
+sfJQueryExtraFormFile:
+ actAs: ~
+ columns:
+ name:
+ type: string(255)
+ notnull: true
+ src:
+ type: string(255)
+ notnull: true
@@ -0,0 +1,13 @@
+<?php
+
+/**
+ * PluginsfJQueryExtraFormFile form.
+ *
+ * @package ##PROJECT_NAME##
+ * @subpackage filter
+ * @author ##AUTHOR_NAME##
+ * @version SVN: $Id: sfDoctrineFormFilterPluginTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
+ */
+abstract class PluginsfJQueryExtraFormFileFormFilter extends BasesfJQueryExtraFormFileFormFilter
+{
+}
@@ -0,0 +1,13 @@
+<?php
+
+/**
+ * PluginsfJQueryExtraFormFile form.
+ *
+ * @package ##PROJECT_NAME##
+ * @subpackage form
+ * @author ##AUTHOR_NAME##
+ * @version SVN: $Id: sfDoctrineFormPluginTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
+ */
+abstract class PluginsfJQueryExtraFormFileForm extends BasesfJQueryExtraFormFileForm
+{
+}
@@ -0,0 +1,16 @@
+<?php
+
+/**
+ * PluginsfJQueryExtraFormFile
+ *
+ * This class has been auto-generated by the Doctrine ORM Framework
+ *
+ * @package ##PACKAGE##
+ * @subpackage ##SUBPACKAGE##
+ * @author ##NAME## <##EMAIL##>
+ * @version SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $
+ */
+abstract class PluginsfJQueryExtraFormFile extends BasesfJQueryExtraFormFile
+{
+
+}
@@ -0,0 +1,19 @@
+<?php
+
+/**
+ * PluginsfJQueryExtraFormFileTable
+ *
+ * This class has been auto-generated by the Doctrine ORM Framework
+ */
+class PluginsfJQueryExtraFormFileTable extends Doctrine_Table
+{
+ /**
+ * Returns an instance of this class.
+ *
+ * @return object PluginsfJQueryExtraFormFileTable
+ */
+ public static function getInstance()
+ {
+ return Doctrine_Core::getTable('PluginsfJQueryExtraFormFile');
+ }
+}
@@ -0,0 +1,93 @@
+<?php
+
+/**
+ * sfJQueryExtraWidgetInputFile represents an ajax upload HTML input tag.
+ *
+ * @package sfJQueryExtraFormPlugin
+ * @subpackage widget
+ * @author Clement Gautier <clement.gautier@smartit.fr>
+ */
+class sfJQueryExtraWidgetInputFile extends sfWidgetFormInputFile
+{
+ /**
+ * Configures the current widget.
+ *
+ * @param array $options An array of options
+ * @param array $attributes An array of default HTML attributes
+ *
+ * @see sfWidgetFormInput
+ */
+ protected function configure($options = array(), $attributes = array())
+ {
+ parent::configure($options, $attributes);
+ }
+
+ public function render($name, $value = null, $attributes = array(), $errors = array())
+ {
+ $html = '<div class="fileupload-buttonbar">
+ <label class="fileinput-button">
+ <span>Add files...</span>
+ '.parent::render($name, $value, $attributes, $errors).'
+ </label>
+ <button type="submit" class="start">Start upload</button>
+ <button type="reset" class="cancel">Cancel upload</button>
+ <button type="button" class="delete">Delete files</button>
+ </div>';
+ $html .= $this->buildJS($name);
+ return $html;
+ }
+
+ public function buildJS($name)
+ {
+ sfContext::getInstance()->getConfiguration()->loadHelpers('JavascriptBase');
+ $js = <<<EOF
+$(function () {
+ 'use strict';
+
+ // Initialize the jQuery File Upload widget:
+ $('#$name').parent().fileupload();
+
+ // Load existing files:
+ $.getJSON($('#$name').parent('form').prop('action'), function (files) {
+ var fu = $('#$name').parent().data('fileupload');
+ fu._adjustMaxNumberOfFiles(-files.length);
+ fu._renderDownload(files)
+ .appendTo($('#$name').parent().find('.files'))
+ .fadeIn(function () {
+ // Fix for IE7 and lower:
+ $(this).show();
+ });
+ });
+
+ // Open download dialogs via iframes,
+ // to prevent aborting current uploads:
+ $('#fileupload .files a:not([target^=_blank])').live('click', function (e) {
+ e.preventDefault();
+ $('<iframe style="display:none;"></iframe>')
+ .prop('src', this.href)
+ .appendTo('body');
+ });
+
+});
+EOF;
+
+ return javascript_tag($js);
+ }
+
+ public function getStylesheets()
+ {
+ return array_merge(array(
+ '/sfJQueryExtraFormPlugin/css/jquery.fileupload-ui.css' => 'all',
+ ), parent::getStylesheets());
+ }
+
+ public function getJavascripts()
+ {
+ return array_merge(array(
+ '/sfJQueryExtraFormPlugin/js/jquery.iframe-transport.js',
+ '/sfJQueryExtraFormPlugin/js/jquery.fileupload.js',
+ '/sfJQueryExtraFormPlugin/js/jquery.fileupload-ui.js',
+ ), parent::getJavascripts());
+ }
+
+}
@@ -0,0 +1,22 @@
+<?php
+
+class sfJQueryExtraWidgetInputText extends sfWidgetFormInputText
+{
+ protected function configure($options = array(), $attributes = array())
+ {
+ parent::configure($options, $attributes);
+
+ $this->setOption('type', 'text');
+ }
+
+ public function render($name, $value = null, $attributes = array(), $errors = array())
+ {
+ sfContext::getInstance()->getConfiguration()->loadHelpers('JavascriptBase');
+
+ $attributes = $this->fixFormId(array_merge(array('type' => $this->getOption('type'), 'name' => $name, 'value' => $value), $attributes));
+
+ $js = '$(function (){ $("#'.$attributes['id'].'").autocomplete(); });';
+
+ return parent::render($name, $value, $attributes, $errors)."\n".javascript_tag($js);
+ }
+}
@@ -0,0 +1,100 @@
+@charset 'UTF-8';
+/*
+ * jQuery File Upload UI Plugin CSS 5.0.6
+ * https://github.com/blueimp/jQuery-File-Upload
+ *
+ * Copyright 2010, Sebastian Tschan
+ * https://blueimp.net
+ *
+ * Licensed under the MIT license:
+ * http://creativecommons.org/licenses/MIT/
+ */
+
+.fileupload-buttonbar .ui-button input {
+ position: absolute;
+ top: 0;
+ right: 0;
+ margin: 0;
+ border: solid transparent;
+ border-width: 0 0 100px 200px;
+ opacity: 0;
+ filter: alpha(opacity=0);
+ -o-transform: translate(250px, -50px) scale(1);
+ -moz-transform: translate(-300px, 0) scale(4);
+ direction: ltr;
+ cursor: pointer;
+}
+
+.fileinput-button {
+ overflow: hidden;
+}
+
+/* Fix for IE 6: */
+*html .fileinput-button {
+ padding: 2px 0;
+}
+
+/* Fix for IE 7: */
+*+html .fileinput-button {
+ padding: 2px 0;
+}
+
+.fileupload-buttonbar {
+ padding: 0.2em 0.4em;
+}
+
+.fileupload-buttonbar .ui-button {
+ vertical-align: middle;
+}
+
+.fileupload-content {
+ padding: 0.2em 0.4em;
+ border-top-width: 0;
+}
+
+.fileupload-content .ui-progressbar {
+ width: 200px;
+ height: 20px;
+}
+
+.fileupload-content .ui-progressbar-value {
+ background: url(pbar-ani.gif);
+}
+
+.fileupload-content .fileupload-progressbar {
+ width: 400px;
+ margin: 10px 0;
+}
+
+.files {
+ margin: 10px 0;
+ border-collapse: collapse;
+}
+
+.files td {
+ padding: 5px;
+ border-spacing: 5px;
+}
+
+.files img {
+ border: none;
+}
+
+.files .name {
+ padding: 0 10px;
+}
+
+.files .size {
+ padding: 0 10px 0 0;
+ text-align: right;
+ white-space: nowrap;
+}
+
+.ui-state-disabled .ui-state-disabled {
+ opacity: 1;
+ filter: alpha(opacity=100);
+}
+
+.ui-state-disabled input {
+ cursor: default;
+}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.

0 comments on commit 17c6a9a

Please sign in to comment.