hl198181/neptune · jquery.plupload.queue.js
javascript logo
function updateList() {
					var fileList = $('ul.plupload_filelist', target).html(''), inputCount = 0, inputHTML;

					$.each(uploader.files, function(i, file) {
						inputHTML = '';

						if (file.status == plupload.DONE) {
							if (file.target_name) {
								inputHTML += '<input type="hidden" name="' + id + '_' + inputCount + '_tmpname" value="' + plupload.xmlEncode(file.target_name) + '" />';
							}

							inputHTML += '<input type="hidden" name="' + id + '_' + inputCount + '_name" value="' + plupload.xmlEncode(file.name) + '" />';
							inputHTML += '<input type="hidden" name="' + id + '_' + inputCount + '_status" value="' + (file.status == plupload.DONE ? 'done' : 'failed') + '" />';
	
							inputCount++;

							$('#' + id + '_count').val(inputCount);
						}

						fileList.append(
							'<li id="' + file.id + '">' +
								'<div class="plupload_file_name"><span>' + file.name + '</span></div>' +
								'<div class="plupload_file_action"><a href="#"></a></div>' +
								'<div class="plupload_file_status">' + file.percent + '%</div>' +
								'<div class="plupload_file_size">' + plupload.formatSize(file.size) + '</div>' +
								'<div class="plupload_clearer">&nbsp;</div>' +
								inputHTML +
							'</li>'
						);

						handleStatus(file);

						$('#' + file.id + '.plupload_delete a').click(function(e) {
							$('#' + file.id).remove();
							uploader.removeFile(file);

							e.preventDefault();
						});
					});

					$('span.plupload_total_file_size', target).html(plupload.formatSize(uploader.total.size));

					if (uploader.total.queued === 0) {
						$('span.plupload_add_text', target).html(_('Add Files'));
					} else {
						$('span.plupload_add_text', target).html(o.sprintf(_('%d files queued'), uploader.total.queued));
					}

					$('a.plupload_start', target).toggleClass('plupload_disabled', uploader.files.length == (uploader.total.uploaded + uploader.total.failed));

					// Scroll to end of file list
					fileList[0].scrollTop = fileList[0].scrollHeight;

					updateTotalProgress();

					// Re-add drag message if there is no files
					if (!uploader.files.length && uploader.features.dragdrop && uploader.settings.dragdrop) {
						$('#' + id + '_filelist').append('<li class="plupload_droptext">' + _("Drag files here.") + '</li>');
					}
				}
Similar code snippets
1.
hl198181/neptune · jquery.plupload.queue.js
Match rating: 80.74% · See similar code snippets
javascript logo
function(i, file) {
						inputHTML = '';

						if (file.status == plupload.DONE) {
							if (file.target_name) {
								inputHTML += '<input type="hidden" name="' + id + '_' + inputCount + '_tmpname" value="' + plupload.xmlEncode(file.target_name) + '" />';
							}

							inputHTML += '<input type="hidden" name="' + id + '_' + inputCount + '_name" value="' + plupload.xmlEncode(file.name) + '" />';
							inputHTML += '<input type="hidden" name="' + id + '_' + inputCount + '_status" value="' + (file.status == plupload.DONE ? 'done' : 'failed') + '" />';
	
							inputCount++;

							$('#' + id + '_count').val(inputCount);
						}

						fileList.append(
							'<li id="' + file.id + '">' +
								'<div class="plupload_file_name"><span>' + file.name + '</span></div>' +
								'<div class="plupload_file_action"><a href="#"></a></div>' +
								'<div class="plupload_file_status">' + file.percent + '%</div>' +
								'<div class="plupload_file_size">' + plupload.formatSize(file.size) + '</div>' +
								'<div class="plupload_clearer">&nbsp;</div>' +
								inputHTML +
							'</li>'
						);

						handleStatus(file);

						$('#' + file.id + '.plupload_delete a').click(function(e) {
							$('#' + file.id).remove();
							uploader.removeFile(file);

							e.preventDefault();
						});
					}
