- Fixed stream utils + tests
- Asset Rebuild
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* This file is generated by the "yii asset" command.
|
||||
* DO NOT MODIFY THIS FILE DIRECTLY.
|
||||
* @version 2018-04-11 14:52:08
|
||||
* @version 2018-06-26 17:00:01
|
||||
*/
|
||||
return [
|
||||
'all' => [
|
||||
@ -10,10 +10,10 @@ return [
|
||||
'basePath' => '@webroot-static',
|
||||
'baseUrl' => '@web-static',
|
||||
'js' => [
|
||||
'js/all-cdd03cdcb17517e3d6d54d52287b162d.js',
|
||||
'js/all-ce58fb7858b808766e16730bae74d4cb.js',
|
||||
],
|
||||
'css' => [
|
||||
'css/all-2febca3798ebc2dcc727616c385acb02.css',
|
||||
'css/all-f2b44a6173358e1ad596f24b864444fe.css',
|
||||
],
|
||||
'sourcePath' => null,
|
||||
'depends' => [],
|
||||
@ -199,6 +199,23 @@ return [
|
||||
'all',
|
||||
],
|
||||
],
|
||||
'humhub\\assets\\ProsemirrorEditorAsset' => [
|
||||
'sourcePath' => null,
|
||||
'js' => [],
|
||||
'css' => [],
|
||||
'depends' => [
|
||||
'all',
|
||||
],
|
||||
],
|
||||
'humhub\\modules\\content\\assets\\ProseMirrorRichTextAsset' => [
|
||||
'sourcePath' => null,
|
||||
'js' => [],
|
||||
'css' => [],
|
||||
'depends' => [
|
||||
'humhub\\assets\\ProsemirrorEditorAsset',
|
||||
'all',
|
||||
],
|
||||
],
|
||||
'humhub\\modules\\user\\assets\\UserAsset' => [
|
||||
'sourcePath' => null,
|
||||
'js' => [],
|
||||
@ -294,6 +311,24 @@ return [
|
||||
'all',
|
||||
],
|
||||
],
|
||||
'humhub\\modules\\topic\\assets\\TopicAsset' => [
|
||||
'sourcePath' => null,
|
||||
'js' => [],
|
||||
'css' => [],
|
||||
'depends' => [
|
||||
'humhub\\assets\\CoreApiAsset',
|
||||
'all',
|
||||
],
|
||||
],
|
||||
'humhub\\modules\\ui\\filter\\assets\\FilterAsset' => [
|
||||
'sourcePath' => null,
|
||||
'js' => [],
|
||||
'css' => [],
|
||||
'depends' => [
|
||||
'humhub\\assets\\CoreApiAsset',
|
||||
'all',
|
||||
],
|
||||
],
|
||||
'humhub\\modules\\comment\\assets\\CommentAsset' => [
|
||||
'sourcePath' => null,
|
||||
'js' => [],
|
||||
@ -360,6 +395,22 @@ return [
|
||||
'all',
|
||||
],
|
||||
],
|
||||
'humhub\\assets\\SocketIoAsset' => [
|
||||
'sourcePath' => null,
|
||||
'js' => [],
|
||||
'css' => [],
|
||||
'depends' => [
|
||||
'all',
|
||||
],
|
||||
],
|
||||
'humhub\\assets\\OpenSansAsset' => [
|
||||
'sourcePath' => null,
|
||||
'js' => [],
|
||||
'css' => [],
|
||||
'depends' => [
|
||||
'all',
|
||||
],
|
||||
],
|
||||
'humhub\\assets\\AppAsset' => [
|
||||
'sourcePath' => null,
|
||||
'js' => [],
|
||||
@ -381,6 +432,7 @@ return [
|
||||
'humhub\\assets\\AtJsAsset',
|
||||
'humhub\\assets\\AnimateCssAsset',
|
||||
'humhub\\assets\\CoreApiAsset',
|
||||
'humhub\\modules\\content\\assets\\ProseMirrorRichTextAsset',
|
||||
'humhub\\modules\\user\\assets\\UserAsset',
|
||||
'humhub\\modules\\live\\assets\\LiveAsset',
|
||||
'humhub\\modules\\notification\\assets\\NotificationAsset',
|
||||
@ -390,6 +442,8 @@ return [
|
||||
'humhub\\modules\\file\\assets\\FileAsset',
|
||||
'humhub\\modules\\post\\assets\\PostAsset',
|
||||
'humhub\\modules\\space\\assets\\SpaceAsset',
|
||||
'humhub\\modules\\topic\\assets\\TopicAsset',
|
||||
'humhub\\modules\\ui\\filter\\assets\\FilterAsset',
|
||||
'humhub\\modules\\comment\\assets\\CommentAsset',
|
||||
'humhub\\assets\\NProgressAsset',
|
||||
'humhub\\assets\\IE9FixesAsset',
|
||||
@ -397,6 +451,8 @@ return [
|
||||
'humhub\\assets\\PagedownConverterAsset',
|
||||
'humhub\\assets\\ClipboardJsAsset',
|
||||
'humhub\\assets\\ImagesLoadedAsset',
|
||||
'humhub\\assets\\SocketIoAsset',
|
||||
'humhub\\assets\\OpenSansAsset',
|
||||
'all',
|
||||
],
|
||||
],
|
||||
|
@ -209,7 +209,7 @@ humhub.module('comment', function (module, require, $) {
|
||||
};
|
||||
|
||||
var toggleComment = function(evt) {
|
||||
let visible = evt.$target.is(':visible');
|
||||
var visible = evt.$target.is(':visible');
|
||||
evt.$target.slideToggle(undefined, function() {
|
||||
evt.$target.find('.humhub-ui-richtext').trigger('focus');
|
||||
});
|
||||
|
@ -56,9 +56,6 @@ humhub.module('content', function (module, require, $) {
|
||||
options = options || {};
|
||||
var that = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (!that.hasAction('delete')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var modalOptions = options.modal || module.config.modal.deleteConfirm;
|
||||
|
||||
|
@ -164,6 +164,8 @@ humhub.module('stream.Stream', function (module, require, $) {
|
||||
return Promise.resolve(this.handleLastEntryLoaded());
|
||||
} else if (request.options.insertAfter) {
|
||||
return this.handleInsertAfterResponse(request);
|
||||
} else if(request.options.prepend) {
|
||||
return this.prependResponseEntries(request);
|
||||
} else {
|
||||
return this.handleLoadMoreResponse(request);
|
||||
}
|
||||
@ -189,7 +191,11 @@ humhub.module('stream.Stream', function (module, require, $) {
|
||||
};
|
||||
|
||||
Stream.prototype.canLoadMore = function () {
|
||||
return !(this.state.loading || this.state.lastEntryLoaded);
|
||||
return !this.isLoading() && !this.state.lastEntryLoaded;
|
||||
};
|
||||
|
||||
Stream.prototype.isLoading = function () {
|
||||
return this.state.loading === true;
|
||||
};
|
||||
|
||||
Stream.prototype.load = function (options) {
|
||||
@ -398,7 +404,8 @@ humhub.module('stream.Stream', function (module, require, $) {
|
||||
|
||||
entry.loader();
|
||||
|
||||
that.loadEntry(entry.getKey()).then(function ($entryNode) {
|
||||
that.loadEntry(entry.getKey()).then(function (request) {
|
||||
var $entryNode = $(request.getResultHtml());
|
||||
// If no entry was returned it means it is not visible in the current scope
|
||||
if (!$entryNode || !$entryNode.length) {
|
||||
entry.remove();
|
||||
@ -415,6 +422,8 @@ humhub.module('stream.Stream', function (module, require, $) {
|
||||
Stream.prototype.onChange = function () {
|
||||
var hasEntries = this.hasEntries();
|
||||
|
||||
this.$.find('.streamMessage').remove();
|
||||
|
||||
if (!hasEntries) {
|
||||
this.onEmptyStream();
|
||||
} else if (this.isShowSingleEntry()) {
|
||||
@ -424,9 +433,13 @@ humhub.module('stream.Stream', function (module, require, $) {
|
||||
}
|
||||
};
|
||||
|
||||
Stream.prototype.hasFilter = function (filter) {
|
||||
return this.filter.hasFilter(filter);
|
||||
}
|
||||
|
||||
Stream.prototype.onEmptyStream = function () {
|
||||
var hasActiveFilters = this.hasActiveFilters();
|
||||
this.$.find('streamMessage').remove();
|
||||
this.$.find('.streamMessage').remove();
|
||||
|
||||
this.$content.append(string.template(this.static('templates').streamMessage, {
|
||||
message: (hasActiveFilters) ? this.options.streamEmptyFilterMessage : this.options.streamEmptyMessage,
|
||||
|
@ -24,6 +24,7 @@ humhub.module('stream.StreamEntry', function (module, require, $) {
|
||||
var loader = require('ui.loader');
|
||||
var modal = require('ui.modal');
|
||||
var additions = require('ui.additions');
|
||||
var streamModule = require('stream');
|
||||
|
||||
/**
|
||||
* Represents a single stream entry within a stream.
|
||||
@ -74,8 +75,8 @@ humhub.module('stream.StreamEntry', function (module, require, $) {
|
||||
|
||||
promise.then(function ($confirm) {
|
||||
if ($confirm) {
|
||||
that.remove(); // Make sure to remove the wallentry node.
|
||||
module.log.success('success.delete');
|
||||
that.$.remove(); // Make sure to remove the wallentry node.
|
||||
streamModule.log.success('success.delete');
|
||||
}
|
||||
}).catch(function (err) {
|
||||
module.log.error(err, true);
|
||||
@ -194,7 +195,7 @@ humhub.module('stream.StreamEntry', function (module, require, $) {
|
||||
}).status({
|
||||
200: function (response) {
|
||||
that.$.html(response.html);
|
||||
module.log.success('success.edit');
|
||||
streamModule.log.success('success.edit');
|
||||
that.apply();
|
||||
that.highlight();
|
||||
},
|
||||
@ -248,7 +249,7 @@ humhub.module('stream.StreamEntry', function (module, require, $) {
|
||||
client.post(evt).then(function (response) {
|
||||
if (response.success) {
|
||||
that.reload();
|
||||
module.log.success('saved');
|
||||
streamModule.log.success('saved');
|
||||
} else {
|
||||
module.log.error(response, true);
|
||||
that.loader(false);
|
||||
@ -270,7 +271,7 @@ humhub.module('stream.StreamEntry', function (module, require, $) {
|
||||
client.post(evt.url, evt).then(function (data) {
|
||||
if (data.success) {
|
||||
that.remove().then(function () {
|
||||
stream.loadEntry(that.getKey(), {'prepend': true});
|
||||
stream.load({'contentId': that.getKey(), 'prepend': true});
|
||||
});
|
||||
} else if (data.info) {
|
||||
module.log.info(data.info, true);
|
||||
@ -314,8 +315,8 @@ humhub.module('stream.StreamEntry', function (module, require, $) {
|
||||
that.$.fadeOut(function () {
|
||||
that.$.replaceWith($newEntry);
|
||||
// Sinc the response does not only include the node itself we have to search it.
|
||||
that.$ = $newEntry.find(DATA_STREAM_ENTRY_SELECTOR)
|
||||
.addBack(DATA_STREAM_ENTRY_SELECTOR);
|
||||
that.$ = $newEntry.find(StreamEntry.SELECTOR)
|
||||
.addBack(StreamEntry.SELECTOR);
|
||||
|
||||
that.apply();
|
||||
|
||||
@ -338,13 +339,13 @@ humhub.module('stream.StreamEntry', function (module, require, $) {
|
||||
client.post(evt.url).then(function (response) {
|
||||
if (response.success) {
|
||||
// Either just remove entry or reload it in case the stream includes archived entries
|
||||
if (that.stream().hasFilter(FILTER_INCLUDE_ARCHIVED)) {
|
||||
if (that.stream().filter.isActive('entry_archived')) {
|
||||
that.reload().then(function () {
|
||||
module.log.success('success.archive', true);
|
||||
streamModule.log.success('success.archive', true);
|
||||
});
|
||||
} else {
|
||||
that.remove().then(function () {
|
||||
module.log.success('success.archive', true);
|
||||
streamModule.log.success('success.archive', true);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
@ -367,9 +368,9 @@ humhub.module('stream.StreamEntry', function (module, require, $) {
|
||||
client.post(evt.url).then(function (response) {
|
||||
if (response.success) {
|
||||
that.reload().then(function () {
|
||||
module.log.success('success.unarchive', true);
|
||||
streamModule.log.success('success.unarchive', true);
|
||||
}).catch(function (err) {
|
||||
module.log.error('error.default', true);
|
||||
streamModule.log.error('error.default', true);
|
||||
});
|
||||
}
|
||||
}).catch(function (e) {
|
||||
|
@ -57,7 +57,7 @@ humhub.module('stream.StreamRequest', function (module, require, $) {
|
||||
StreamRequest.prototype.load = function() {
|
||||
this.stream.trigger('humhub:stream:beforeLoadEntries', [this.stream, this]);
|
||||
|
||||
if(!this.stream.canLoadMore()) {
|
||||
if(this.stream.isLoading()) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
@ -100,13 +100,15 @@ humhub.module('stream.StreamRequest', function (module, require, $) {
|
||||
};
|
||||
|
||||
StreamRequest.prototype.getRequestData = function() {
|
||||
let data = {};
|
||||
var data = {};
|
||||
|
||||
var that = this;
|
||||
data[this.buildRequestDataKey('sort')] = this.sort;
|
||||
|
||||
data[this.buildRequestDataKey('from')] = this.from;
|
||||
data[this.buildRequestDataKey('limit')] = this.limit;
|
||||
if(!this.contentId) {
|
||||
data[this.buildRequestDataKey('sort')] = this.sort;
|
||||
data[this.buildRequestDataKey('from')] = this.from;
|
||||
data[this.buildRequestDataKey('limit')] = this.limit;
|
||||
}
|
||||
|
||||
data[this.buildRequestDataKey('contentId')] = this.contentId;
|
||||
data[this.buildRequestDataKey('suppressionOnly')] = this.suppressionsOnly;
|
||||
|
@ -32,7 +32,7 @@ class StreamCest
|
||||
$I->amGoingTo('Delte my new post');
|
||||
$I->click('.preferences .dropdown-toggle', $newEntrySelector);
|
||||
$I->wait(1);
|
||||
$I->click('Delete');
|
||||
$I->click('Delete','[data-content-key="12"]');
|
||||
|
||||
$I->waitForElementVisible('#globalModalConfirm', 5);
|
||||
$I->see('Confirm post deletion');
|
||||
@ -70,9 +70,9 @@ class StreamCest
|
||||
$I->dontSeeElement($newEntrySelector);
|
||||
|
||||
$I->amGoingTo('check if my post is visible with filter include archived');
|
||||
$I->click('Filter', '#filter');
|
||||
$I->waitForElementVisible('#filter_entry_archived');
|
||||
$I->click('#filter_entry_archived');
|
||||
$I->click('Filter', '.wall-stream-filter-head');
|
||||
$I->waitForElementVisible('[data-filter-id="entry_archived"]');
|
||||
$I->click('[data-filter-id="entry_archived"]');
|
||||
|
||||
$I->waitForElementVisible($newEntrySelector, 20);
|
||||
$I->expectTo('see my archived post');
|
||||
@ -199,7 +199,7 @@ class StreamCest
|
||||
$I->wantToTest('the empty stream message and filter');
|
||||
|
||||
$I->waitForText('This space is still empty!');
|
||||
$I->dontSeeElement('#filter');
|
||||
$I->dontSeeElement('#wall-stream-filter-nav');
|
||||
|
||||
$I->amGoingTo('create a new post and delete it afterwards');
|
||||
|
||||
@ -208,8 +208,8 @@ class StreamCest
|
||||
$I->wait(1);
|
||||
|
||||
$I->amGoingTo('Delete my new post again.');
|
||||
$I->waitForElementVisible('#wall-stream-filter-nav');
|
||||
$I->dontSee('This space is still empty!');
|
||||
$I->seeElement('#filter');
|
||||
$I->click('.preferences .dropdown-toggle', '[data-stream-entry]:nth-of-type(1)');
|
||||
$I->wait(1);
|
||||
$I->click('Delete');
|
||||
@ -220,7 +220,7 @@ class StreamCest
|
||||
|
||||
$I->seeSuccess('The content has been deleted');
|
||||
$I->see('This space is still empty!');
|
||||
$I->dontSeeElement('#filter');
|
||||
$I->dontSeeElement('#wall-stream-filter-nav');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -231,10 +231,12 @@ class StreamCest
|
||||
{
|
||||
$I->amUser();
|
||||
$I->amOnSpace2();
|
||||
$I->waitForElementVisible('#filter');
|
||||
$I->click('.stream-filter', '#filter');
|
||||
$I->waitForElementVisible('#filter_entry_userinvolved');
|
||||
$I->click('#filter_entry_userinvolved');
|
||||
|
||||
|
||||
$I->waitForElementVisible('.wall-stream-filter-head');
|
||||
$I->click('Filter', '.wall-stream-filter-head');
|
||||
$I->waitForElementVisible('[data-filter-id="entry_userinvolved"]');
|
||||
$I->click('[data-filter-id="entry_userinvolved"]');
|
||||
$I->waitForText('No matches with your selected filters!');
|
||||
|
||||
$I->createPost('Involved Post.');
|
||||
@ -242,22 +244,24 @@ class StreamCest
|
||||
$I->dontSee('No matches with your selected filters!');
|
||||
|
||||
$I->amGoingTo('Reset filter');
|
||||
$I->click('.stream-filter', '#filter');
|
||||
$I->waitForElementVisible('#filter_entry_userinvolved');
|
||||
$I->click('#filter_entry_userinvolved');
|
||||
$I->click('Filter', '.wall-stream-filter-head');
|
||||
$I->waitForElementVisible('[data-filter-id="entry_userinvolved"]');
|
||||
$I->click('[data-filter-id="entry_userinvolved"]');
|
||||
|
||||
$I->waitForElementVisible('[data-content-key="10"]');
|
||||
|
||||
$I->click('Comment', '[data-content-key="10"]');
|
||||
$I->waitForElementVisible('#newCommentForm_humhubmodulespostmodelsPost_10');
|
||||
$I->fillField('#newCommentForm_humhubmodulespostmodelsPost_10', 'My Comment');
|
||||
$I->click('Send', '#comment_create_form_humhubmodulespostmodelsPost_10');
|
||||
$I->waitForText('My Comment', 30, '#comment_humhubmodulespostmodelsPost_10 .comment');
|
||||
$postSelector = '[data-content-key="10"]';
|
||||
$I->waitForElementVisible($postSelector);
|
||||
|
||||
$I->click('Comment', $postSelector);
|
||||
$I->waitForElementVisible($postSelector.' .comment-container', null );
|
||||
$I->fillField('[data-content-key="10"] .comment_create .humhub-ui-richtext', 'My Comment');
|
||||
$I->click('Send', '[data-content-key="10"] .comment_create');
|
||||
$I->waitForText('My Comment', null, '[data-content-key="10"] .comment');
|
||||
|
||||
// $I->scrollTop();
|
||||
$I->click('.stream-filter', '#filter');
|
||||
$I->waitForElementVisible('#filter_entry_userinvolved');
|
||||
$I->click('#filter_entry_userinvolved');
|
||||
$I->click('Filter', '.wall-stream-filter-head');
|
||||
$I->waitForElementVisible('[data-filter-id="entry_userinvolved"]');
|
||||
$I->click('[data-filter-id="entry_userinvolved"]');
|
||||
$I->wait(1);
|
||||
$I->waitForText('Involved Post.');
|
||||
|
||||
@ -300,9 +304,9 @@ class StreamCest
|
||||
|
||||
$I->scrollTop();
|
||||
|
||||
$I->click('.stream-sorting', '#filter');
|
||||
$I->waitForElementVisible('#sorting_u');
|
||||
$I->click('#sorting_u');
|
||||
$I->click('Filter', '.wall-stream-filter-head');
|
||||
$I->waitForElementVisible('[data-filter-id="sort_update"]');
|
||||
$I->click('[data-filter-id="sort_update"]');
|
||||
$I->wait(2);
|
||||
$I->waitForElementVisible($post4Selector);
|
||||
|
||||
|
@ -190,6 +190,15 @@ humhub.module('ui.filter', function(module, require, $) {
|
||||
return result;
|
||||
};
|
||||
|
||||
Filter.prototype.getFilterById = function(id) {
|
||||
return this.getFilterInput($('[data-filter-id = "'+id+'"]'));
|
||||
};
|
||||
|
||||
Filter.prototype.isActive = function(key) {
|
||||
var filter = this.getFilterById(key);
|
||||
return (filter) ? filter.isActive() : false;
|
||||
};
|
||||
|
||||
Filter.prototype.getActiveFilterCount = function(options) {
|
||||
var count = 0;
|
||||
this.getFilterInputs().forEach(function(input) {
|
||||
@ -213,10 +222,10 @@ humhub.module('ui.filter', function(module, require, $) {
|
||||
}
|
||||
|
||||
if(options.include) {
|
||||
if(object.isArray(options.exclude)) {
|
||||
result = options.exclude.indexOf(input.getCategory()) >= 0;
|
||||
if(object.isArray(options.include)) {
|
||||
result = options.include.indexOf(input.getCategory()) >= 0;
|
||||
} else {
|
||||
result = input.getCategory() === options.exclude;
|
||||
result = input.getCategory() === options.include;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ class AcceptanceTester extends \Codeception\Actor
|
||||
{
|
||||
$this->jsClick('#contentForm_message');
|
||||
$this->wait(1);
|
||||
$this->fillField('#contentForm_message', $text);
|
||||
$this->fillField('#contentForm_message .humhub-ui-richtext', $text);
|
||||
$this->executeJS("$('#contentForm_message').trigger('focusout');");
|
||||
$this->wait(1);
|
||||
$this->jsClick('#post_submit_button');
|
||||
|
8
static/assets/34d3f7b2/CONTRIBUTING.md
Normal file
@ -0,0 +1,8 @@
|
||||
#Found a bug?
|
||||
|
||||
###Please include the following when opening an issue:
|
||||
|
||||
1. jquery-placeholder version
|
||||
2. jquery version
|
||||
3. Browser vendor and versions where you are seeing the issue
|
||||
4. Example code to reproduce the issue (using jsfiddle is best)
|
46
static/assets/34d3f7b2/Gruntfile.js
Normal file
@ -0,0 +1,46 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function(grunt) {
|
||||
|
||||
// Get devDependencies
|
||||
require('load-grunt-tasks')(grunt, {scope: 'devDependencies'});
|
||||
|
||||
// Displays the execution time of grunt tasks
|
||||
require('time-grunt')(grunt);
|
||||
|
||||
// Config
|
||||
grunt.initConfig({
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
|
||||
// uglify
|
||||
uglify: {
|
||||
options: {
|
||||
sourceMap: true,
|
||||
compress: {
|
||||
drop_console: true,
|
||||
drop_debugger: true
|
||||
},
|
||||
banner: '/* <%= pkg.title %> - v<%= pkg.version %>\n' +
|
||||
' * Copyright (c)<%= grunt.template.today("yyyy") %> Mathias Bynens\n' +
|
||||
' * <%= grunt.template.today("yyyy-mm-dd") %>\n' +
|
||||
' */'
|
||||
},
|
||||
minify : {
|
||||
files: {
|
||||
'jquery.placeholder.min.js': ['jquery.placeholder.js']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Register own tasks by putting together existing ones
|
||||
*/
|
||||
|
||||
// Default task
|
||||
grunt.registerTask('default',
|
||||
['uglify']
|
||||
);
|
||||
|
||||
};
|
20
static/assets/34d3f7b2/LICENSE.txt
Normal file
@ -0,0 +1,20 @@
|
||||
Copyright Mathias Bynens <http://mathiasbynens.be/>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
93
static/assets/34d3f7b2/README.md
Normal file
@ -0,0 +1,93 @@
|
||||
# HTML5 Placeholder jQuery Plugin
|
||||
|
||||
## Demo & Examples
|
||||
|
||||
<https://mathiasbynens.github.io/jquery-placeholder/>
|
||||
|
||||
## Example Usage
|
||||
|
||||
### HTML
|
||||
|
||||
```html
|
||||
<input type="text" name="name" placeholder="e.g. John Doe">
|
||||
<input type="email" name="email" placeholder="e.g. address@example.ext">
|
||||
<input type="url" name="url" placeholder="e.g. https://mathiasbynens.be/">
|
||||
<input type="tel" name="tel" placeholder="e.g. +32 472 77 69 88">
|
||||
<input type="password" name="password" placeholder="e.g. h4x0rpr00fz">
|
||||
<input type="search" name="search" placeholder="Search this site…">
|
||||
<textarea name="message" placeholder="Your message goes here"></textarea>
|
||||
```
|
||||
|
||||
### jQuery
|
||||
|
||||
Use the plugin as follows:
|
||||
|
||||
```js
|
||||
$('input, textarea').placeholder();
|
||||
```
|
||||
|
||||
By default, `.placeholder` css class will be added. You can override default by passing the `customClass` option:
|
||||
```js
|
||||
$('input, textarea').placeholder({ customClass: 'my-placeholder' });
|
||||
```
|
||||
|
||||
You’ll still be able to use `jQuery#val()` to get and set the input values. If the element is currently showing a placeholder, `.val()` will return an empty string instead of the placeholder text, just like it does in browsers with a native `@placeholder` implementation. Calling `.val('')` to set an element’s value to the empty string will result in the placeholder text (re)appearing.
|
||||
|
||||
### CSS
|
||||
|
||||
The plugin automatically adds `class="placeholder"` to the elements who are currently showing their placeholder text. You can use this to style placeholder text differently:
|
||||
|
||||
```css
|
||||
input, textarea { color: #000; }
|
||||
.placeholder { color: #aaa; }
|
||||
```
|
||||
|
||||
I’d suggest sticking to the `#aaa` color for placeholder text, as it’s the default in most browsers that support `@placeholder`. If you really want to, though, you can [style the placeholder text in some of the browsers that natively support it](https://stackoverflow.com/a/2610741/96656).
|
||||
|
||||
## Installation
|
||||
|
||||
You can install jquery-placeholder by using [Bower](http://bower.io/).
|
||||
|
||||
```bash
|
||||
bower install jquery-placeholder
|
||||
```
|
||||
|
||||
Or you can install it through [npm](https://www.npmjs.com/):
|
||||
|
||||
```
|
||||
npm install --save jquery-placeholder
|
||||
```
|
||||
|
||||
Contributors should install the »dev dependencies« after forking and cloning via [npm](https://www.npmjs.com/).
|
||||
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
* Requires jQuery 1.6+. For an older version of this plugin that works under jQuery 1.4.2+, see [v1.8.7](https://github.com/mathiasbynens/jquery-placeholder/tree/v1.8.7).
|
||||
* Works in all A-grade browsers, including IE6.
|
||||
* Automatically checks if the browser natively supports the HTML5 `placeholder` attribute for `input` and `textarea` elements. If this is the case, the plugin won’t do anything. If `@placeholder` is only supported for `input` elements, the plugin will leave those alone and apply to `textarea`s exclusively. (This is the case for Safari 4, Opera 11.00, and possibly other browsers.)
|
||||
* Caches the results of its two feature tests in `jQuery.fn.placeholder.input` and `jQuery.fn.placeholder.textarea`. For example, if `@placeholder` is natively supported for `input` elements, `jQuery.fn.placeholder.input` will be `true`. After loading the plugin, you can re-use these properties in your own code.
|
||||
* Using `<input type="reset" />` will break the plugin functionality
|
||||
* Makes sure it never causes duplicate IDs in your DOM, even in browsers that need an extra `input` element to fake `@placeholder` for password inputs. This means you can safely do stuff like:
|
||||
|
||||
```html
|
||||
<label for="bar">Example label</label>
|
||||
<input type="password" placeholder="foo" id="bar">
|
||||
```
|
||||
|
||||
And the `<label>` will always point to the `<input>` element you’d expect. Also, all CSS styles based on the ID will just work™.
|
||||
|
||||
## License
|
||||
|
||||
This plugin is available under [the MIT license](http://mths.be/mit).
|
||||
|
||||
## Thanks to…
|
||||
|
||||
* [Paul Irish](http://paulirish.com/) for his inspiring snippet in [jQuery 1.4 Hawtness #1](http://jquery14.com/day-05/jquery-1-4-hawtness-1-with-paul-irish)
|
||||
* everyone from [#jquery](http://webchat.freenode.net/?channels=jquery) for the tips, ideas and patches
|
||||
* anyone who [contributed a patch](https://github.com/mathiasbynens/jquery-placeholder/contributors) or [made a helpful suggestion](https://github.com/mathiasbynens/jquery-placeholder/issues)
|
||||
|
||||
_– [Mathias](http://mathiasbynens.be/)_
|
125
static/assets/34d3f7b2/index.html
Normal file
@ -0,0 +1,125 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML5 placeholder jQuery Plugin</title>
|
||||
<style>
|
||||
body { font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; }
|
||||
input, textarea { font-size: 1em; font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;}
|
||||
input { width: 250px; }
|
||||
input[type="radio"], input[type="checkbox"] { width: auto }
|
||||
label code { display: inline-block; width: 200px; }
|
||||
textarea { height: 2em; width: 20em;, font-family: sans-serif; }
|
||||
.my-placeholder { color: #aaa; }
|
||||
.note { border: 1px solid orange; font-size: 13px; padding: 1em; background: #ffffe0; }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>HTML5 Placeholder jQuery Plugin</h1>
|
||||
|
||||
<a href="https://github.com/mathiasbynens/jquery-placeholder"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>
|
||||
|
||||
<form method="GET" action="">
|
||||
<input type="radio" name="color" value="red" placeholder="This can't be seen"> Red
|
||||
<input type="radio" name="color" value="green" placeholder="This can't be seen"> Green
|
||||
|
||||
<br />
|
||||
|
||||
<input type="checkbox" name="fruits" value="apple" placeholder="This can't be seen"> Apple
|
||||
<input type="checkbox" name="fruits" value="banana" placeholder="This can't be seen"> Banana
|
||||
|
||||
<br />
|
||||
|
||||
<input type="hidden" name="hidden" placeholder="This can't be seen" value="secret">
|
||||
|
||||
<br />
|
||||
|
||||
<input type="search" name="search" placeholder="type=search">
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<input type="text" name="name" placeholder="type=text">
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<input type="email" name="email" placeholder="type=email" value="prefilled@example.com">
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<input type="url" name="url" placeholder="type=url" value="http://prefilled.example.com">
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<input type="tel" name="tel" placeholder="type=tel">
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<input type="password" name="password" placeholder="type=password" id="p">
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<textarea name="message" placeholder="textarea"></textarea>
|
||||
|
||||
<br />
|
||||
|
||||
<input type="text" name="location" disabled="disabled" placeholder="disabled type=text">
|
||||
|
||||
<br />
|
||||
|
||||
<input type="password" name="code" disabled="disabled" placeholder="disabled type=password">
|
||||
|
||||
<br />
|
||||
|
||||
<textarea name="comments" disabled="disabled" placeholder="disabled textarea"></textarea>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<label for="p">A Label: Click me to focus password field up above</label>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<div class="wrapped">
|
||||
<input type="password" name="password2" placeholder="type=password 2">
|
||||
</div>
|
||||
|
||||
<br />
|
||||
|
||||
<input type="submit" value="type=submit">
|
||||
<input type="reset" value="type=reset">
|
||||
</form>
|
||||
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="jquery.placeholder.js"></script>
|
||||
<script>
|
||||
// To test the @id toggling on password inputs in browsers that don’t support changing an input’s @type dynamically (e.g. Firefox 3.6 or IE), uncomment this:
|
||||
// $.fn.hide = function() { return this; }
|
||||
// Then uncomment the last rule in the <style> element (in the <head>).
|
||||
$(function() {
|
||||
// Invoke the plugin
|
||||
$('input, textarea').placeholder({customClass:'my-placeholder'});
|
||||
// That’s it, really.
|
||||
|
||||
var html;
|
||||
|
||||
if ($.fn.placeholder.input && $.fn.placeholder.textarea) {
|
||||
html = '<strong>Your current browser natively supports <code>placeholder</code> for <code>input</code> and <code>textarea</code> elements.</strong> The plugin won’t run in this case, since it’s not needed. If you want to test the plugin, use an older browser.';
|
||||
} else if ($.fn.placeholder.input) {
|
||||
html = '<strong>Your current browser natively supports <code>placeholder</code> for <code>input</code> elements, but not for <code>textarea</code> elements.</strong> The plugin will only do its thang on the <code>textarea</code>s.';
|
||||
}
|
||||
|
||||
if (html) {
|
||||
$('<p class="note">' + html + '</p>').insertBefore('form');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
40
static/assets/34d3f7b2/package.json
Normal file
@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "jquery-placeholder",
|
||||
"version": "2.3.1",
|
||||
"title": "HTML5 Placeholder jQuery Plugin",
|
||||
"description": "A jQuery plugin that enables HTML5 placeholder behavior for browsers that aren’t trying hard enough yet",
|
||||
"author": {
|
||||
"name": "Mathias Bynens",
|
||||
"url": "https://mathiasbynens.be/"
|
||||
},
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/mathiasbynens/jquery-placeholder.git"
|
||||
},
|
||||
"homepage": "https://github.com/mathiasbynens/jquery-placeholder",
|
||||
"bugs": {
|
||||
"url": "https://github.com/mathiasbynens/jquery-placeholder/issues"
|
||||
},
|
||||
"main": "jquery.placeholder.js",
|
||||
"files": [ "jquery.placeholder.js" ],
|
||||
"directories": {
|
||||
"test": "tests"
|
||||
},
|
||||
"keywords": [
|
||||
"form",
|
||||
"placeholder",
|
||||
"jQuery",
|
||||
"jquery-plugin"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"jquery": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"grunt": "^0.4.5",
|
||||
"grunt-contrib-uglify": "^0.7.0",
|
||||
"grunt-notify": "^0.4.1",
|
||||
"load-grunt-tasks": "^2.0.0",
|
||||
"time-grunt": "^1.0.0"
|
||||
}
|
||||
}
|
125
static/assets/34d3f7b2/simulated.html
Normal file
@ -0,0 +1,125 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML5 placeholder jQuery Plugin</title>
|
||||
<style>
|
||||
body { font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; }
|
||||
input, textarea { font-size: 1em; font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; }
|
||||
input { width: 250px; }
|
||||
input[type="radio"], input[type="checkbox"] { width: auto }
|
||||
label code { display: inline-block; width: 200px; }
|
||||
textarea { height: 2em; width: 20em;, font-family: sans-serif; }
|
||||
.my-placeholder { color: #aaa; }
|
||||
.note { border: 1px solid orange; font-size: 13px; padding: 1em; background: #ffffe0; }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>HTML5 Placeholder jQuery Plugin</h1>
|
||||
|
||||
<a href="https://github.com/mathiasbynens/jquery-placeholder"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>
|
||||
|
||||
<form method="GET" action="">
|
||||
<input type="radio" name="color" value="red" placeholder-x="This can't be seen"> Red
|
||||
<input type="radio" name="color" value="green" placeholder-x="This can't be seen"> Green
|
||||
|
||||
<br />
|
||||
|
||||
<input type="checkbox" name="fruits" value="apple" placeholder-x="This can't be seen"> Apple
|
||||
<input type="checkbox" name="fruits" value="banana" placeholder-x="This can't be seen"> Banana
|
||||
|
||||
<br />
|
||||
|
||||
<input type="hidden" name="hidden" placeholder-x="This can't be seen" value="secret">
|
||||
|
||||
<br />
|
||||
|
||||
<input type="search" name="search" placeholder-x="type=search">
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<input type="text" name="name" placeholder-x="type=text">
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<input type="email" name="email" placeholder-x="type=email" value="prefilled@example.com">
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<input type="url" name="url" placeholder-x="type=url" value="http://prefilled.example.com">
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<input type="tel" name="tel" placeholder-x="type=tel">
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<input type="password" name="password" placeholder-x="type=password" id="p">
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<textarea name="message" placeholder-x="textarea"></textarea>
|
||||
|
||||
<br />
|
||||
|
||||
<input type="text" name="location" disabled="disabled" placeholder-x="disabled type=text">
|
||||
|
||||
<br />
|
||||
|
||||
<input type="password" name="code" disabled="disabled" placeholder-x="disabled type=password">
|
||||
|
||||
<br />
|
||||
|
||||
<textarea name="comments" disabled="disabled" placeholder-x="disabled textarea"></textarea>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<label for="p">A Label: Click me to focus password field up above</label>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<div class="wrapped">
|
||||
<input type="password" name="password2" placeholder-x="type=password 2">
|
||||
</div>
|
||||
|
||||
<br />
|
||||
|
||||
<input type="submit" value="type=submit">
|
||||
<input type="reset" value="type=reset">
|
||||
</form>
|
||||
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="jquery.placeholder.js"></script>
|
||||
<script>
|
||||
// To test the @id toggling on password inputs in browsers that don’t support changing an input’s @type dynamically (e.g. Firefox 3.6 or IE), uncomment this:
|
||||
// $.fn.hide = function() { return this; }
|
||||
// Then uncomment the last rule in the <style> element (in the <head>).
|
||||
$(function() {
|
||||
// Invoke the plugin
|
||||
$('input, textarea').placeholder({customClass:'my-placeholder'});
|
||||
// That’s it, really.
|
||||
|
||||
var html;
|
||||
|
||||
if ($.fn.placeholder.input && $.fn.placeholder.textarea) {
|
||||
html = '<strong>Your current browser natively supports <code>placeholder</code> for <code>input</code> and <code>textarea</code> elements.</strong> The plugin won’t run in this case, since it’s not needed. If you want to test the plugin, use an older browser.';
|
||||
} else if ($.fn.placeholder.input) {
|
||||
html = '<strong>Your current browser natively supports <code>placeholder</code> for <code>input</code> elements, but not for <code>textarea</code> elements.</strong> The plugin will only do its thang on the <code>textarea</code>s.';
|
||||
}
|
||||
|
||||
if (html) {
|
||||
$('<p class="note">' + html + '</p>').insertBefore('form');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
32
static/assets/34d3f7b2/tests/index.html
Normal file
@ -0,0 +1,32 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>jquery-placeholder test suite</title>
|
||||
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.12.0.css">
|
||||
<style>
|
||||
.placeholder { color: #aaa; }
|
||||
#input-type-password { border: 5px solid lime; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="fixtures">
|
||||
<!-- I explicitly want these to be visible in the page, for easier debugging. -->
|
||||
<form>
|
||||
<p><label><code>type=search</code> <input id="input-type-search" type="search" name="search" placeholder="Search this site..."></label></p>
|
||||
<p><label><code>type=text</code> <input id="input-type-text" type="text" name="name" placeholder="e.g. John Doe"></label></p>
|
||||
<p><label><code>type=email</code> <input id="input-type-email" type="email" name="email" placeholder="e.g. address@example.ext"></label></p>
|
||||
<p><label><code>type=url</code> <input id="input-type-url" type="url" name="url" placeholder="e.g. http://mathiasbynens.be/"></label></p>
|
||||
<p><label><code>type=tel</code> <input id="input-type-tel" type="tel" name="tel" placeholder="e.g. +32 472 77 69 88"></label></p>
|
||||
<p><label for="input-type-password"><code>type=password</code> </label><input id="input-type-password" type="password" name="password" placeholder="e.g. hunter2"></p>
|
||||
<p><label><code>textarea</code> <textarea id="textarea" name="message" placeholder="Your message goes here"></textarea></label></p>
|
||||
<p><input type="submit" value="type=submit"></p>
|
||||
</form>
|
||||
</div>
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="http://code.jquery.com/qunit/qunit-1.12.0.js"></script>
|
||||
<script src="../jquery.placeholder.js"></script>
|
||||
<script src="tests.js"></script>
|
||||
</body>
|
||||
</html>
|
134
static/assets/34d3f7b2/tests/tests.js
Normal file
@ -0,0 +1,134 @@
|
||||
(function($) {
|
||||
|
||||
module('jQuery#placeholder');
|
||||
|
||||
test('caches results of feature tests', function() {
|
||||
strictEqual(typeof $.fn.placeholder.input, 'boolean', '$.fn.placeholder.input');
|
||||
strictEqual(typeof $.fn.placeholder.textarea, 'boolean', '$.fn.placeholder.textarea');
|
||||
});
|
||||
|
||||
if ($.fn.placeholder.input && $.fn.placeholder.textarea) {
|
||||
return;
|
||||
}
|
||||
|
||||
var testElement = function($el) {
|
||||
|
||||
var el = $el[0];
|
||||
var placeholder = el.getAttribute('placeholder');
|
||||
|
||||
deepEqual($el.placeholder(), $el, 'should be chainable');
|
||||
|
||||
strictEqual(el.value, placeholder, 'should set `placeholder` text as `value`');
|
||||
strictEqual($el.prop('value'), '', 'propHooks works properly');
|
||||
strictEqual($el.val(), '', 'valHooks works properly');
|
||||
ok($el.hasClass('placeholder'), 'should have `placeholder` class');
|
||||
|
||||
// test on focus
|
||||
$el.focus();
|
||||
strictEqual(el.value, '', '`value` should be the empty string on focus');
|
||||
strictEqual($el.prop('value'), '', 'propHooks works properly');
|
||||
strictEqual($el.val(), '', 'valHooks works properly');
|
||||
ok(!$el.hasClass('placeholder'), 'should not have `placeholder` class on focus');
|
||||
|
||||
// and unfocus (blur) again
|
||||
$el.blur();
|
||||
|
||||
strictEqual(el.value, placeholder, 'should set `placeholder` text as `value`');
|
||||
strictEqual($el.prop('value'), '', 'propHooks works properly');
|
||||
strictEqual($el.val(), '', 'valHooks works properly');
|
||||
ok($el.hasClass('placeholder'), 'should have `placeholder` class');
|
||||
|
||||
// change the value
|
||||
$el.val('lorem ipsum');
|
||||
strictEqual($el.prop('value'), 'lorem ipsum', '`$el.val(string)` should change the `value` property');
|
||||
strictEqual(el.value, 'lorem ipsum', '`$el.val(string)` should change the `value` attribute');
|
||||
ok(!$el.hasClass('placeholder'), '`$el.val(string)` should remove `placeholder` class');
|
||||
|
||||
// and clear it again
|
||||
$el.val('');
|
||||
strictEqual($el.prop('value'), '', '`$el.val("")` should change the `value` property');
|
||||
strictEqual(el.value, placeholder, '`$el.val("")` should change the `value` attribute');
|
||||
ok($el.hasClass('placeholder'), '`$el.val("")` should re-enable `placeholder` class');
|
||||
|
||||
// make sure the placeholder property works as expected.
|
||||
strictEqual($el.prop('placeholder'), placeholder, '$el.prop(`placeholder`) should return the placeholder value');
|
||||
$el.prop('placeholder', 'new placeholder');
|
||||
strictEqual($el.prop('placeholder'), 'new placeholder', '$el.prop(`placeholder`, <string>) should set the placeholder value');
|
||||
strictEqual($el.value, 'new placeholder', '$el.prop(`placeholder`, <string>) should update the displayed placeholder value');
|
||||
$el.prop('placeholder', placeholder);
|
||||
};
|
||||
|
||||
test('emulates placeholder for <input type=text>', function() {
|
||||
testElement( $('#input-type-text') );
|
||||
});
|
||||
|
||||
test('emulates placeholder for <input type=search>', function() {
|
||||
testElement( $('#input-type-search') );
|
||||
});
|
||||
|
||||
test('emulates placeholder for <input type=email>', function() {
|
||||
testElement( $('#input-type-email') );
|
||||
});
|
||||
|
||||
test('emulates placeholder for <input type=url>', function() {
|
||||
testElement( $('#input-type-url') );
|
||||
});
|
||||
|
||||
test('emulates placeholder for <input type=tel>', function() {
|
||||
testElement( $('#input-type-tel') );
|
||||
});
|
||||
|
||||
test('emulates placeholder for <input type=tel>', function() {
|
||||
testElement( $('#input-type-tel') );
|
||||
});
|
||||
|
||||
test('emulates placeholder for <input type=password>', function() {
|
||||
var selector = '#input-type-password';
|
||||
|
||||
var $el = $(selector);
|
||||
var el = $el[0];
|
||||
|
||||
var placeholder = el.getAttribute('placeholder');
|
||||
|
||||
strictEqual($el.placeholder(), $el, 'should be chainable');
|
||||
|
||||
// Re-select the element, as it gets replaced by another one in some browsers
|
||||
$el = $(selector);
|
||||
el = $el[0];
|
||||
|
||||
strictEqual(el.value, placeholder, 'should set `placeholder` text as `value`');
|
||||
strictEqual($el.prop('value'), '', 'propHooks works properly');
|
||||
strictEqual($el.val(), '', 'valHooks works properly');
|
||||
ok($el.hasClass('placeholder'), 'should have `placeholder` class');
|
||||
|
||||
// test on focus
|
||||
$el.focus();
|
||||
|
||||
// Re-select the element, as it gets replaced by another one in some browsers
|
||||
$el = $(selector);
|
||||
el = $el[0];
|
||||
|
||||
strictEqual(el.value, '', '`value` should be the empty string on focus');
|
||||
strictEqual($el.prop('value'), '', 'propHooks works properly');
|
||||
strictEqual($el.val(), '', 'valHooks works properly');
|
||||
ok(!$el.hasClass('placeholder'), 'should not have `placeholder` class on focus');
|
||||
|
||||
// and unfocus (blur) again
|
||||
$el.blur();
|
||||
|
||||
// Re-select the element, as it gets replaced by another one in some browsers
|
||||
$el = $(selector);
|
||||
el = $el[0];
|
||||
|
||||
strictEqual(el.value, placeholder, 'should set `placeholder` text as `value`');
|
||||
strictEqual($el.prop('value'), '', 'propHooks works properly');
|
||||
strictEqual($el.val(), '', 'valHooks works properly');
|
||||
ok($el.hasClass('placeholder'), 'should have `placeholder` class');
|
||||
|
||||
});
|
||||
|
||||
test('emulates placeholder for <textarea></textarea>', function() {
|
||||
testElement( $('#textarea') );
|
||||
});
|
||||
|
||||
}(jQuery));
|
Before Width: | Height: | Size: 86 B After Width: | Height: | Size: 86 B |
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 383 B After Width: | Height: | Size: 383 B |
Before Width: | Height: | Size: 323 B After Width: | Height: | Size: 323 B |
Before Width: | Height: | Size: 323 B After Width: | Height: | Size: 323 B |
Before Width: | Height: | Size: 315 B After Width: | Height: | Size: 315 B |
Before Width: | Height: | Size: 316 B After Width: | Height: | Size: 316 B |
Before Width: | Height: | Size: 327 B After Width: | Height: | Size: 327 B |
Before Width: | Height: | Size: 382 B After Width: | Height: | Size: 382 B |
Before Width: | Height: | Size: 367 B After Width: | Height: | Size: 367 B |
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 6.8 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 471 B After Width: | Height: | Size: 471 B |
Before Width: | Height: | Size: 266 B After Width: | Height: | Size: 266 B |
Before Width: | Height: | Size: 398 B After Width: | Height: | Size: 398 B |
Before Width: | Height: | Size: 316 B After Width: | Height: | Size: 316 B |
Before Width: | Height: | Size: 316 B After Width: | Height: | Size: 316 B |
Before Width: | Height: | Size: 385 B After Width: | Height: | Size: 385 B |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 380 B After Width: | Height: | Size: 380 B |
Before Width: | Height: | Size: 408 B After Width: | Height: | Size: 408 B |
Before Width: | Height: | Size: 394 B After Width: | Height: | Size: 394 B |
Before Width: | Height: | Size: 404 B After Width: | Height: | Size: 404 B |
Before Width: | Height: | Size: 390 B After Width: | Height: | Size: 390 B |
Before Width: | Height: | Size: 310 B After Width: | Height: | Size: 310 B |
Before Width: | Height: | Size: 445 B After Width: | Height: | Size: 445 B |
Before Width: | Height: | Size: 367 B After Width: | Height: | Size: 367 B |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |