You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by cm...@apache.org on 2012/07/03 14:22:29 UTC
[16/28] git commit: WICKET-4635 Improve JavaScript files by applying
common JSHint rules
WICKET-4635 Improve JavaScript files by applying common JSHint rules
Add -extensions progressbar.js to JSHint-ed files.
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/93a6d411
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/93a6d411
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/93a6d411
Branch: refs/heads/sandbox/resourcefinder
Commit: 93a6d411b08a24dc42a49fbc1500b460778a4dcb
Parents: 8a4e3e0
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Mon Jul 2 16:29:28 2012 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Mon Jul 2 19:27:56 2012 +0200
----------------------------------------------------------------------
grunt.js | 40 ++-
.../ajax/markup/html/form/upload/progressbar.js | 207 ++++++++-------
2 files changed, 135 insertions(+), 112 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/93a6d411/grunt.js
----------------------------------------------------------------------
diff --git a/grunt.js b/grunt.js
index c37c87d..a946f91 100644
--- a/grunt.js
+++ b/grunt.js
@@ -6,26 +6,42 @@
* 1) install node.js - http://nodejs.org/#download. This will install 'npm' (Node Package Manager) too
* 2) install phantomjs - http://code.google.com/p/phantomjs/downloads/list
* 3) install grunt - 'npm -g install grunt'
- * 4) run it: grunt lint[:all] qunit[:index] qunit:local
+ * 4) run it: grunt lint, grunt lint:core, grunt qunit, grunt qunit:local
*/
+ /*global module: true */
+
module.exports = function(grunt) {
+ "use strict";
- var lintCore = [
- 'wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-event-jquery.js',
- 'wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery-debug.js',
- 'wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js',
- "wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckGroupSelector.js",
- "wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckboxMultipleChoiceSelector.js",
- "wicket-core/src/main/java/org/apache/wicket/markup/html/form/AbstractCheckSelector.js",
- "wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/MultiFileUploadField.js",
- "wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckBoxSelector.js"
- ]
+ var
+ lintCore = [
+ 'wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-event-jquery.js',
+ 'wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery-debug.js',
+ 'wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js',
+ "wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckGroupSelector.js",
+ "wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckboxMultipleChoiceSelector.js",
+ "wicket-core/src/main/java/org/apache/wicket/markup/html/form/AbstractCheckSelector.js",
+ "wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/MultiFileUploadField.js",
+ "wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckBoxSelector.js"
+ ],
+ lintExtensions = [
+ "wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/form/upload/progressbar.js"
+// "wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js",
+// "wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/modal.js",
+// "wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/palette.js",
+// "wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/tree/res/tree.js"
+ ],
+ gruntJs = [
+ "grunt.js"
+ ];
// Project configuration.
grunt.initConfig({
lint: {
- all: lintCore
+ core: lintCore,
+ extensions: lintExtensions,
+ grunt: gruntJs
},
jshint: {
http://git-wip-us.apache.org/repos/asf/wicket/blob/93a6d411/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/form/upload/progressbar.js
----------------------------------------------------------------------
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/form/upload/progressbar.js b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/form/upload/progressbar.js
index 96c741b..3807d30 100644
--- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/form/upload/progressbar.js
+++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/form/upload/progressbar.js
@@ -14,104 +14,111 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-if (typeof(Wicket) == "undefined") Wicket = { };
-
-Wicket.WUPB = Wicket.Class.create();
-Wicket.WUPB.prototype = {
-
- initialize : function(formid, statusid, barid, url, fileid, initialStatus) {
- this.formid = formid;
- this.statusid = statusid;
- this.barid = barid;
- this.url = url;
- this.fileid = fileid;
- this.initialStatus = initialStatus;
- },
-
- bind : function(formid) {
- formElement = Wicket.$(formid);
- this.originalCallback = formElement.onsubmit;
- formElement.onsubmit = Wicket.bind(this.submitCallback, this);
- },
-
- submitCallback : function() {
- if (this.originalCallback && !this.originalCallback()) {
- return false;
- } else {
- this.start();
- return true;
- }
- },
-
- start : function(){
- this.displayprogress = true;
- if (this.fileid) {
- var fileupload = Wicket.$(this.fileid);
- this.displayprogress = fileupload && fileupload.value && fileupload.value != '';
- }
- if (this.displayprogress) {
- this.setPercent(0);
- this.setStatus(this.initialStatus);
- Wicket.$(this.statusid).style.display='block';
- Wicket.$(this.barid).style.display='block';
- this.scheduleUpdate();
- }
- },
-
- setStatus : function(status){
- var label = document.createElement("label");
- label.innerHTML = status;
- var oldLabel = Wicket.$(this.statusid).firstChild;
- if( oldLabel != null){
- Wicket.$(this.statusid).removeChild(oldLabel);
- }
- Wicket.$(this.statusid).appendChild(label);
- },
-
- setPercent : function(progressPercent){
- Wicket.$(this.barid).firstChild.firstChild.style.width = progressPercent + '%';
- },
-
- scheduleUpdate : function(){
- window.setTimeout(Wicket.bind(this.load, this), 1000);
- },
-
- load : function() {
- var URL = this.url;
-
- this.iframe = Wicket._createIFrame(""+Math.random());
-
- document.body.appendChild(this.iframe);
-
- Wicket.Event.add(this.iframe, "load", Wicket.bind(this.update, this));
- this.iframe.src = URL;
- },
-
- update : function() {
- var responseAsText;
- if(this.iframe.contentDocument){
- responseAsText = this.iframe.contentDocument.body.innerHTML;
- }else{
- // for IE 5.5, 6 and 7:
- responseAsText = this.iframe.contentWindow.document.body.innerHTML
- }
-
- var update = responseAsText.split('|');
-
- var progressPercent = update[1];
- var status = update[2];
-
- this.setPercent(progressPercent);
- this.setStatus( status );
-
- this.iframe.parentNode.removeChild(this.iframe);
- this.iframe = null;
-
- if (progressPercent == 100) {
- wicketHide(this.statusid);
- wicketHide(this.barid);
- } else {
- this.scheduleUpdate();
- }
+
+;(function (undefined) {
+ 'use strict';
+
+ if (typeof(Wicket) === "undefined") {
+ Wicket = {};
}
-};
\ No newline at end of file
+
+ Wicket.WUPB = Wicket.Class.create();
+ Wicket.WUPB.prototype = {
+
+ initialize : function(formid, statusid, barid, url, fileid, initialStatus) {
+ this.formid = formid;
+ this.statusid = statusid;
+ this.barid = barid;
+ this.url = url;
+ this.fileid = fileid;
+ this.initialStatus = initialStatus;
+ },
+
+ bind : function(formid) {
+ var formElement = Wicket.$(formid);
+ this.originalCallback = formElement.onsubmit;
+ formElement.onsubmit = Wicket.bind(this.submitCallback, this);
+ },
+
+ submitCallback : function() {
+ if (this.originalCallback && !this.originalCallback()) {
+ return false;
+ } else {
+ this.start();
+ return true;
+ }
+ },
+
+ start : function(){
+ this.displayprogress = true;
+ if (this.fileid) {
+ var fileupload = Wicket.$(this.fileid);
+ this.displayprogress = fileupload && fileupload.value && fileupload.value !== '';
+ }
+ if (this.displayprogress) {
+ this.setPercent(0);
+ this.setStatus(this.initialStatus);
+ Wicket.$(this.statusid).style.display='block';
+ Wicket.$(this.barid).style.display='block';
+ this.scheduleUpdate();
+ }
+ },
+
+ setStatus : function(status){
+ var label = document.createElement("label");
+ label.innerHTML = status;
+ var oldLabel = Wicket.$(this.statusid).firstChild;
+ if( oldLabel != null){
+ Wicket.$(this.statusid).removeChild(oldLabel);
+ }
+ Wicket.$(this.statusid).appendChild(label);
+ },
+
+ setPercent : function(progressPercent){
+ Wicket.$(this.barid).firstChild.firstChild.style.width = progressPercent + '%';
+ },
+
+ scheduleUpdate : function(){
+ window.setTimeout(Wicket.bind(this.load, this), 1000);
+ },
+
+ load : function() {
+ var URL = this.url;
+
+ this.iframe = Wicket._createIFrame(""+Math.random());
+
+ document.body.appendChild(this.iframe);
+
+ Wicket.Event.add(this.iframe, "load", Wicket.bind(this.update, this));
+ this.iframe.src = URL;
+ },
+
+ update : function() {
+ var responseAsText;
+ if(this.iframe.contentDocument){
+ responseAsText = this.iframe.contentDocument.body.innerHTML;
+ }else{
+ // for IE 5.5, 6 and 7:
+ responseAsText = this.iframe.contentWindow.document.body.innerHTML;
+ }
+
+ var update = responseAsText.split('|');
+
+ var progressPercent = update[1];
+ var status = update[2];
+
+ this.setPercent(progressPercent);
+ this.setStatus( status );
+
+ this.iframe.parentNode.removeChild(this.iframe);
+ this.iframe = null;
+
+ if (progressPercent === 100) {
+ Wicket.DOM.hide(this.statusid);
+ Wicket.DOM.hide(this.barid);
+ } else {
+ this.scheduleUpdate();
+ }
+ }
+ };
+})();
\ No newline at end of file