Skip to content
Browse files

Merge pull request #179 from afuna/jquery-update-bug4771

(Bug 4771, 4780, and 4781) Upgrade jQuery / jQuery UI
  • Loading branch information...
2 parents 800640a + cf95a89 commit 079c2fed39637f1a1ab2b658cf05dd0dff60ed99 @afuna afuna committed Dec 11, 2012
Showing with 14,986 additions and 11,575 deletions.
  1. +12 −5 cgi-bin/LJ/S2.pm
  2. +7 −3 cgi-bin/LJ/S2/EntryPage.pm
  3. +6 −5 cgi-bin/ljlib.pl
  4. BIN htdocs/img/jquery/dark-hive/ui-bg_flat_50_5c5c5c_40x100.png
  5. BIN htdocs/img/jquery/dark-hive/ui-bg_highlight-hard_20_0972a5_1x100.png
  6. BIN htdocs/img/jquery/smoothness/ui-bg_glass_55_fbf9ee_1x400.png
  7. BIN htdocs/img/jquery/smoothness/ui-bg_glass_65_ffffff_1x400.png
  8. BIN htdocs/img/jquery/smoothness/ui-bg_glass_75_dadada_1x400.png
  9. BIN htdocs/img/jquery/smoothness/ui-bg_glass_75_e6e6e6_1x400.png
  10. BIN htdocs/img/jquery/smoothness/ui-bg_gloss-wave_65_ffffff_500x100.png
  11. BIN htdocs/img/jquery/smoothness/ui-bg_gloss-wave_75_dadada_500x100.png
  12. BIN htdocs/img/jquery/smoothness/ui-bg_gloss-wave_75_e6e6e6_500x100.png
  13. BIN htdocs/img/jquery/smoothness/ui-bg_glow-ball_55_fbf9ee_600x600.png
  14. BIN htdocs/img/jquery/smoothness/ui-bg_highlight-soft_75_cccccc_1x100.png
  15. BIN htdocs/img/jquery/smoothness/ui-bg_white-lines_75_cccccc_40x100.png
  16. +19 −17 htdocs/js/dw/dw-core.js
  17. +101 −149 htdocs/js/jquery.ajaxtip.js
  18. +6 −16 htdocs/js/jquery.autocompletewithunknown.js
  19. +4 −12 htdocs/js/jquery.collapsible.js
  20. +94 −84 htdocs/js/jquery.commentmanage.js
  21. +229 −202 htdocs/js/jquery.contextualhover.js
  22. +19 −13 htdocs/js/jquery.crosspost.js
  23. +4 −4 htdocs/js/jquery.cuttag-ajax.js
  24. +80 −71 htdocs/js/jquery.esn.js
  25. +6 −6 htdocs/js/jquery.iconselector.js
  26. +127 −113 htdocs/js/jquery.poll.js
  27. +6 −6 htdocs/js/jquery.postform.js
  28. +1 −1 htdocs/js/jquery.postoptions.js
  29. +1 −1 htdocs/js/jquery.quickreply.js
  30. +1 −1 htdocs/js/jquery.supportform.js
  31. +4 −4 htdocs/js/jquery.tagselector.js
  32. +4 −7 htdocs/js/jquery.threadexpander.js
  33. +0 −8,374 htdocs/js/jquery/jquery-1.5.2.js
  34. +0 −16 htdocs/js/jquery/jquery-1.5.2.min.js
  35. +9,472 −0 htdocs/js/jquery/jquery-1.8.3.js
  36. +2 −0 htdocs/js/jquery/jquery-1.8.3.min.js
  37. +342 −353 htdocs/js/jquery/jquery.ui.autocomplete.js
  38. +5 −32 htdocs/js/jquery/jquery.ui.autocomplete.min.js
  39. +415 −0 htdocs/js/jquery/jquery.ui.button.js
  40. +5 −0 htdocs/js/jquery/jquery.ui.button.min.js
  41. +136 −107 htdocs/js/jquery/jquery.ui.core.js
  42. +5 −17 htdocs/js/jquery/jquery.ui.core.min.js
  43. +210 −137 htdocs/js/jquery/jquery.ui.datepicker.js
  44. +5 −82 htdocs/js/jquery/jquery.ui.datepicker.min.js
  45. +387 −397 htdocs/js/jquery/jquery.ui.dialog.js
  46. +5 −40 htdocs/js/jquery/jquery.ui.dialog.min.js
  47. +91 −70 htdocs/js/jquery/jquery.ui.draggable.js
  48. +5 −50 htdocs/js/jquery/jquery.ui.draggable.min.js
  49. +27 −18 htdocs/js/jquery/jquery.ui.droppable.js
  50. +5 −26 htdocs/js/jquery/jquery.ui.droppable.min.js
  51. +609 −0 htdocs/js/jquery/jquery.ui.menu.js
  52. +5 −0 htdocs/js/jquery/jquery.ui.menu.min.js
  53. +34 −21 htdocs/js/jquery/jquery.ui.mouse.js
  54. +5 −17 htdocs/js/jquery/jquery.ui.mouse.min.js
  55. +396 −131 htdocs/js/jquery/jquery.ui.position.js
  56. +5 −16 htdocs/js/jquery/jquery.ui.position.min.js
  57. +802 −0 htdocs/js/jquery/jquery.ui.resizable.js
  58. +5 −0 htdocs/js/jquery/jquery.ui.resizable.min.js
  59. +28 −33 htdocs/js/jquery/jquery.ui.selectable.js
  60. +5 −22 htdocs/js/jquery/jquery.ui.selectable.min.js
  61. +147 −133 htdocs/js/jquery/jquery.ui.sortable.js
  62. +5 −60 htdocs/js/jquery/jquery.ui.sortable.min.js
  63. +342 −0 htdocs/js/jquery/jquery.ui.tooltip.js
  64. +5 −0 htdocs/js/jquery/jquery.ui.tooltip.min.js
  65. +358 −118 htdocs/js/jquery/jquery.ui.widget.js
  66. +5 −15 htdocs/js/jquery/jquery.ui.widget.min.js
  67. +0 −340 htdocs/js/tooltip.js
  68. +0 −18 htdocs/js/tooltip.min.js
  69. +31 −0 htdocs/js/untitled.html
  70. +0 −13 htdocs/stc/ajaxtip.css
  71. +1 −1 htdocs/stc/base-colors-light.css
  72. +17 −0 htdocs/stc/jquery.commentmanage.css
  73. +48 −0 htdocs/stc/jquery.contextualhover.css
  74. +5 −13 htdocs/stc/jquery.iconselector.css
  75. +5 −44 htdocs/stc/jquery/jquery.ui.autocomplete.css
  76. +22 −2 htdocs/stc/jquery/jquery.ui.base.css
  77. +40 −0 htdocs/stc/jquery/jquery.ui.button.css
  78. +9 −11 htdocs/stc/jquery/jquery.ui.core.css
  79. +7 −8 htdocs/stc/jquery/jquery.ui.datepicker.css
  80. +7 −6 htdocs/stc/jquery/jquery.ui.dialog.css
  81. +30 −0 htdocs/stc/jquery/jquery.ui.menu.css
  82. +21 −0 htdocs/stc/jquery/jquery.ui.resizable.css
  83. +5 −4 htdocs/stc/jquery/jquery.ui.selectable.css
  84. +16 −22 htdocs/stc/jquery/jquery.ui.theme.dark-hive.css
  85. +23 −28 htdocs/stc/jquery/jquery.ui.theme.smoothness.css
  86. +22 −0 htdocs/stc/jquery/jquery.ui.tooltip.css
  87. +7 −4 htdocs/talkread.bml
  88. +51 −42 views/dev/tests/commentmanage.js
  89. +1 −1 views/dev/tests/json.js
  90. +9 −9 views/dev/tests/libfunctions.js
  91. +1 −1 views/dev/tests/login.js
  92. +2 −2 views/dev/tests/quickreply.js
  93. +2 −1 views/entry/form.tt