2.
hl198181/neptune · jquery.ui.plupload.js
Match rating: 74.16% · See similar code snippets
javascript logo
function() {
		var self = this;

		// re-add from fresh
		$('.plupload_file_fields', this.filelist).html('');

		plupload.each(this.uploader.files, function(file, count) {
			var fields = ''
			, id = self.id + '_' + count
			;

			if (file.target_name) {
				fields += '<input type="hidden" name="' + id + '_tmpname" value="'+plupload.xmlEncode(file.target_name)+'" />';
			}
			fields += '<input type="hidden" name="' + id + '_name" value="'+plupload.xmlEncode(file.name)+'" />';
			fields += '<input type="hidden" name="' + id + '_status" value="' + (file.status === plupload.DONE ? 'done' : 'failed') + '" />';

			$('#' + file.id).find('.plupload_file_fields').html(fields);
		});

		this.counter.val(this.uploader.files.length);
	}
3.
hl198181/neptune · jquery.ui.plupload.js
Match rating: 71.33% · See similar code snippets
javascript logo
function(file, count) {
			var fields = ''
			, id = self.id + '_' + count
			;

			if (file.target_name) {
				fields += '<input type="hidden" name="' + id + '_tmpname" value="'+plupload.xmlEncode(file.target_name)+'" />';
			}
			fields += '<input type="hidden" name="' + id + '_name" value="'+plupload.xmlEncode(file.name)+'" />';
			fields += '<input type="hidden" name="' + id + '_status" value="' + (file.status === plupload.DONE ? 'done' : 'failed') + '" />';

			$('#' + file.id).find('.plupload_file_fields').html(fields);
		}
4.
jsbin/jsbin · save.js
Match rating: 52.2% · See similar code snippets
javascript logo
function setupform(method) {
var $form = $('form#saveform').empty()
    .append('<input type="hidden" name="javascript" />')
    .append('<input type="hidden" name="html" />')
    .append('<input type="hidden" name="css" />')
    .append('<input type="hidden" name="method" />')
    .append('<input type="hidden" name="_csrf" value="' + jsbin.state.token + '" />')
    .append('<input type="hidden" name="settings" />')
    .append('<input type="hidden" name="checksum" />');

  var settings = {};

  if (jsbin.state.processors) {
    settings.processors = jsbin.state.processors;
  }

  // this prevents new revisions forking off the welcome bin
  // because it's looking silly!
  if (jsbin.state.code === 'welcome') {
    $form.attr('action', '/save');
  }

  $form.find('input[name=settings]').val(JSON.stringify(settings));
  $form.find('input[name=javascript]').val(editors.javascript.getCode());
  $form.find('input[name=css]').val(editors.css.getCode());
  $form.find('input[name=html]').val(editors.html.getCode());
  $form.find('input[name=method]').val(method);
  $form.find('input[name=checksum]').val(jsbin.state.checksum);

  return $form;
}
5.
easysoft/zui · kindeditor.js
Match rating: 48.44% · See similar code snippets
javascript logo
function(options) {
            var self = this,
                button = K(options.button),
                fieldName = options.fieldName || 'file',
                url = options.url || '',
                title = button.val(),
                extraParams = options.extraParams || {},
                cls = button[0].className || '',
                target = options.target || 'kindeditor_upload_iframe_' + new Date().getTime();
            options.afterError = options.afterError || function(str) {
                alert(str);
            };
            var hiddenElements = [];
            for(var k in extraParams) {
                hiddenElements.push('<input type="hidden" name="' + k + '" value="' + extraParams[k] + '" />');
            }
            var html = [
                '<div class="ke-inline-block ' + cls + '">', (options.target ? '' : '<iframe name="' + target + '" style="display:none;"></iframe>'), (options.form ? '<div class="ke-upload-area">' : '<form class="ke-upload-area ke-form" method="post" enctype="multipart/form-data" target="' + target + '" action="' + url + '">'),
                '<span class="ke-button-common">',
                hiddenElements.join(''),
                '<input type="button" class="ke-button-common ke-button" value="' + title + '" />',
                '</span>',
                '<input type="file" class="ke-upload-file" name="' + fieldName + '" tabindex="-1" />', (options.form ? '</div>' : '</form>'),
                '</div>'
            ].join('');
            var div = K(html, button.doc);
            button.hide();
            button.before(div);
            self.div = div;
            self.button = button;
            self.iframe = options.target ? K('iframe[name="' + target + '"]') : K('iframe', div);
            self.form = options.form ? K(options.form) : K('form', div);
            self.fileBox = K('.ke-upload-file', div);
            self.options = options;
        }
6.
ariatemplates/hashspace · plunker.js
Match rating: 48.36% · See similar code snippets
javascript logo
function plunkerExport(event, playground) {
  var form = createElement('<form style="display: none;" method="post" action="http://plnkr.co/edit/#/?p=preview" target="_blank"></form>');
  var addField = function(name, value) {
    var input = createElement('<input type="hidden" name="' + name + '">');
    input.setAttribute('value', value);
    form.appendChild(input);
  };


  addField('description', playground.data.sampleTitle + "\n" + window.location);
  addField('tags[]', "hashspace");
  addField('files[index.html]', [
    '<!doctype html>',
    '<html>',
    '  <head>',
    '    <link rel="stylesheet" type="text/css" href="http://hashspace.ariatemplates.com/css/samples.css" />',
    '    <script src="http://noder-js.ariatemplates.com/dist/v1.6.0/noder.dev.js" type="text/javascript">',
    '    {',
    '      packaging: {',
    '        preprocessors: [{',
    '          pattern: /\\.hsp$/,',
    '          module: "hsp/compiler/compile"',
    '        }, {',
    '          pattern: /\\.js$/,',
    '          module: "hsp/transpiler/transpile"',
    '        }]',
    '      }',
    '    }',
    '    </script>',
    '    <script src="http://hashspace.ariatemplates.com/dist/' + window.hashspace_version + '/hashspace-noder.js"></script>',
    '    <script src="http://hashspace.ariatemplates.com/dist/' + window.hashspace_version + '/hashspace-noder-compiler.js"></script>',
    '  </head>',
    '  <body>\n',
    '    <div id="sample"></div>',
    '',
    '    <script type="application/x-noder">',
    '      var sample = require("./sample.hsp"),',
    '          template = sample.template,',
    '          data = sample.data || [];',
    '',
    '      if (typeof data === "function") {',
    '        data = data.call(sample);',
    '      }',
    '      template.apply(sample, data).render("sample");',
    '    </script>',
    '  </body>',
    '</html>'
  ].join('\n'));
  addField('files[sample.hsp]', [
    playground.editor.getValue()
  ].join('\n'));

  document.body.appendChild(form);
  form.submit();
  document.body.removeChild(form);
  event.preventDefault();
}
7.
hl198181/neptune · jquery.ui.plupload.js
Match rating: 47.84% · See similar code snippets
javascript logo
function() {
		var id = this.element.attr('id');
		if (!id) {
			id = plupload.guid();
			this.element.attr('id', id);
		}
		this.id = id;
				
		// backup the elements initial state
		this.contents_bak = this.element.html();
		renderUI(this.element);
		
		// container, just in case
		this.container = $('.plupload_container', this.element).attr('id', id + '_container');	

		this.content = $('.plupload_content', this.element);
		
		if ($.fn.resizable) {
			this.container.resizable({ 
				handles: 's',
				minHeight: 300
			});
		}
		
		// list of files, may become sortable
		this.filelist = $('.plupload_filelist_content', this.container)
			.attr({
				id: id + '_filelist',
				unselectable: 'on'
			});
		

		// buttons
		this.browse_button = $('.plupload_add', this.container).attr('id', id + '_browse');
		this.start_button = $('.plupload_start', this.container).attr('id', id + '_start');
		this.stop_button = $('.plupload_stop', this.container).attr('id', id + '_stop');
		this.thumbs_switcher = $('#' + id + '_view_thumbs');
		this.list_switcher = $('#' + id + '_view_list');
		
		if ($.ui.button) {
			this.browse_button.button({
				icons: { primary: 'ui-icon-circle-plus' },
				disabled: true
			});
			
			this.start_button.button({
				icons: { primary: 'ui-icon-circle-arrow-e' },
				disabled: true
			});
			
			this.stop_button.button({
				icons: { primary: 'ui-icon-circle-close' }
			});
      
			this.list_switcher.button({
				text: false,
				icons: { secondary: "ui-icon-grip-dotted-horizontal" }
			});

			this.thumbs_switcher.button({
				text: false,
				icons: { secondary: "ui-icon-image" }
			});
		}
		
		// progressbar
		this.progressbar = $('.plupload_progress_container', this.container);		
		
		if ($.ui.progressbar) {
			this.progressbar.progressbar();
		}
		
		// counter
		this.counter = $('.plupload_count', this.element)
			.attr({
				id: id + '_count',
				name: id + '_count'
			});
					
		// initialize uploader instance
		this._initUploader();
	}