View
17 cgi-bin/LJ/S2.pm
@@ -199,10 +199,18 @@ sub make_journal
}
LJ::need_res( { group => "jquery" }, qw(
+ js/jquery/jquery.ui.core.js
js/jquery/jquery.ui.widget.js
+ js/jquery/jquery.ui.tooltip.js
+ js/jquery/jquery.ui.button.js
+ js/jquery/jquery.ui.dialog.js
+ js/jquery/jquery.ui.position.js
js/jquery.ajaxtip.js
- js/tooltip.js
- stc/ajaxtip.css
+
+ stc/jquery/jquery.ui.core.css
+ stc/jquery/jquery.ui.tooltip.css
+ stc/jquery/jquery.ui.button.css
+ stc/jquery/jquery.ui.dialog.css
js/jquery.poll.js
@@ -1803,13 +1811,12 @@ sub tracking_popup_js {
{ group => 'jquery' }, qw(
js/jquery/jquery.ui.widget.js
+ js/jquery/jquery.ui.tooltip.js
js/jquery.ajaxtip.js
- js/tooltip.js
js/jquery/jquery.ui.position.js
- stc/ajaxtip.css
+ stc/jquery/jquery.ui.tooltip.css
js/jquery.esn.js
- stc/esn.css
) ): ();
}
View
10 cgi-bin/LJ/S2/EntryPage.pm
@@ -410,12 +410,16 @@ sub EntryPage
LJ::need_res( "js/commentmanage.js" );
LJ::need_res( { group => "jquery" }, qw(
+ js/jquery/jquery.ui.tooltip.js
js/jquery.ajaxtip.js
+ js/jquery/jquery.ui.button.js
+ js/jquery/jquery.ui.dialog.js
js/jquery.commentmanage.js
- js/tooltip.js
js/jquery/jquery.ui.position.js
- stc/ajaxtip.css
- stc/popup-form.css
+ stc/jquery/jquery.ui.tooltip.css
+ stc/jquery/jquery.ui.button.css
+ stc/jquery/jquery.ui.dialog.css
+ stc/jquery.commentmanage.css
) );
LJ::need_res( LJ::S2::tracking_popup_js() );
View
11 cgi-bin/ljlib.pl
@@ -955,7 +955,7 @@ sub start_request
LJ::need_res( { group => 'jquery', priority => $LJ::LIB_RES_PRIORITY },
# jquery library is the big one, load first
- 'js/jquery/jquery-1.5.2.js',
+ 'js/jquery/jquery-1.8.3.js',
# the rest of the libraries
qw(
@@ -983,7 +983,7 @@ sub start_request
# contextual popup JS
if ( $LJ::CTX_POPUP ) {
- LJ::need_res( { priority => $LJ::LIB_RES_PRIORITY }, qw(
+ LJ::need_res( { priority => $LJ::LIB_RES_PRIORITY, group => "default" }, qw(
js/6alib/ippu.js
js/lj_ippu.js
js/6alib/hourglass.js
@@ -995,14 +995,15 @@ sub start_request
qw(
js/jquery/jquery.ui.widget.js
+ js/jquery/jquery.ui.tooltip.js
js/jquery.ajaxtip.js
- js/tooltip.js
js/jquery/jquery.ui.position.js
- stc/ajaxtip.css
+ stc/jquery/jquery.ui.tooltip.css
+ stc/jquery/jquery.ui.theme.smoothness.css
js/jquery.hoverIntent.js
js/jquery.contextualhover.js
- stc/contextualhover.css
+ stc/jquery.contextualhover.css
));
}
View
BIN htdocs/img/jquery/dark-hive/ui-bg_flat_50_5c5c5c_40x100.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN htdocs/img/jquery/dark-hive/ui-bg_highlight-hard_20_0972a5_1x100.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN htdocs/img/jquery/smoothness/ui-bg_glass_55_fbf9ee_1x400.png
Deleted file not rendered
View
BIN htdocs/img/jquery/smoothness/ui-bg_glass_65_ffffff_1x400.png
Deleted file not rendered
View
BIN htdocs/img/jquery/smoothness/ui-bg_glass_75_dadada_1x400.png
Deleted file not rendered
View
BIN htdocs/img/jquery/smoothness/ui-bg_glass_75_e6e6e6_1x400.png
Deleted file not rendered
View
BIN htdocs/img/jquery/smoothness/ui-bg_gloss-wave_65_ffffff_500x100.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN htdocs/img/jquery/smoothness/ui-bg_gloss-wave_75_dadada_500x100.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN htdocs/img/jquery/smoothness/ui-bg_gloss-wave_75_e6e6e6_500x100.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN htdocs/img/jquery/smoothness/ui-bg_glow-ball_55_fbf9ee_600x600.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN htdocs/img/jquery/smoothness/ui-bg_highlight-soft_75_cccccc_1x100.png
Deleted file not rendered
View
BIN htdocs/img/jquery/smoothness/ui-bg_white-lines_75_cccccc_40x100.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
36 htdocs/js/dw/dw-core.js
@@ -51,32 +51,34 @@ $.extractParams = function(url) {
$.throbber = {
src: Site.imgprefix + "/ajax-loader.gif",
- image: function() { return $("<img>", { src: $.throbber.src } ) }
+ error: Site.imgprefix + "/silk/site/error.png"
};
$.endpoint = function(action){
- return Site && Site.currentJournal ? "/" + Site.currentJournal + "/__rpc_" + action : "/__rpc_" + action;
+ return ( Site && Site.currentJournal ) ? "/" + Site.currentJournal + "/__rpc_" + action : "/__rpc_" + action;
};
-// position is an optional first argument
-$.fn.throbber = function(position, jqxhr) {
+$.fn.throbber = function(jqxhr) {
var $this = $(this);
- if ( $this.data("throbber") )
- $this.data("throbber").remove();
-
- if ( jqxhr === undefined ) jqxhr = position;
- if ( position != "before" && position != "after" && position != "prepend" && position != "append" ) {
- if ( $this.is(":input") )
- position = "after"
- else
- position = "append"
+ if ( ! $this.data( "throbber" ) ) {
+ $this.css( "padding-right", "+=18px" );
}
- var $img = $.throbber.image();
- $this[position]($img);
- $this.data("throbber", $img);
- jqxhr.complete(function() { $img.remove(); $this.removeData("throbber") });
+ $this
+ .css( "background", "url('" + $.throbber.src + "') center right no-repeat" )
+ .data("throbber", true);
+
+ jqxhr.then(function() {
+ $this.css( {
+ "paddingRight": "-=18px",
+ "backgroundImage": "none"
+ }).data("throbber", false);
+ });
+
+ jqxhr.fail(function() {
+ $this.css( "backgroundImage", "url('" + $.throbber.error + "')" );
+ });
return $this;
};
View
250 htdocs/js/jquery.ajaxtip.js
@@ -1,178 +1,130 @@
(function($) {
-$.widget("dw.ajaxtip", {
+$.widget("dw.ajaxtip", $.ui.tooltip, {
options: {
- namespace: undefined,
content: undefined,
- tooltip: { dynamic: true },
- persist: false,
- multiple: false // allow multiple ajaxtip requests, even if we're not done processing the previous
- },
- _namespace: function() {
- return this.options.namespace ? "."+this.options.namespace : "";
+ items: "*",
+
+ loadingContent: undefined,
+
+ tooltipClass: "ajaxtip",
+ position: {
+ my: "left top+10",
+ at: "left bottom",
+ collision: "flipfit flipfit"
+ }
},
_create: function() {
+ // we override completely because we want to control what events trigger this widget
var self = this;
- var ns = self._namespace();
-
- var tipcontainer = $("<div class='ajaxtooltip ajaxtip' style='display: none'></div>")
- .click(function(e) {e.stopPropagation()})
- if ( self.options.persist ) {
- $(self.element).attr("type", "persistent").bind("mouseout"+self._namespace(), function(e) {
- self.element.trigger("tooltipout" + self._namespace());
- } )
- }
+ // attach (and remove) custom handlers
+ this._on({
+ ajaxtipopen: function (event, ui) {
+ self._on( ui.tooltip, {
+ // we want to bind the events to the tooltip
+ // but we want close() to use this.element
+ // so we have to call this.close() ourselves
+ mouseleave: function() { self.close(); },
+ focusout: function() { self.close(); }
+ });
+ },
+ ajaxtipclose: function(event, ui) {
+ self._off( ui.tooltip, "mouseleave focusout" );
+ }
+ });
- self.element
- .after(tipcontainer)
- .bind("ajaxresult"+ns, function(e) {
- var tip = self.element.data("tooltip").getTip()
- .addClass("ajaxresult-" + e.ajaxresult.status);
- if ( e.ajaxresult.message ) tip.text(e.ajaxresult.message);
- })
- .tooltip($.extend({
- predelay: 0,
- delay: 1500,
- events: {
- // just fade away after a preset period
- def : "ajaxstart"+ns+", tooltipout"+ns+" ajaxresult"+ns,
- // persist until the user takes some action (including moving the mouse away from trigger)
- persistent: "ajaxstart"+ns+", tooltipout"+ns,
- widget : "ajaxstart"+ns+", ajaxresult"+ns,
- tooltip : "mouseover,mouseleave"
- },
- relative: true,
- effect: "fade",
- onBeforeShow: function(e) {
- var tooltipAPI = this;
- var tip = tooltipAPI.getTip();
- tip.removeClass("ajaxresult ajaxresult-success ajaxresult-error")
- .appendTo("body");
- if ( ! tip.data( "boundclose" ) ) {
- tip.bind( "close", function () {
-
- // abort any existing request
- var xhr = tip.data( "xhr" );
- if ( xhr ) xhr.abort();
-
- // hide any currently shown ones
- tooltipAPI.hide();
- } );
- tip.data( "boundclose", true );
- }
-
- if ( self.options.content && ! this.inprogress ){
- tip.html(self.options.content)
- } else {
- tip.empty().append($("<img />", { src: Site.imgprefix + "/ajax-loader.gif" }))
- .addClass("ajaxresult")
- }
-
- tip.css({position: "absolute", top: "", left: ""})
- self._reposition( tip );
- },
- onShow: function(e) {
- self._reposition( this.getTip() );
- }
- }, self.options.tooltip));
- },
- _init: function() {
- if(this.options.content)
- this.element.data("tooltip").show()
+ this.tooltips = {};
+ this.requests = [];
},
- _reposition: function( tip ) {
- tip.position({ my: "left top", at: "left bottom", of: this.element, collision: "fit"})
- },
- _endpointurl : function( action ) {
- // if we are on a journal subdomain then our url will be
- // /journalname/__rpc_action instead of /__rpc_action
- return Site.currentJournal
- ? "/" + Site.currentJournal + "/__rpc_" + action
- : "/__rpc_" + action;
+ // close everything except the target (if it was a tooltip)
+ closeinactive: function($target) {
+ var target_id = $target.attr( "id" );
+ if ( ! this.tooltips[target_id] ) {
+ this.close();
+ }
},
- widget: function() {
- return this.element.data("tooltip").getTip();
+ error: function(msg) {
+ this.option("content", msg);
+ this.open();
},
- cancel: function() {
- var tip = this.element.data("tooltip");
- if( tip && tip.isShown() ) tip.hide();
- },
- show: function() {
- var tip = this.element.data("tooltip");
- tip.show();
- this.success(/*no msg*/);
+ success: function(msg) {
+ var self = this;
+ self.option("content", msg);
+ self.open();
+
+ // this is only a confirmation message. We can fade away quickly
+ window.setTimeout( function() { self.close(); }, 1500 );
},
- load: function(opts) {
+ load: function(args) {
+ /* opts is an object (or array of objects) containing overrides:
+ *
+ * endpoint : name of the endpoint we wish to use (not the URL)
+ *
+ * ajax : options for the AJAX call, in case you want to override the defaults
+ * Here are the moste useful ones:
+ *
+ * type : POST or GET
+ * data : any additional data to pass to the request
+ * e.g., POST parameters
+ * context : the context used for "this" in the callbacks
+ *
+ * success : success callback
+ * error : error callback
+ */
+
var self = this;
- var tip = self.element.data("tooltip");
- if( tip && ! opts.multiple ) {
- if( tip.inprogress ) return;
- if( tip.isShown() ) tip.hide();
- tip.inprogress = true;
+ // abort and remove any old requests
+ if ( self.requests.length ) {
+ $.each( self.requests, function (i, req) {
+ req.abort();
+ });
+ self.requests = [];
+ }
+
+ if ( self.options.loadingContent ) {
+ self.option("content", self.options.loadingContent);
+ self.open();
}
- self.element.trigger("ajaxstart" + self._namespace());
-
- var xhr = $.ajax({
- type: opts.formmethod || "POST",
- url : opts.endpoint ? self._endpointurl( opts.endpoint) : opts.url,
- data: opts.data,
- context: opts.context,
-
- dataType: "json",
- complete: function() {
- var tip = self.element.data("tooltip");
- if ( tip ) {
- tip.inprogress = false;
- var tipele = tip.getTip();
- self._reposition( tipele );
- tipele.removeData("xhr");
+ $.each( $.isArray( args ) ? args : [ args ], function (i, opts) {
+ var endpoint_url = $.endpoint( opts["endpoint"] );
+
+ var deferred = $.ajax( $.extend({
+ url : endpoint_url,
+ context: self,
+
+ dataType: "json"
+ }, opts.ajax ));
+ self.requests.push( deferred );
+
+ deferred.fail(function(jqxhr, status, error) {
+ // "abort" status means we cancelled the ajax request
+ if ( status !== "abort" ) {
+ self.error( "Error contacting server: " + error );
}
- },
- success: opts.success,
- error: opts.error ? opts.error : function( jqxhr, status, error ) {
- if ( status == "abort" )
- this.element.ajaxtip("cancel");
- else
- this.element.ajaxtip( "error", "Error contacting server. " + error);
-
- this._trigger( "complete" );
+ });
+
+ if ( ! self.options.loadingContent ) {
+ // now add the throbber. It will be removed automatically
+ $(self.element).throbber( deferred );
}
+ } );
+
+ // clean out requests queue once all requests have successfully completed
+ $.when.apply( $, self.requests ).done(function() {
+ self.requests = [];
});
- if ( tip ) tip.getTip().data( "xhr", xhr );
- },
- success: function(msg) {
- this.element.trigger({ type: "ajaxresult"+this._namespace(),
- ajaxresult: { message: msg, status: "success" } })
- },
- error: function(msg) {
- this.element.trigger({ type: "ajaxresult"+this._namespace(),
- ajaxresult: { message: msg, status: "error" } })
- },
- abort: function(msg) {
- this.element.data("tooltip").show();
- this.element.trigger({ type: "ajaxresult"+this._namespace(),
- ajaxresult: { message: msg, status: "error" } })
}
});
$.extend( $.dw.ajaxtip, {
closeall: function(e) {
- $(".ajaxtip:visible").each(
- function(){
- var $this = $(this);
-
- if ( e && e.target && $this.has( e.target ).length > 0 ) {
- // clicked inside this popup; do nothing
- } else {
- $(this).trigger("close");
- }
- })
+ $(":dw-ajaxtip").ajaxtip( "closeinactive", $(e.target).closest(".ajaxtip") );
}
-})
-})(jQuery);
+});
+})(jQuery, Site);
jQuery(function($) {
$(document).click(function(e) {
View
22 htdocs/js/jquery.autocompletewithunknown.js
@@ -157,7 +157,7 @@
if ( self.cache[self.currentCache] != null )
return response( self._filterTags( self.cache[self.currentCache], request.term ) );
},
-
+ autoFocus: true,
select: _handleComplete
}).bind("keydown.autocompleteselect", function( event ) {
var keyCode = $.ui.keyCode;
@@ -170,22 +170,12 @@
_handleComplete.apply( $input,
[event, { item: { value: $input.val() } } ]);
self.justCompleted = true;
+ $input.autocomplete("close");
event.preventDefault();
- var $menu = $input.data("autocomplete").menu;
- $menu.deactivate();
-
return;
case keyCode.TAB:
- var $menu = $input.data("autocomplete").menu;
- if ( $menu.element.is(":visible")) {
- if ( !$menu.active ) {
- $menu.next(event);
- $menu.select();
- self.justCompleted = true;
- }
- event.preventDefault();
- } else if ($input.val()) {
+ if ($input.val()) {
_handleComplete.apply( $input,
[event, { item: { value: $input.val() } } ]);
self.justCompleted = true;
@@ -205,7 +195,7 @@
_handleComplete.apply( $input, [event, { item: { value: $input.val() } } ]);
}).change(function(event){
// if we have the menu open, let that handle the autocomplete
- var $menu = $(this).data("autocomplete").menu;
+ var $menu = $(this).data("ui-autocomplete").menu;
if ( $menu.element.is(":visible") ) return;
_handleComplete.apply( $(this), [event, { item: { value: $(event.currentTarget).val() } } ]);
@@ -216,9 +206,9 @@
self.justCompleted = false;
}
})
- .data("autocomplete")._renderItem = function( ul, item ) {
+ .data("ui-autocomplete")._renderItem = function( ul, item ) {
return $( "<li></li>" )
- .data( "item.autocomplete", item )
+ .data( "ui-autocomplete-item", item )
.append( "<a>" + item.label + "</a>" )
.appendTo( ul );
};
View
16 htdocs/js/jquery.collapsible.js
@@ -1,11 +1,4 @@
(function($) {
-$.fn.ultrafocus = function( focus, blur ) {
- return $(this)
- .focus(focus)
- .blur(blur)
- .hover(focus, blur);
-}
-
$.widget("ui.collapsible", {
_init: function() {
var self = this;
@@ -23,11 +16,10 @@ $.widget("ui.collapsible", {
self._trigger.attr("aria-controls", self._target.attr("id"))
self.element.data("collapsibleid", $.proxy(opts.parseid, self.element)());
- $trigger.ultrafocus(function() {
- $(this).addClass(opts.triggerHoverClass);
- }, function() {
- $(this).removeClass(opts.triggerHoverClass);
- })
+ self._hoverable( $trigger );
+ self._focusable( $trigger );
+
+ $trigger
.addClass(opts.triggerClass)
.append("<span class='ui-icon'></span>")
.wrapInner($("<a href='#'></a>").attr({ href: "#" }))
View
178 htdocs/js/jquery.commentmanage.js
@@ -23,7 +23,7 @@ $.widget("dw.moderate", {
journal: undefined,
form_auth: undefined,
- endpoint: "__rpc_talkscreen",
+ endpoint: "talkscreen"
},
_updateLink: function(newData) {
this.element.attr("href", newData.newurl);
@@ -50,13 +50,11 @@ $.widget("dw.moderate", {
_abort: function(reason, ditemid) {
ditemid = ditemid || this.linkdata.id;
- this.element.ajaxtip({namespace:"moderate"})
- .ajaxtip( "abort", "Error moderating comment #" + ditemid + ". " + reason);
+ this.element.ajaxtip().ajaxtip( "error", "Error moderating comment #" + ditemid + ". " + reason);
},
_create: function() {
var self = this;
-
var params = $.extractParams(this.element.attr("href"));
this.linkdata = {
id: params.talkid || "",
@@ -83,31 +81,36 @@ $.widget("dw.moderate", {
return;
}
- var posturl = "/" + self.options.journal + "/" + self.options.endpoint
- + "?jsmode=1&json=1&mode=" + self.linkdata.action;
+ var endpoint = self.options.endpoint +
+ "?jsmode=1&json=1&mode=" + self.linkdata.action;
self.element
- .ajaxtip({
- namespace: "moderate",
- })
- .ajaxtip("load", {
- url: posturl,
- context: self,
- data: {
- talkid : self.linkdata.id,
- journal : self.options.journal,
-
- confirm : "Y",
- lj_form_auth: self.options.form_auth
- },
- success: function( data, status, jqxhr ) {
- if ( data.error ) {
- self.element.ajaxtip( "error", "Error while trying to " + self.linkdata.action + ": " + data.error )
- } else {
- self.element.ajaxtip("success",data.msg);
- self._updateLink(data);
+ .ajaxtip() // init
+ .ajaxtip( "load", {
+ endpoint: endpoint,
+
+ ajax: {
+ type: "POST",
+
+ context: self,
+
+ data: {
+ talkid : self.linkdata.id,
+ journal : self.options.journal,
+
+ confirm : "Y",
+ lj_form_auth: self.options.form_auth
+ },
+
+ success: function( data, status, jqxhr ) {
+ if ( data.error ) {
+ this.element.ajaxtip( "error", "Error while trying to " + this.linkdata.action + ": " + data.error );
+ } else {
+ this.element.ajaxtip( "success", data.msg );
+ this._updateLink(data);
+ }
+ self._trigger( "complete" );
}
- self._trigger( "complete" );
}
});
});
@@ -120,13 +123,13 @@ $.widget("dw.delcomment", {
journal: undefined,
form_auth: undefined,
- endpoint: "__rpc_delcomment"
+ endpoint: "delcomment"
},
_abort: function(reason, ditemid) {
ditemid = ditemid || this.linkdata.id;
- this.element.ajaxtip({namespace:"delcomment"})
- .ajaxtip( "abort", "Error deleting comment #" + ditemid + ". " + reason);
+ this.element.ajaxtip() // init
+ .ajaxtip( "error", "Error deleting comment #" + ditemid + ". " + reason );
},
_create: function() {
@@ -149,30 +152,35 @@ $.widget("dw.delcomment", {
return;
}
- var posturl = "/" + self.options.journal + "/" + self.options.endpoint
- +"?"+$.param({ mode: "js", json: 1, journal: self.options.journal, id: self.linkdata.id});
+ var endpoint = self.options.endpoint +
+ "?"+$.param({ mode: "js", json: 1, journal: self.options.journal, id: self.linkdata.id});
var postdata = { confirm: 1 };
if($("#popdel"+self.linkdata.id+"ban").is(":checked")) postdata["ban"] = 1;
if($("#popdel"+self.linkdata.id+"spam").is(":checked")) postdata["spam"] = 1;
if($("#popdel"+self.linkdata.id+"thread").is(":checked")) postdata["delthread"] = 1;
if(self.options.form_auth) postdata["lj_form_auth"] = self.options.form_auth;
- self.element
- .ajaxtip("load", {
- url: posturl,
- data: postdata,
- context: self,
- success: function( data, status, jqxhr ) {
- if ( data.error ) {
- self.element.ajaxtip( "error", "Error while trying to delete comment: " + data.error )
- } else {
- self.element.ajaxtip("success",data.msg);
- removecomment(self.linkdata.id, postdata["delthread"]);
+ self.element.ajaxtip()
+ .ajaxtip( "load", {
+ endpoint: endpoint,
+ ajax: {
+ type: "POST",
+ context: self,
+
+ data: postdata,
+
+ success: function( data, status, jqxhr ) {
+ if ( data.error ) {
+ this.element.ajaxtip( "error", "Error while trying to delete comment: " + data.error );
+ } else {
+ this.element.ajaxtip( "success", data.msg );
+ removecomment(this.linkdata.id, postdata["delthread"]);
+ }
+ self._trigger( "complete" );
}
- self._trigger( "complete" );
}
- })
+ });
}
function removecomment(ditemid,killchildren) {
@@ -209,57 +217,59 @@ $.widget("dw.delcomment", {
}
if ( e.shiftKey ) {
- self.element.ajaxtip({ namespace: "delcomment" })
deletecomment();
return;
}
- self.element
- .ajaxtip({
- namespace: "delcomment",
- content: function() {
- var canAdmin = cmtinfo["canAdmin"];
- var canSpam = cmtinfo["canSpam"];
-
- var form = $("<form class='popup-form'><fieldset><legend>Delete comment?</legend></fieldset></form>");
- var ul = $("<ul>").appendTo(form.find("fieldset"));
-
- if(remote != "" && cmtdata.u != "" && cmtdata.u != remote && canAdmin) {
- var id = "popdel"+self.linkdata.id+"ban";
- ul.append($("<li>").append(
- $("<input>", { type: "checkbox", value: "ban", id: id}),
- $("<label>", { "for": id }).html("Ban <strong>"+cmtdata.u+"</strong> from commenting")
- ));
- }
- if(remote != "" && cmtdata.u != remote && canSpam) {
- var id = "popdel"+self.linkdata.id+"spam";
- ul.append($("<li>").append(
- $("<input>", { type: "checkbox", value: "spam", id: id}),
- $("<label>", { "for": id }).text("Mark this comment as spam")
- ));
- }
+ var $deleteDialog = function() {
+ var canAdmin = cmtinfo["canAdmin"];
+ var canSpam = cmtinfo["canSpam"];
- if(cmtdata.rc && cmtdata.rc.length && canAdmin){
- var id = "popdel"+self.linkdata.id+"thread";
- ul.append($("<li>").append(
- $("<input>", { type: "checkbox", value: "thread", id: id}),
- $("<label>", { "for": id }).text("Delete thread (all subcomments)")
- ));
- }
+ var _checkbox = function(action, label) {
+ var prefix = "popdel"+self.linkdata.id;
+ return "<li><input type='checkbox' value='"+action+"' id='"+prefix+action+"'>" +
+ "<label for='"+prefix+action+"'>"+label+"</label></li>";
+ };
- ul.append($("<li>", { "class": "submit" }).append(
- $("<input>", { type: "button", value: "Delete"})
- .click(deletecomment),
+ var form = $("<form></form>");
+ var checkboxes = [];
- $("<input>", { type: "button", value: "Cancel" })
- .click(function(){self.element.ajaxtip("cancel")}),
+ if(remote !== "" && cmtdata.u !== "" && cmtdata.u !== remote && canAdmin) {
+ checkboxes.push(_checkbox( "ban", "Ban <strong>"+cmtdata.u+"</strong> from commenting" ));
+ }
- $("<div class='note'>shift-click to delete without options</div>")
- ));
+ if(remote !== "" && cmtdata.u !== remote && canSpam) {
+ checkboxes.push(_checkbox( "spam", "Mark this comment as spam" ));
+ }
- return form;
+ if(cmtdata.rc && cmtdata.rc.length && canAdmin){
+ checkboxes.push(_checkbox( "thread", "Delete thread (all subcomments)" ));
}
+
+ $("<ul>").append(checkboxes.join("")).appendTo(form);
+ $("<p class='detail'>shift-click to delete without options</p>").appendTo(form);
+
+ return form;
+ }();
+
+ $deleteDialog.dialog({
+ title: "Delete Comment",
+ position: {
+ my: "center bottom",
+ at: "right top",
+ of: this,
+ collision: "fit fit"
+ },
+ buttons: {
+ "Delete": function() {
+ $(this).dialog( "close" );
+ deletecomment();
+ }
+ },
+ dialogClass: "popdel",
+ maxWidth: "80%",
+ width: 500
});
});
}
View
431 htdocs/js/jquery.contextualhover.js
@@ -1,4 +1,5 @@
(function($, Site){
+var document = window.document;
$.fn.contextualhoversetup = function() {
if (!Site || !Site.ctx_popup) return;
@@ -47,6 +48,24 @@ function _initIcons(context) {
})(jQuery, Site);
+/* The contextual hover menu
+
+ appears:
+ - when you hover over the trigger a short period of time
+ - NOT if you merely pass the mouse over the trigger
+
+ lingers:
+ - as long as the mouse is over the trigger
+ - if you move the mouse from the trigger to the contextual popup
+ - as long as the mouse is over the tooltip
+ - NOT if you move the mouse away from the trigger before the popup is fully visible
+
+ disappears:
+ - when you move the mouse over then out of the contextual popup
+ - a short time after you move the mouse out of the trigger
+ (only if you don't then move it to the popup)
+ */
+
$.widget("dw.contextualhover", {
options: {
disableAJAX: false,
@@ -61,83 +80,150 @@ _create: function() {
var opts = self.options;
if ( opts.type == "icon" ) {
- var parent = self.element.parent("a")
+ var parent = self.element.parent("a");
if ( parent.length > 0 )
self.element = parent;
}
var trigger = self.element;
- trigger.addClass("ContextualPopup");
-
- var action = $.fn.hoverIntent ? "hoverIntent" : "hover";
- trigger[action](
- function() {
- if ( self.cachedResults ) {
- self._renderPopup();
- self._trigger("complete");
- return;
- }
+ trigger.addClass("ContextualPopup-trigger");
- trigger.ajaxtip({ namespace: "contextualpopup", persist: true })
- .ajaxtip( "load", {
- endpoint: "ctxpopup",
- formmethod: "GET",
- context: self,
- data: {
- "user": opts.username || "",
- "userid": opts.userid || 0,
- "userpic_url": opts.icon_url || "",
- "mode": "getinfo"
+ trigger.hoverIntent( {
+ // how long before the popup fades out automatically once you've moved away
+ timeout: 1500,
+
+ over: function() {
+ if ( self.cachedResults ) {
+ self._renderPopup();
+ return;
+ }
+
+ trigger.ajaxtip({
+ tooltipClass: "ContextualPopup",
+ loadingContent: "<img src='" + $.throbber.src + "' alt='Loading' />",
+
+ // called after the popup is opened
+ open: function(event, ui) {
+ var ns = event.handleObj.namespace;
+ var $trigger = $(this);
+ var $tooltip = ui.tooltip;
+ $tooltip.promise().done(function() {
+ // turn off the mouseleave/focusout events which close the popup immediately
+ // but only once fade in is done and popup is fully visible
+ // this is both a technical limitation
+ // (the callback fires before the events are registered in tooltip)
+ // and desired behavior
+ // (if the tooltip isn't fully visible yet, but they've moved away, assume they don't want it)
+ $trigger.off( "mouseleave." + ns + " focusout." + ns );
+ });
+
+ // the popup will also fade away after a short delay
+ // once you've moved your mouse away from the trigger
+ // this is to prevent the annoying behavior of the popup never going away
+ // HOWEVER we want to ignore the timeout if we've moused over the popup at any point
+ // so record if this has happened
+ $tooltip.one( "mouseover." +ns, function() {
+ // event from $.fn.hoverIntent
+ $trigger.data( "popup-persist", true );
+ } )
+
+ // attach listeners to links for dynamic actions
+ .on( "click", "a[data-dw-ctx-action]", function(e){
+ e.stopPropagation();
+ e.preventDefault();
+
+ self._changeRelation( $(this) );
+ });
},
- success: function( data, status, jqxhr ) {
- if ( data.error ) {
- if ( data.noshow )
- trigger.ajaxtip( "cancel" );
- else
- trigger.ajaxtip( "error", data.error )
- } else {
- self.cachedResults = data;
- self._renderPopup();
-
- // expire cache after 5 minutes
- setTimeout(function() {
- self.cachedResults = null;
- }, 60 * 5 * 1000);
+ // called after the popup has closed
+ close: function(event, ui) {
+ // cleanup
+ ui.tooltip.off( "mouseover." + event.handleObj.namespace );
+ }
+ }).ajaxtip( "load", {
+
+ endpoint: "ctxpopup",
+
+ ajax: {
+ context: self,
+
+ data: {
+ "user": opts.username || "",
+ "userid": opts.userid || 0,
+ "userpic_url": opts.icon_url || "",
+ "mode": "getinfo"
+ },
+
+ success: function( data, status, jqxhr ) {
+ if ( data.error ) {
+ if ( data.noshow ) {
+ trigger.ajaxtip( "close" );
+ } else {
+ trigger.ajaxtip( "error", data.error );
+ }
+ } else {
+ this.cachedResults = data;
+ this._renderPopup();
+
+ // expire cache after 5 minutes
+ setTimeout(function() {
+ self.cachedResults = null;
+ }, 60 * 5 * 1000);
+
+ }
}
- self._trigger("complete");
}
});
- },
- function() {
- }
- )
+ },
+ out: function(e) {
+ var persist = trigger.data("popup-persist");
+ if ( ! persist ) {
+ trigger.ajaxtip( "close" );
+ }
+ trigger.removeData("popup-persist");
+ }
+ } );
+},
+
+_addRelationStatus: function( string ) {
+ this._rel_html.push( "<div>" + string + "</div>");
+},
+
+_addAction: function( url, text, action ) {
+ action = !! action ? ' data-dw-ctx-action="' + action + '"' : "";
+ this._actions_html.push( '<div><a href="' + url+ '"' + action + '>' + text + '</a></div>' );
+},
+_addText: function( text ) {
+ this._actions_html.push( '<div>' + text + '</div>' );
},
_renderPopup: function() {
var self = this;
+ var $trigger = this.element;
var opts = self.options;
var data = self.cachedResults;
+ this._actions_html = [];
+ this._rel_html = [];
if ( data && ( !data.username || !data.success || data.noshow ) ) {
- this.element.ajaxtip("cancel");
+ return undefined;
}
- var $inner = $("<div class='Inner'></div>");
- var $content = $("<div class='Content'></div>");
+ var userpic_html = "";
if ( data.url_userpic ) {
- var $link = $("<a></a>", { href: data.url_allpics });
- var $icon = $("<img>", { src: data.url_userpic }).attr({width: data.userpic_w, height: data.userpic_h});
- var $container = $("<div class='Userpic'></div>").append($link.append($icon));
-
- $inner.append($container);
+ userpic_html = '<div class="Userpic">' +
+ '<a href="' + data.url_allpics + '">' +
+ '<img src="' + data.url_userpic + '"' +
+ ' width="' + data.userpic_w + '"' +
+ ' height="' + data.userpic_h + '"' +
+ ' />' +
+ '</a>' +
+ '</div>';
}
- $inner.append($content);
-
var username = data.display_username;
- var $relation = $("<div class='Relation'></div>");
- var strings = {
+ var rel_strings = {
member: "You are a member of " + username,
watching: "You have subscribed to " + username,
watched_by: username + " has subscribed to you",
@@ -147,213 +233,154 @@ _renderPopup: function() {
mutual_trust: username + " and you have mutual access",
self: "This is you"
};
+
if ( data.is_comm ) {
- var rels = [];
- if (data.is_member) rels.push(strings.member);
- if (data.is_watching) rels.push(strings.watching);
+ if (data.is_member) this._addRelationStatus(rel_strings.member);
+ if (data.is_watching) this._addRelationStatus(rel_strings.watching);
- $relation.html(rels.length > 0 ? rels.join("<br />") : username);
} else if (data.is_syndicated ) {
- $relation.html(data.is_watching ? strings.watching : username);
+ this._addRelationStatus( data.is_watching ? rel_strings.watching : username );
} else if (data.is_requester) {
- $relation.html( strings.self );
+ this._addRelationStatus( rel_strings.self );
} else {
- var rels = [];
if ( data.is_trusting && data.is_trusted_by )
- rels.push(strings.mutual_trust);
+ this._addRelationStatus( rel_strings.mutual_trust );
else if ( data.is_trusting )
- rels.push(strings.trusting);
+ this._addRelationStatus( rel_strings.trusting );
else if ( data.is_trusted_by )
- rels.push(strings.trusted_by);
+ this._addRelationStatus( rel_strings.trusted_by );
if ( data.is_watching && data.is_watched_by )
- rels.push(strings.mutual_watch);
+ this._addRelationStatus( rel_strings.mutual_watch );
else if ( data.is_watching )
- rels.push(strings.watching);
+ this._addRelationStatus( rel_strings.watching );
else if ( data.is_watched_by )
- rels.push(strings.watched_by);
+ this._addRelationStatus( rel_strings.watched_by );
+ }
+
+ if ( ! this._rel_html.length )
+ this._addRelationStatus( username );
+
+ if ( data.is_person || data.is_comm || data.is_syndicated ) {
+ var journal_text = "";
+ if (data.is_person)
+ journal_text ="View journal";
+ else if ( data.is_comm )
+ journal_text = "View community";
+ else if ( data.is_syndicated )
+ journal_text = "View feed";
+
+ this._addAction( data.url_journal, journal_text );
+ this._addAction( data.url_profile, "View profile" );
+ }
- $relation.html(rels.length > 0 ? rels.join("<br />") : username);
+ if ( data.is_logged_in && ( data.is_person || data.is_identity ) && data.can_message ) {
+ this._addAction( data.url_message, "Send message" );
}
- $content.append($relation);
if ( data.is_logged_in && data.is_comm ) {
- var $membership = $("<span></span>");
if ( ! data.is_closed_membership || data.is_member ) {
- var $membershiplink = $("<a></a>");
- var membership_action = data.is_member ? "leave" : "join";
-
if ( data.is_member )
- $membershiplink.attr("href" , data.url_leavecomm ).html("Leave");
+ this._addAction( data.url_leavecomm, "Leave", "leave" );
else
- $membershiplink.attr("href", data.url_joincomm ).html("Join community");
-
- if ( ! opts.disableAJAX ) {
- $membershiplink.click(function(e) {
- e.stopPropagation(); e.preventDefault();
- self._changeRelation(data, membership_action, this, e);
- });
- }
-
- $membership.append($membershiplink);
+ this._addAction( data.url_joincomm, "Join community", "join" );
} else {
- $membership.html("Community closed");
+ this._addRelationStatus( "Community closed" );
}
- $content.append($membership, "<br />" );
}
- var links = [];
- if ( data.is_logged_in && ( data.is_person || data.is_identity ) && data.can_message ) {
- var $sendmessage = $("<a></a>", { href: data.url_message }).html("Send message");
- links.push($("<span></span>").append($sendmessage));
- }
-
- // relationships
if ( data.is_logged_in && ! data.is_requester ) {
if ( ! data.is_trusting ) {
if ( data.is_person || data.other_is_identity ) {
- var $addtrust = $("<a></a>", { href: data.url_addtrust } ).html("Grant access");
- links.push($("<span class='AddTrust'></span>").append($addtrust));
-
- if( ! opts.disableAJAX ) {
- $addtrust.click(function(e) {
- e.stopPropagation(); e.preventDefault();
- self._changeRelation(data, "addTrust", this, e);
- });
- }
+ this._addAction( data.url_addtrust, "Grant access", "addTrust" );
}
} else {
if ( data.is_person || data.other_is_identity ) {
- var $removetrust = $("<a></a>", { href: data.url_addtrust } ).html("Remove access");
- links.push($("<span class='RemoveTrust'></span>").append($removetrust));
-
- if( ! opts.disableAJAX ) {
- $removetrust.click(function(e) {
- e.stopPropagation(); e.preventDefault();
- self._changeRelation(data, "removeTrust", this, e);
- });
- }
+ this._addAction( data.url_addtrust, "Remove access", "removeTrust" );
}
}
if ( !data.is_watching && !data.other_is_identity ) {
- var $addwatch = $("<a></a>", { href: data.url_addwatch } ).html("Subscribe");
- links.push($("<span class='AddWatch'></span>").append($addwatch));
-
- if( ! opts.disableAJAX ) {
- $addwatch.click(function(e) {
- e.stopPropagation(); e.preventDefault();
- self._changeRelation(data, "addWatch", this, e);
- });
- }
+ this._addAction( data.url_addwatch, "Subscribe", "addWatch" );
} else if ( data.is_watching ) {
- var $removewatch = $("<a></a>", { href: data.url_addwatch } ).html("Remove subscription");
- links.push($("<span class='RemoveWatch'></span>").append($removewatch));
-
- if( ! opts.disableAJAX ) {
- $removewatch.click(function(e) {
- e.stopPropagation(); e.preventDefault();
- self._changeRelation(data, "removeWatch", this, e);
- });
- }
+ this._addAction( data.url_addwatch, "Remove subscription", "removeWatch" );
}
- $relation.addClass("RelationshipStatus");
}
// FIXME: double-check this when vgifts come out
if ( ( data.is_person || data.is_comm ) && ! data.is_requester && data.can_receive_vgifts ) {
- var $sendvgift = $("<a></a>", { href: Site.siteroot + "/shop/vgift?to=" + data.username })
- .html("Send a virtual gift");
- links.push($("<span></span").append($sendvgift));
+ this._addAction( Site.siteroot + "/shop/vgift?to=" + data.username, "Send a virtual gift" );
}
if ( data.is_logged_in && ! data.is_requester && ! data.is_syndicated ) {
if ( data.is_banned ) {
- var $unbanlink = $("<a></a>", { href: Site.siteroot + "/manage/banusers" });
- $unbanlink.html( data.is_comm ? "Unban community" : "Unban user" );
- if( ! opts.disableAJAX ) {
- $unbanlink.click(function(e) {
- e.stopPropagation(); e.preventDefault();
- self._changeRelation(data, "setUnban", this, e);
- });
- }
- links.push($("<span class='SetUnban'></span>").append($unbanlink));
-
+ this._addAction( Site.siteroot + "/manage/banusers",
+ data.is_comm ? "Unban community" : "Unban user", "setUnban" );
} else {
+ this._addAction( Site.siteroot + "/manage/banusers",
+ data.is_comm ? "Ban community" : "Ban user", "setBan" );
var $banlink = $("<a></a>", { href: Site.siteroot + "/manage/banusers" });
- $banlink.html( data.is_comm ? "Ban community" : "Ban user" );
- if( ! opts.disableAJAX ) {
- $banlink.click(function(e) {
- e.stopPropagation(); e.preventDefault();
- self._changeRelation(data, "setBan", this, e);
- });
- }
- links.push($("<span class='SetBan'></span>").append($banlink));
}
}
- var linkslength = links.length;
- $.each(links,function(index) {
- $content.append(this);
- $content.append("<br>");
- });
-
- $("<span>View: </span>").appendTo($content);
- if ( data.is_person || data.is_comm || data.is_syndicated ) {
- var $journallink = $("<a></a>", {href: data.url_journal});
- if (data.is_person)
- $journallink.html("Journal");
- else if ( data.is_comm )
- $journallink.html("Community");
- else if ( data.is_syndicated )
- $journallink.html("Feed");
-
- $content.append(
- $journallink,
- $("<span> | </span>"),
- $("<a></a>", { href: data.url_profile} ).html("Profile")
- );
- }
+ var content = '<div class="Content">' +
+ '<div class="Relation">' + this._rel_html.join( "" ) + '</div>' +
+ '<div class="Actions">' + this._actions_html.join("") + '</div>' +
+ '</div>';
- $content.append($("<div class='ljclear'>&nbsp;</div>"));
-
- this.element.ajaxtip("show")
this.element
- .ajaxtip("widget")
- .removeClass("ajaxresult ajaxtooltip").addClass("ContextualPopup")
- .empty().append($inner);
+ .ajaxtip( "option", "content", userpic_html + content )
+ .ajaxtip( "open" );
},
-_changeRelation: function(info, action, link, e) {
- if ( !info ) return;
+_changeRelation: function($link) {
+
var self = this;
- var $link = $(link);
+ var info = self.cachedResults;
+ if ( !info ) return;
+
+ var action = $link.data( "dw-ctx-action" );
- $link.ajaxtip({namespace: "changerelation"}).ajaxtip("load", {
+ // stop the popup from wiggling around when a status is removed
+ var $popup = $link.closest(".ContextualPopup");
+ var $r = $popup.find(".Relation");
+ var relheight = $r.height();
+ var oldheight = $popup.data( "relheight" );
+ if ( ! oldheight ) oldheight = 0;
+ if ( relheight > oldheight ) $popup.data("relheight", relheight);
+
+ $link.ajaxtip() // init
+ .ajaxtip( "load", {
endpoint: "changerelation",
- context: self,
- data: {
- target: info.username,
- action: action,
- auth_token: info[action+"_authtoken"]
- },
- success: function( data, status, jqxhr ) {
- if ( data.error ) {
- $link.ajaxtip( "error", data.error )
- } else if ( ! data.success ) {
- $link.ajaxtip( "error", "Did not change relation successfully" );
- self._renderPopup(data);
- } else {
- if ( self.cachedResults ) {
- var updatedProps = [ "is_trusting", "is_watching", "is_member", "is_banned" ];
- $.each(updatedProps,function(){
- self.cachedResults[this]=data[this];
- });
+
+ ajax: {
+ type: "POST",
+
+ context: self,
+
+ data: {
+ target: info.username,
+ action: action,
+ auth_token: info[action+"_authtoken"]
+ },
+
+ success: function( data, status, jqxhr ) {
+ if ( data.error ) {
+ $link.ajaxtip( "error", data.error );
+ } else if ( ! data.success ) {
+ $link.ajaxtip( "error", "Did not change relation successfully" );
+ self._renderPopup();
+ } else {
+ if ( self.cachedResults ) {
+ var updatedProps = [ "is_trusting", "is_watching", "is_member", "is_banned" ];
+ $.each(updatedProps,function(){
+ self.cachedResults[this] = data[this];
+ });
+ }
+ self._renderPopup();
+ $popup.find(".Relation").css( "min-height", $popup.data( "relheight" ) );
}
- $link.ajaxtip( "cancel" );
- self._renderPopup();
}
- self._trigger("complete");
}
});
}
View
32 htdocs/js/jquery.crosspost.js
@@ -146,18 +146,24 @@ _create: function() {
var $crosspost_entry = $("#crosspost_entry");
var allUnchecked = ! $accounts.is(":checked");
if ( allUnchecked ) {
- $crosspost_entry.removeAttr("checked").attr("disabled","disabled");
+ $crosspost_entry.prop({
+ "checked": false,
+ "disabled": true
+ });
} else {
- $crosspost_entry.removeAttr("disabled").attr("checked","checked");
+ $crosspost_entry.prop({
+ "checked": true,
+ "disabled": false
+ });
}
- };
+ }
$accounts = $("#crosspost_accounts input[name='crosspost']")
.crosspostaccount({ mainCheckbox: "#crosspost_entry" })
.change(crosspostAccountUpdated)
.bind("crosspostaccountcancel", function() {
$(this).closest("form").find("input[type='submit']")
- .removeAttr("disabled").removeClass("ui-state-disabled");
+ .prop("disabled", false).removeClass("ui-state-disabled");
})
.bind("crosspostaccountchalrespcomplete", function () {
// use an array intead of $.each so that we can return out of the function
@@ -182,7 +188,7 @@ _create: function() {
}
$form.find("input[type='submit']")
- .removeAttr("disabled").removeClass("ui-state-disabled");
+ .prop("disabled", false).removeClass("ui-state-disabled");
})
crosspostAccountUpdated();
@@ -192,13 +198,13 @@ _create: function() {
var $inputs = $("#crosspost_accounts").find("input");
if ( do_crosspost_entry ) {
- $inputs.removeAttr("disabled")
+ $inputs.prop("disabled", false)
var $checkboxes = $inputs.filter("[name='crosspost']");
if ( ! $checkboxes.is(":checked") )
- $checkboxes.attr("checked", "checked")
+ $checkboxes.prop("checked", true)
} else {
- $inputs.attr("disabled", "disabled")
+ $inputs.prop("disabled", true)
}
});
@@ -209,7 +215,7 @@ _create: function() {
_checkSubmit: function (e) {
var $target = $(e.target);
if ( ! skipChecks && ! $target.data("preventedby") && ! $target.data("skipchecks") ) {
- $(this).find("input[type='submit']").attr("disabled","disabled").addClass("ui-state-disabled");
+ $(this).find("input[type='submit']").prop("disabled",true).addClass("ui-state-disabled");
var needChalResp = false;
$accounts.each(function() {
@@ -246,16 +252,16 @@ toggle: function(why, allowThisCrosspost, animate) {
// preserve existing disabled state if crosspost allowed
var allUnchecked = ! $accounts.is(":checked")
if ( ! allowCrosspost || allUnchecked )
- $crosspost_entry.attr("disabled", "disabled")
+ $crosspost_entry.prop("disabled", true)
else
- $crosspost_entry.removeAttr("disabled")
+ $crosspost_entry.prop("disabled", false)
var enableAccountCheckboxes = allowCrosspost && ( allUnchecked || $crosspost_entry.is(":checked") );
if (enableAccountCheckboxes)
- $accounts.removeAttr("disabled");
+ $accounts.prop("disabled",false);
else
- $accounts.attr("disabled", "disabled");
+ $accounts.prop("disabled", true);
if ( allowCrosspost ) {
skipChecks = false;
View
8 htdocs/js/jquery.cuttag-ajax.js
@@ -191,7 +191,7 @@ $.widget("dw.cuttag_controls", {
var aria_closed = "";
cuttags.each(function (_,element) {
- var el = $(element).data("cuttag");
+ var el = $(element).data("dw-cuttag");
if ( el.isOpen() ) {
aria_open += " div-cuttag_" + el.identifier;
} else {
@@ -224,7 +224,7 @@ $.widget("dw.cuttag_controls", {
isExpandingAll = 1;
var cuttags = $("span.cuttag");
cuttags.each(function (_,element) {
- $(element).data("cuttag").open();
+ $(element).data("dw-cuttag").open();
});
});
}
@@ -246,7 +246,7 @@ $.widget("dw.cuttag_controls", {
isExpandingAll = 0;
to_do = 1;
cuttags.each(function (_,element) {
- var widget = $(element).data("cuttag");
+ var widget = $(element).data("dw-cuttag");
if ( widget )
widget.close();
});
@@ -268,7 +268,7 @@ $.extend( $.dw.cuttag_controls, {
var controls = $(".cutTagControls");
controls.each(function (_,element) {
- $(element).data("cuttag_controls").update();
+ $(element).data("dw-cuttag_controls").update();
});
}
});
View
151 htdocs/js/jquery.esn.js
@@ -1,13 +1,17 @@
-(function($,Site,cmtinfo){
+(function($,Site){
+
+if ( ! window.LJ_cmtinfo ) LJ_cmtinfo = {};
+
$.widget("dw.trackbutton", {
options: {},
_toggleSubscriptions: function(subInfo,subs) {
var self = this;
subInfo["subid"] = Number(subInfo["subid"]);
+ var data = [];
if ((subInfo["subid"] && ! subs["newComments"])
|| (! subInfo["subid"] && subs["newComments"])) {
- self._toggleSubscription(subInfo, "newComments");
+ data.push( self._toggleSubscription(subInfo, "newComments") );
}
subInfo["newentry_subid"] = Number(subInfo["newentry_subid"]);
@@ -16,7 +20,12 @@ _toggleSubscriptions: function(subInfo,subs) {
var newEntrySubInfo = new Object(subInfo);
newEntrySubInfo["subid"] = Number(subInfo["newentry_subid"]);
- self._toggleSubscription(newEntrySubInfo, "newEntry");
+ data.push(self._toggleSubscription(newEntrySubInfo, "newEntry"));
+ }
+
+ if ( data.length ) {
+ self.element.ajaxtip() // init
+ .ajaxtip("load", data );
}
},
@@ -53,12 +62,15 @@ _toggleSubscription: function(subInfo, type) {
params.action = action;
var $clicked = self.element;
- $clicked.ajaxtip({namespace: "trackbutton"})
- .ajaxtip("load", {
- endpoint: "esn_subs",
+ return {
+ endpoint: "esn_subs",
+ ajax: {
+ type: "POST",
+
context: self,
+
data: params,
- multiple: true,
+
success: function( data, status, jqxhr ) {
if (data.error) {
$clicked.ajaxtip("error", data.error);
@@ -96,7 +108,7 @@ _toggleSubscription: function(subInfo, type) {
// otherwise set state to "parent", which is equivalent to "on"
var $parentBtn;
var parent_dtalkid = dtalkid;
- var cmtInfo = cmtinfo[dtalkid+""];
+ var cmtInfo = LJ_cmtinfo[dtalkid+""];
while ( $parentBtn = self._getParentButton(parent_dtalkid) ) {
parent_dtalkid = $parentBtn.attr("lj_dtalkid");
@@ -107,22 +119,20 @@ _toggleSubscription: function(subInfo, type) {
break;
}
}
- self._updateThread(dtalkid, state);
+ this._updateThread(dtalkid, state);
} else {
- self._updateButton(self.element,state);
+ this._updateButton(self.element,state);
}
}
}
-
- self._trigger( "complete" );
}
- });
-
+ }
+ };
},
// given a dtalkid, find the track button for its parent comment (if any)
_getParentButton: function(dtalkid) {
- var cmt = cmtinfo[dtalkid+""];
+ var cmt = LJ_cmtinfo[dtalkid+""];
if ( ! cmt ) return null;
var parent_dtalkid = cmt.parent;
@@ -160,7 +170,7 @@ _updateThread: function(dtalkid, state) {
var $btn = $("#lj_track_btn_" + dtalkid);
if ( ! $btn.length ) return;
- var cmtInfo = cmtinfo[dtalkid + ""];
+ var cmtInfo = LJ_cmtinfo[dtalkid + ""];
if (! cmtInfo) return;
// subscription already exists on this button, don't mess with it
@@ -215,71 +225,70 @@ _create: function() {
btnInfo[arg] = $ele.attr("lj_" + arg);
});
- // show the menu
- $ele.ajaxtip({
- namespace:"trackbutton",
- content: function() {
-
- // the dialog we will show later
- var $dlg = $("<div class='trackdialog'><div class='track_title'>Email me when</div></div>");
-
- // this creates a new checkbox for a notification option with a specified name
- // and default check option
- var TrackCheckbox = function (title, checked) {
- var uniqueid = "newentrytrack" + Unique.id();
- var $checkbox = $("<input></input>",
- { "type": "checkbox", "id": uniqueid, "checked": checked });
- var $checkContainer = $("<div></div>")
- .append( $checkbox, $("<label></label>", { "for": uniqueid }).html(title) )
- .appendTo( $dlg );
-
- return $checkbox;
- };
-
- // is the user already tracking new entries by this user / new comments on this entry?
- var trackingNewEntries = Number(btnInfo['newentry_subid']) ? true : false;
- var trackingNewComments = Number(btnInfo['subid']) ? true : false;
-
- var $newEntryTrackBtn;
- var $commentsTrackBtn;
-
- if (Number($ele.attr("lj_dtalkid"))) {
- // this is a thread tracking button
- // always checked: either because they're subscribed, or because
- // they're going to subscribe.
- $commentsTrackBtn = TrackCheckbox("someone replies in this comment thread", true);
- } else {
- // entry tracking button
- var journal = cmtinfo["journal"] || $ele.attr("journal") || Site.currentJournal;
- if ( journal ) {
- $newEntryTrackBtn = TrackCheckbox( journal + " posts a new entry", trackingNewEntries );
- }
- $commentsTrackBtn = TrackCheckbox("someone comments on this post", trackingNewComments);
+
+ var $dlg = $("<div class='trackdialog'></div>");
+ var TrackCheckbox = function (title, checked) {
+ var uniqueid = "newentrytrack" + Unique.id();
+ var $checkbox = $("<input></input>",
+ { "type": "checkbox", "id": uniqueid, "checked": checked });
+ var $checkContainer = $("<div></div>")
+ .append( $checkbox, $("<label></label>", { "for": uniqueid }).html(title) )
+ .appendTo( $dlg );
+
+ return $checkbox;
+ };
+
+ // is the user already tracking new entries by this user / new comments on this entry?
+ var trackingNewEntries = Number(btnInfo['newentry_subid']) ? true : false;
+ var trackingNewComments = Number(btnInfo['subid']) ? true : false;
+
+ var $newEntryTrackBtn;
+ var $commentsTrackBtn;
+
+ if (Number($ele.attr("lj_dtalkid"))) {
+ // this is a thread tracking button
+ // always checked: either because they're subscribed, or because
+ // they're going to subscribe.
+ $commentsTrackBtn = TrackCheckbox("someone replies in this comment thread", true);
+ } else {
+ // entry tracking button
+ var journal = LJ_cmtinfo["journal"] || $ele.attr("journal") || Site.currentJournal;
+ if ( journal ) {
+ $newEntryTrackBtn = TrackCheckbox( journal + " posts a new entry", trackingNewEntries );
}
+ $commentsTrackBtn = TrackCheckbox("someone comments on this post", trackingNewComments);
+ }
- var $savebutton = $("<input type='button' class='track_savechanges' value='Save Changes'></input>")
- .click(function() {
+ $dlg.dialog({
+ title: "Email me when",
+ dialogClass: "track-dialog",
+ position: {
+ my: "center bottom",
+ at: "right top",
+ of: this,
+ collision: "fit fit"
+ },
+ buttons: {
+ "Save Changes": function() {
+ $(this).dialog( "close" );
self._toggleSubscriptions(btnInfo,{
newEntry: $newEntryTrackBtn ? $newEntryTrackBtn.is(":checked") : false,
newComments: $commentsTrackBtn.is(":checked")
});
- });
- var $btnsContainer = $("<div class='track_btncontainer'></div>")
- .append( $savebutton,
- $("<a></a>", {"href": $ele.attr("href"), "class": "track_moreopts"}).html("More Options")
- ).appendTo($dlg);
-
- return $dlg;
- }
-
- })
+ },
+ "More Options": function() {
+ document.location = $ele.attr("href");
+ }
+ },
+ maxWidth: "80%",
+ width: 500
+ });
});
-
}
-});
+});
-})(jQuery,window.Site||{},window.LJ_cmtinfo||{});
+})(jQuery,window.Site||{});
jQuery(function($){
$("a.TrackButton").trackbutton();
View
12 htdocs/js/jquery.iconselector.js
@@ -81,9 +81,9 @@
$(".iconselector_top .keywords", $.fn.iconselector.instance)
.replaceWith($keywords.clone());
if ($keywords.length > 0)
- $("#iconselector_select").removeAttr("disabled");
+ $("#iconselector_select").prop("disabled", false);
else
- $("#iconselector_select").attr("disabled", "disabled");
+ $("#iconselector_select").prop("disabled", true);
} else {
$(".iconselector_top .selected", $.fn.iconselector.instance)
.removeClass("selected");
@@ -225,8 +225,8 @@
- 5
);
- $("button", $.fn.iconselector.instance.siblings()).attr("disabled", "true");
- $(":input", $.fn.iconselector.instance).attr("disabled", "true");
+ $("button", $.fn.iconselector.instance.siblings()).prop("disabled", true);
+ $(":input", $.fn.iconselector.instance).prop("disabled", true);
$("#iconselector_search", $.fn.iconselector.instance).bind("keyup click", _filterPics);
var url = Site.currentJournalBase ? "/" + Site.currentJournal + "/__rpc_userpicselect" : "/__rpc_userpicselect";
@@ -277,8 +277,8 @@
$("#iconselector_icons").empty().append($iconslist);
- $("button", $.fn.iconselector.instance.siblings()).removeAttr("disabled");
- $(":input:not([id='iconselector_select'])", $.fn.iconselector.instance).removeAttr("disabled");
+ $("button", $.fn.iconselector.instance.siblings()).prop("disabled", false);
+ $(":input:not([id='iconselector_select'])", $.fn.iconselector.instance).prop("disabled", false);
$("#iconselector_icons_list")
.click(_selectByClick)
.dblclick(function(e) {
View
240 htdocs/js/jquery.poll.js
@@ -20,67 +20,65 @@ $.widget("dw.dynamicpoll", {
if ( ! pollid || ! pollqid ) return;
- $clicked
- .ajaxtip({namespace: "pollanswer"})
+ $clicked.ajaxtip() // init
.ajaxtip("load", {
endpoint: "poll",
- context: self,
- data: {
- pollid : pollid,
- pollqid : pollqid,
- page : $clicked.attr("lj_page"),
- pagesize: $clicked.attr("lj_pagesize"),
- action : "get_answers"
- },
- success: function( data, status, jqxhr ) {
- if ( data.error ) {