8.
easysoft/zui · kindeditor.js
Match rating: 47.61% · See similar code snippets
javascript logo
function() {
            var html = ['<div style="padding:20px;">',
                '<div class="ke-dialog-row">',
                '<label for="keName">' + lang.name + '</label>',
                '<input class="ke-input-text" type="text" id="keName" name="name" value="" style="width:100px;" />',
                '</div>',
                '</div>'
            ].join('');
            var dialog = self.createDialog({
                name: name,
                width: 300,
                title: self.lang(name),
                body: html,
                yesBtn: {
                    name: self.lang('yes'),
                    click: function(e) {
                        self.insertHtml('<a name="' + nameBox.val() + '">').hideDialog().focus();
                    }
                }
            });
            var div = dialog.div,
                nameBox = K('input[name="name"]', div);
            var img = self.plugin.getSelectedAnchor();
            if(img) {
                nameBox.val(unescape(img.attr('data-ke-name')));
            }
            nameBox[0].focus();
            nameBox[0].select();
        }
9.
ansman/validate.js · validate-helpers-spec.js
Match rating: 46.77% · See similar code snippets
javascript logo
function() {
    it("handles empty input", function() {
      expect(validate.collectFormValues()).toEqual({});
    });

    it("handles simple forms", function() {
      var form = document.createElement("form");
      form.innerHTML = '' +
        '<input type="text" name="text" value="example text">' +
        '<input type="text" name="empty-text">' +
        '<input type="email" name="email" value="example@email.com">' +
        '<input type="password" name="password" value="password!">' +
        '<input type="checkbox" name="selected-checkbox" value="checkbox" checked>' +
        '<input type="checkbox" name="deselected-checkbox" value="checkbox">' +
        '<input type="date" name="date" value="2015-03-08">' +
        '<input type="hidden" name="hidden" value="hidden">' +
        '<input type="number" name="number" value="4711">' +
        '<input type="url" name="url" value="http://validatejs.org">' +
        '<input type="radio" name="single-checked-radio" value="radio" checked>' +
        '<input type="radio" name="single-unchecked-radio" value="radio">' +
        '<radiogroup>' +
        '  <input type="radio" name="checked-radio" value="radio1">' +
        '  <input type="radio" name="checked-radio" value="radio2" checked>' +
        '  <input type="radio" name="checked-radio" value="radio3">' +
        '</radiogroup>' +
        '<radiogroup>' +
        '  <input type="radio" name="unchecked-radio" value="radio1">' +
        '  <input type="radio" name="unchecked-radio" value="radio2">' +
        '  <input type="radio" name="unchecked-radio" value="radio3">' +
        '</radiogroup>' +
        '<select name="selected-dropdown">' +
        '  <option>' +
        '  <option value="option1">' +
        '  <option value="option2" selected>' +
        '</select>' +
        '<select name="unselected-dropdown">' +
        '  <option>' +
        '  <option value="option1">' +
        '  <option value="option2">' +
        '</select>' +
        '<textarea name="textarea-ignored" data-ignored>the textarea</textarea>'+
        '<textarea name="textarea">the textarea</textarea>';

      expect(validate.collectFormValues(form)).toEqual({
        text: "example text",
        "empty-text": null,
        email: "example@email.com",
        password: "password!",
        "selected-checkbox": "checkbox",
        "deselected-checkbox": null,
        date: "2015-03-08",
        hidden: "hidden",
        number: 4711,
        url: "http://validatejs.org",
        "single-checked-radio": "radio",
        "single-unchecked-radio": null,
        "checked-radio": "radio2",
        "unchecked-radio": null,
        "selected-dropdown": "option2",
        "unselected-dropdown": null,
        "textarea": "the textarea"
        });
    });

    it("has an option to nullify empty and trim strings", function() {
      var form = document.createElement("form");
      form.innerHTML = '' +
        '<input type="text" name="normal" value="normal">' +
        '<input type="text" name="empty">' +
        '<input type="text" name="whitespace" value=" ">' +
        '<input type="text" name="trimmed" value=" foo ">';

      var options = {nullify: false};
      expect(validate.collectFormValues(form, options)).toEqual({
        normal: "normal",
        empty: "",
        whitespace: " ",
        trimmed: " foo "
      });

      options = {nullify: true};
      expect(validate.collectFormValues(form, options)).toEqual({
        normal: "normal",
        empty: null,
        whitespace: " ",
        trimmed: " foo "
      });

      options = {trim: true};
      expect(validate.collectFormValues(form, options)).toEqual({
        normal: "normal",
        empty: null,
        whitespace: null,
        trimmed: "foo"
      });
    });

    it("has a way to ignore elements", function() {
      var form = document.createElement("form");
      form.innerHTML = '' +
        '<input type="text" name="ignored" value="ignored" data-ignored>' +
        '<select name="ignored-select" data-ignored>' +
        '  <option value="select" selected>Select</option>' +
        '</select>';
      expect(validate.collectFormValues(form)).toEqual({});
    });

    it("uses true/false for checkboxes without a value", function() {
      var form = document.createElement("form");
      form.innerHTML = '' +
        '<input type="checkbox" name="checked" checked>' +
        '<input type="checkbox" name="unchecked">';

      expect(validate.collectFormValues(form)).toEqual({
        checked: true,
        unchecked: false
      });
    });

    it("accepts jquery elements", function() {
      var $form = $('<form><input value="foobar" name="input" /></form>');
      expect(validate.collectFormValues($form)).toEqual({
        input: "foobar"
      });
    });

    it("empty jquery collections return empty objects", function() {
      expect(validate.collectFormValues($())).toEqual({});
    });

    it("handles empty and invalid numeric inputs", function() {
      var form = document.createElement("form");
      form.innerHTML = '' +
        '<input type="number" name="emptyNumber">' +
        '<input type="number" name="invalidNumber" value="abc">';

      expect(validate.collectFormValues(form)).toEqual({
        emptyNumber: null,
        invalidNumber: null
      });
    });

    it("handles select tags with 'multiple'", function() {
      var form = document.createElement("form");
      form.innerHTML = '' +
        '<select name="selected-dropdown" multiple>' +
        '  <option>' +
        '  <option value="option1">' +
        '  <option value="option2" selected>' +
        '  <option value="option3">' +
        '  <option value="option4" selected>' +
        '</select>' +
        '<select name="unselected-dropdown" multiple>' +
        '  <option>' +
        '  <option value="option1">' +
        '  <option value="option2">' +
        '  <option value="option3">' +
        '  <option value="option4">' +
        '</select>' +
        '<select name="empty-value" multiple>' +
        '  <option selected>' +
        '</select>';

      expect(validate.collectFormValues(form)).toEqual({
        "selected-dropdown": ["option2", "option4"],
        "unselected-dropdown": [],
        "empty-value": [null]
      });
    });

    it("escapes periods", function() {
      var form = document.createElement("form");
      form.innerHTML = '<input type="text" name="foo.bar.baz" value="quux" />';

      expect(validate.collectFormValues(form)).toEqual({
        "foo\\\\.bar\\\\.baz": "quux"
      });
    });
  }
10.
snapappointments/bootstrap-select · plnkrOpener.js
Match rating: 46.7% · See similar code snippets
javascript logo
function formPostData(url, fields) {
    var form = $('<form style="display: none;" method="post" action="' + url + '"></form>');
    $.each(fields, function(name, value) {
      var input = $('<input type="hidden" name="' + name + '">');
      input.attr('value', value);
      form.append(input);
    });

    $(document).find('body').append(form);

    form[0].submit(function(e) {
      e.preventDefault();
    });

    form.remove();
  }